Add PyPI job to CD.yml #21
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
| # Run CI tests | |
| name: CI | |
| # Controls when the action will run. | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the master branch | |
| push: | |
| branches: master | |
| pull_request: | |
| branches: master | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| # JOB to run change in the build files | |
| changes: | |
| runs-on: ubuntu-latest | |
| # Required permissions | |
| permissions: | |
| pull-requests: read | |
| # Set job outputs to values from filter step | |
| outputs: | |
| files: ${{ steps.filter.outputs.files }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/[email protected] | |
| - name: Filter files | |
| uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2 | |
| id: filter | |
| with: | |
| filters: | | |
| files: | |
| - 'pyproject.toml' | |
| - 'setup.py' | |
| - '.conda/env_build.yml' | |
| - '.conda/meta.yml' | |
| verify-conda-build: | |
| name: Conda Build | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| # Only run if there are changes in the build files | |
| if: ${{ needs.changes.outputs.files == 'true' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup conda build environment | |
| uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | |
| with: | |
| miniconda-version: "latest" | |
| python-version: ${{ vars.PY_VERSION }} | |
| environment-file: .conda/env_build.yml | |
| auto-activate-base: false | |
| auto-update-conda: false | |
| show-channel-urls: true | |
| - name: Enforce .tar.bz2 packages | |
| # Temporary work-arounds while the action uibcdf/action-build-and-upload-conda-packages gets updated: | |
| # We create a `~/.condarc` file with the correct options to enforce the use of `.tar.bz2` packages | |
| # and we set the channels to be used by conda build | |
| shell: bash | |
| run: | | |
| cat > ~/.condarc << EOF | |
| conda-build: | |
| pkg_format: .tar.bz2 | |
| channels: | |
| - accessnri | |
| - conda-forge | |
| - nodefaults | |
| EOF | |
| - name: Verify conda recipe | |
| shell: bash -el {0} | |
| # Ignores: | |
| # C2105 - Found invalid package version in meta.yaml | |
| # C2122 - Found invalid license family | |
| run: conda-verify .conda --ignore C2105,C2122 --exit | |
| - name: Run conda build | |
| shell: bash -el {0} | |
| run: | | |
| conda build . --no-anaconda-upload --output-folder=./build | |
| - name: Verify conda package | |
| shell: bash -el {0} | |
| # Ignores: | |
| # C1105 - Found invalid version number in info/index.json | |
| # C1115 - Found invalid license in info/index.json | |
| # C1141 - Found python file without a corresponding pyc file | |
| run: conda-verify ./build/noarch/*.tar.bz2 --ignore C1105,C1115,C1141 --exit | |
| tests: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/[email protected] | |
| - name: Setup conda environment | |
| uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | |
| with: | |
| miniconda-version: "latest" | |
| python-version: ${{ matrix.python-version }} | |
| environment-file: .conda/env_dev.yml | |
| activate-environment: yamanifest-dev | |
| auto-update-conda: false | |
| auto-activate-base: false | |
| show-channel-urls: true | |
| - name: Install source | |
| shell: bash -l {0} | |
| run: python3 -m pip install --no-deps --no-build-isolation -e . | |
| - name: List installed packages | |
| shell: bash -l {0} | |
| run: conda list | |
| - name: Entrypoint test of driver script | |
| shell: bash -l {0} | |
| run: yamf --help | |
| - name: Run tests | |
| shell: bash -l {0} | |
| run: | | |
| python -m pytest --cov=yamanifest --cov-report=html -s test | |
| # - name: Upload code coverage | |
| # # Only upload once for the installed version | |
| # if: ${{ matrix.python-version == vars.PY_VERSION }} | |
| # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 #v4.6.0 | |
| # with: | |
| # token: ${{ secrets.codecov_token }} | |
| # files: ./coverage.xml |