-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
6 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1,8 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters