Expands docs task to move all tutorial files #316
Workflow file for this run
This file contains hidden or 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
| # This is the main workflow for testing the code before and after | |
| # packaging it. | |
| # The workflow is divided into three jobs: | |
| # 1. env-prepare: | |
| # - Prepare the environment for testing | |
| # 2. source-test: | |
| # - Test the code base against the latest code in the repository | |
| # - Create the Python package | |
| # - Upload the Python package for the next job | |
| # 3. package-test: | |
| # - Download the Python package (including extra files) from the previous job | |
| # - Install the downloaded Python package | |
| # - Test the code base against the installed package | |
| # 4. dashboard-build-trigger: | |
| # - Trigger the dashboard build workflow to update the code quality | |
| # metrics on the dashboard | |
| name: Code and package tests | |
| on: | |
| # Trigger the workflow on push | |
| push: | |
| # Every branch | |
| branches: ['**'] | |
| # But do not run this workflow on creating a new tag starting with | |
| # 'v', e.g. 'v1.0.3' (see publish-pypi.yml) | |
| tags-ignore: ['v*'] | |
| # Trigger the workflow on pull request | |
| pull_request: | |
| branches: ['**'] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Need permissions to trigger the dashboard build workflow | |
| permissions: | |
| actions: write | |
| contents: read | |
| # 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 }} | |
| jobs: | |
| # Job 1: Prepare environment | |
| env-prepare: | |
| runs-on: [ubuntu-latest] | |
| outputs: | |
| pytest-marks: ${{ steps.set-mark.outputs.pytest_marks }} | |
| steps: | |
| # Determine if integration tests should be run fully or only the fast ones | |
| # (to save time on branches other than master and develop) | |
| - name: Set mark for integration tests | |
| id: set-mark | |
| run: | | |
| if [[ "${{ env.CI_BRANCH }}" == "master" || "${{ env.CI_BRANCH }}" == "develop" ]]; then | |
| echo "pytest_marks=" >> $GITHUB_OUTPUT | |
| else | |
| echo "pytest_marks=-m fast" >> $GITHUB_OUTPUT | |
| fi | |
| # Job 2: Test code | |
| source-test: | |
| needs: env-prepare # depend on previous job | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04, macos-14, windows-2022] | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| PIXI_ENVS: 'py311-dev py313-dev' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: '0' # full history with tags to get the version number by versioningit | |
| - name: Set up pixi | |
| uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| environments: ${{ env.PIXI_ENVS }} | |
| run-install: true | |
| frozen: true | |
| cache: false | |
| post-cleanup: false | |
| - name: Install and setup development dependencies | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env dev | |
| echo "PYTHONPATH:" | |
| pixi run printenv PYTHONPATH || true | |
| pixi run --environment $env easydiffraction --version | |
| done | |
| - name: Run unit tests | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env unit-tests | |
| done | |
| - name: | |
| Run integration tests ${{ needs.env-prepare.outputs.pytest-marks }} | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env integration-tests ${{ needs.env-prepare.outputs.pytest-marks }} | |
| done | |
| # Delete all local tags when not on a tagged commit to force versioningit | |
| # to fall back to the configured default-tag, which is '999.0.0' in our case. | |
| # This is needed for testing the package in the next job, as its version | |
| # must be higher than the PyPI version for pip to prefer the local version. | |
| - name: Force using versioningit default tag (non tagged release) | |
| if: startsWith(github.ref , 'refs/tags/v') != true | |
| run: git tag --delete $(git tag) | |
| - name: Create Python package | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run -e $env dist-build | |
| env_prefix="${env%%-*}" | |
| echo "๐ฆ Moving built wheel to dist/$env_prefix/" | |
| pixi run mkdir -p dist/$env_prefix | |
| pixi run mv dist/*.whl dist/$env_prefix/ | |
| done | |
| - name: Remove local easydiffraction from pixi.toml | |
| shell: bash | |
| run: pixi remove --pypi easydiffraction | |
| - name: Remove Python cache files before uploading | |
| shell: bash | |
| run: pixi run clean-pycache | |
| # More than one file/dir need to be specified in 'path', to preserve the | |
| # structure of the dist/ directory, not only its contents. | |
| - name: Upload Python package for the next job | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: edl_${{ matrix.os }}_${{ runner.arch }} | |
| path: | | |
| dist/ | |
| tests/ | |
| pytest.ini | |
| pixi.toml | |
| pixi.lock | |
| if-no-files-found: 'error' | |
| compression-level: 0 | |
| # Job 3: Test the package | |
| package-test: | |
| needs: [env-prepare, source-test] # depend on previous jobs | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04, macos-14, windows-2022] | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| PIXI_ENVS: 'py311-dev py313-dev' | |
| steps: | |
| - name: | |
| Download zipped Python package (incl. extra files) from previous job | |
| uses: actions/download-artifact@v4 | |
| with: # name or path are taken from the upload step of the previous job | |
| name: edl_${{ matrix.os }}_${{ runner.arch }} | |
| path: . # directory to extract downloaded zipped artifacts | |
| - name: Set up pixi | |
| uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| environments: ${{ env.PIXI_ENVS }} | |
| run-install: true | |
| frozen: true | |
| cache: false | |
| post-cleanup: false | |
| - name: Install and setup development dependencies | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env wheel | |
| done | |
| - name: Add easydiffraction package from the built wheel | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| env_prefix="${env%%-*}" | |
| echo "๐ฆ Looking for wheel in dist/$env_prefix/" | |
| whl_path="$(python3 -c "import pathlib; w = sorted(pathlib.Path('dist/${env_prefix}').glob('*.whl')); print(w[0].resolve().as_uri())")" | |
| echo "๐ฆ Adding easydiffraction from: $whl_path" | |
| pixi add --feature $env_prefix --pypi "easydiffraction[all] @ $whl_path" | |
| pixi run --environment $env easydiffraction --version | |
| done | |
| - name: Run unit tests | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env unit-tests | |
| done | |
| - name: | |
| Run integration tests ${{ needs.env-prepare.outputs.pytest-marks }} | |
| shell: bash | |
| run: | | |
| for env in ${{ env.PIXI_ENVS }}; do | |
| echo "๐น๐ธ๐น๐ธ๐น Current env: $env ๐น๐ธ๐น๐ธ๐น" | |
| pixi run --environment $env integration-tests ${{ needs.env-prepare.outputs.pytest-marks }} | |
| done | |
| # Job 4: Trigger dashboard build | |
| dashboard-build-trigger: | |
| needs: [source-test, package-test] # depend on previous jobs | |
| 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 }}" | |
| }); |