Split autoreduction script into functions and add tests #160
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
| name: Tests, Packaging, and Deployment | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: [next, qa, main] | |
| tags: ["v*"] | |
| env: | |
| PKG_NAME: lr_reduction | |
| jobs: | |
| ################# | |
| ### Run Tests ### | |
| ################# | |
| tests: | |
| runs-on: ubuntu-24.04 | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Fetch all history for accurate versioning | |
| fetch-tags: true # Fetch tags to ensure versioning works correctly | |
| submodules: recursive | |
| - name: Set up Pixi | |
| uses: prefix-dev/setup-pixi@v0.9.2 | |
| with: | |
| manifest-path: pyproject.toml | |
| - name: Download test data | |
| run: | | |
| git submodule update --init | |
| git submodule foreach --recursive git lfs pull | |
| echo "data repo size: $(du -sh tests/data/liquidsreflectometer-data)" | |
| - name: Test with coverage | |
| run: | | |
| pixi run test-reduction | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: github.actor != 'dependabot[bot]' | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Build documentation | |
| run: | | |
| pixi run docs-build --environment docs | |
| test -f ./docs/build/html/index.html | |
| ############################## | |
| ### Package and Deployment ### | |
| ############################## | |
| build: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 100 | |
| fetch-tags: true | |
| ref: ${{ github.ref }} | |
| - name: Setup Pixi | |
| uses: prefix-dev/setup-pixi@v0.9.2 | |
| with: | |
| pixi-version: v0.48.2 | |
| - name: Build conda package | |
| run: pixi run conda-build | |
| - name: upload conda package as artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: artifact-conda-package | |
| path: ${{ env.PKG_NAME }}-*.conda | |
| conda-verify: | |
| needs: build | |
| runs-on: ubuntu-24.04 | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| ref: ${{ github.ref }} | |
| - name: Setup micromamba | |
| uses: mamba-org/setup-micromamba@v2 | |
| with: | |
| environment-name: test | |
| init-shell: bash | |
| create-args: >- | |
| python=3.11 | |
| - name: Download conda package artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: artifact-conda-package | |
| path: /tmp/local-channel/linux-64 | |
| - name: Install the package | |
| run: | | |
| micromamba install --yes -c conda-forge conda-build conda-index | |
| python -m conda_index /tmp/local-channel | |
| micromamba install --yes -c /tmp/local-channel -c mantid -c neutrons -c conda-forge ${{ env.PKG_NAME }} | |
| - name: Verify the installation | |
| run: | | |
| conda_version=$(micromamba list "${{ env.PKG_NAME }}" | awk -v pkg="${{ env.PKG_NAME }}" '$1 == pkg { print $2 }') | |
| echo "Conda version: $conda_version" | |
| python_version=$(python -c "import ${{ env.PKG_NAME }}; print(${{ env.PKG_NAME }}.__version__)") | |
| echo "Python version: $python_version" | |
| if [ "$conda_version" != "$python_version" ]; then | |
| echo "Version mismatch!" | |
| exit 1 | |
| else | |
| echo "Versions match." | |
| fi | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| needs: [tests, build, conda-verify] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 100 | |
| fetch-tags: true | |
| ref: ${{ github.ref }} | |
| - name: Setup Pixi | |
| uses: prefix-dev/setup-pixi@v0.9.2 | |
| with: | |
| pixi-version: v0.48.2 | |
| - name: Download conda package artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: artifact-conda-package | |
| - name: Upload package to anaconda | |
| env: | |
| ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| IS_RC: ${{ contains(github.ref, 'rc') }} | |
| run: | | |
| # label is main or rc depending on the tag-name | |
| CONDA_LABEL="main" | |
| if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi | |
| echo pushing ${{ github.ref }} with label $CONDA_LABEL | |
| pixi run anaconda upload --label $CONDA_LABEL --user neutrons ${{ env.PKG_NAME }}-*.conda |