Skip to content

Commit

Permalink
use hyperspy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne committed May 3, 2024
1 parent 4d51544 commit d4e690c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 161 deletions.
164 changes: 6 additions & 158 deletions .github/workflows/package_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,162 +1,10 @@
# Reusable workflows are not supported with external organizations
# copy and paste
# https://github.com/hyperspy/.github/blob/main/.github/workflows/package_and_test.yml
# Remove 'pooch', 'fetch tags upstream'

name: Package & Test

on:
workflow_call:
inputs:
library_name:
description: 'The name of library, if different from repository name'
# if empty string, the current repository name is used
default: ''
type: string
module_name:
description: 'The name of the module to test, if different from repository name'
# if empty string, the current repository name is used
default: ''
type: string
use_xvfb:
description: 'Whether to install and setup xvfb and pyqt for testing'
# if empty string, the current repository name is used
default: false
type: boolean
EXTRAS:
description: 'Optional “variants” (also called extra) to be installed'
# if empty string, no argument is passed
default: '[tests]'
type: string
PYTEST_ARGS:
description: 'The argurment to pass to pytest call'
# if empty string, no argument is passed
default: ''
type: string
ADDITIONAL_TEST_DEPENDENCIES:
description: 'Additional dependencies to be installed when testing'
# if empty string, no argument is passed
default: ''
type: string


env:
PYTHON_VERSION: '3.11'
on: [push, pull_request]

jobs:
package:
name: Package
runs-on: ubuntu-latest
outputs:
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- uses: actions/setup-python@v5
name: Install Python
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Display version
run: |
python --version
pip --version
- name: Install pypa/build pypa/twine
run: |
pip install build twine
- name: Build a wheel and sdist
run: |
python -m build
- name: Display content dist folder
run: |
ls -shR dist/
- name: Run twin check
run: |
twine check dist/*
- uses: actions/upload-artifact@v4
with:
path: ./dist/*
name: dist

test:
name: Test
needs: package
runs-on: ubuntu-latest
env:
REPOSITORY_NAME: ${{ needs.package.outputs.REPOSITORY_NAME }}
LIBRARY_NAME: ${{ inputs.library_name }}
MODULE_NAME: ${{ inputs.module_name }}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Ubuntu packages for Qt
if: ${{ inputs.use_xvfb }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install qtbase5-dev
sudo apt-get install libxkbcommon-x11-0
sudo apt-get install libxcb-icccm4
sudo apt-get install libxcb-image0
sudo apt-get install libxcb-keysyms1
sudo apt-get install libxcb-randr0
sudo apt-get install libxcb-render-util0
sudo apt-get install libxcb-xinerama0
- name: Install pyqt
if: ${{ inputs.use_xvfb }}
run: |
pip install pyqt5 PyQtWebEngine
- uses: actions/download-artifact@v4

- name: Display content working folder
run: |
ls -shR
- shell: bash
name: Get library name
run: |
if [ '${{ env.LIBRARY_NAME }}' = '' ]; then
LIBRARY_NAME=${{ env.REPOSITORY_NAME }}
echo "LIBRARY_NAME=${LIBRARY_NAME}" >> $GITHUB_ENV
fi
- shell: bash
name: Get module name
run: |
if [ '${{ env.MODULE_NAME }}' = '' ]; then
MODULE_NAME=${{ env.REPOSITORY_NAME }}
echo "MODULE_NAME=${MODULE_NAME}" >> $GITHUB_ENV
fi
- name: Install distribution
env:
EXTRAS: ${{ inputs.EXTRAS }}
run: |
# pint release version doesn't support numpy 2.0
pip install numpy
pip install --pre --find-links dist ${{ env.LIBRARY_NAME }}${{ env.EXTRAS }}
- name: Install additional test dependencies
if: ${{ inputs.ADDITIONAL_TEST_DEPENDENCIES != ''}}
run: |
pip install ${{ inputs.ADDITIONAL_TEST_DEPENDENCIES }}
- name: Pip list
run: |
pip list
package_and_test:
# Use the "reusable workflow" from the hyperspy organisation
uses: hyperspy/.github/.github/workflows/package_and_test.yml@main
with:
ORGANISATION: lumispy
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Release
# Reusable workflows are not supported with external organizations
# Reusable workflows are not supported with trusted publisher
# https://github.com/pypa/gh-action-pypi-publish/issues/166
# copy and paste "jobs" from
# https://github.com/hyperspy/.github/blob/main/.github/workflows/release_pure_python.yml

Expand All @@ -18,11 +19,14 @@ jobs:
package_and_test:
name: Package and Test
# Use the "reusable workflow" from the hyperspy organisation
uses: ./.github/workflows/package_and_test.yml
uses: hyperspy/.github/.github/workflows/package_and_test.yml@main
with:
ORGANISATION: lumispy

upload_to_pypi:
needs: [package_and_test]
runs-on: ubuntu-latest
environment: release
name: Upload to pypi
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
Expand All @@ -41,7 +45,7 @@ jobs:
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/

create_github_release:
# If zenodo is setup to create a DOI automatically on a GitHub release,
# If zenodo is set up to create a DOI automatically on a GitHub release,
# this step will trigger the mining of the DOI
needs: upload_to_pypi
permissions:
Expand Down

0 comments on commit d4e690c

Please sign in to comment.