Skip to content

PyPI package tests #122

PyPI package tests

PyPI package tests #122

Workflow file for this run

name: PyPI package tests
on:
# Run daily, at 00:00.
schedule:
- cron: '0 0 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow only one concurrent workflow, skipping runs queued between the run
# in-progress and latest queued. And cancel in-progress runs.
concurrency:
group:
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Set the environment variables to be used in all jobs defined in this workflow
env:
CI_BRANCH: ${{ github.head_ref || github.ref_name }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
jobs:
# Job 1: Test installation from PyPI on multiple OS
pypi-package-tests:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set up pixi
uses: prefix-dev/[email protected]
with:
run-install: false
cache: false
post-cleanup: false
- name:
Download the pixi configuration file from the ${{ env.CI_BRANCH}}
branch
shell: bash
run: |
curl -LO https://raw.githubusercontent.com/easyscience/diffraction-lib/${CI_BRANCH}/pixi.toml
- name: Download the tests from the ${{ env.DEFAULT_BRANCH }} branch
shell: bash
run: |
curl -LO https://github.com/easyscience/diffraction-lib/archive/refs/heads/${DEFAULT_BRANCH}.zip
unzip ${DEFAULT_BRANCH}.zip -d .
mkdir -p tests
cp -r diffraction-lib-${DEFAULT_BRANCH}/tests/* tests/
cp diffraction-lib-${DEFAULT_BRANCH}/pytest.ini .
rm -rf ${DEFAULT_BRANCH}.zip diffraction-lib-${DEFAULT_BRANCH}
- name: Create the environment and install dependencies
run: pixi install
- name: Run unit tests to verify the installation
run: pixi run unit-tests
- name: Run integration tests to verify the installation
run: pixi run integration-tests
# Github token to avoid hitting the unauthenticated API rate limit
- name: List and fetch the EasyDiffraction tutorials
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pixi run easydiffraction --version
pixi run easydiffraction list-tutorials
pixi run easydiffraction download-all-tutorials
- name: Test tutorials as notebooks
run: pixi run notebook-tests
# Job 2: Trigger dashboard build
dashboard-build-trigger:
needs: pypi-package-tests
runs-on: ubuntu-latest
steps:
- name: Check-out repository
uses: actions/checkout@v5
- name: Trigger dashboard build
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "dashboard.yaml",
ref: "${{ env.CI_BRANCH }}"
});