Split main into separate function and add entry point #48
Workflow file for this run
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
# 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: [ main, develop ] | |
pull_request: | |
branches: [ main, develop ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
PY_VERSION: "3.10" | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
conda-build: | |
name: Conda Build | |
runs-on: ubuntu-latest | |
env: | |
NAME: test-${{ github.event.repository.name }} | |
outputs: | |
artifact-name: ${{ env.NAME }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup conda environment | |
uses: conda-incubator/setup-miniconda@11b562958363ec5770fef326fe8ef0366f8cbf8a # v3.0.1 | |
with: | |
miniconda-version: "latest" | |
python-version: ${{ env.PY_VERSION }} | |
environment-file: conda/environment.yml | |
auto-update-conda: false | |
auto-activate-base: false | |
show-channel-urls: true | |
- name: Run conda build | |
shell: bash -el {0} | |
run: | | |
conda build . --no-anaconda-upload --output-folder=./build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.NAME }} | |
if-no-files-found: error | |
path: ./build | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
needs: conda-build | |
# Run the job for different versions of python | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
env: | |
ARTIFACT_LOCATION: ${{ github.workspace }}/conda-local | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.conda-build.outputs.artifact-name }} | |
path: ${{ env.ARTIFACT_LOCATION }} | |
- name: Setup conda environment | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniconda-version: "latest" | |
python-version: ${{ matrix.python-version }} | |
environment-file: conda/environment.yml | |
activate-environment: um2nc | |
- name: Install conda package | |
shell: bash -l {0} | |
run: | | |
conda install -c file://${{ env.ARTIFACT_LOCATION }} -c conda-forge -c accessnri -c coecms um2nc | |
- name: List installed packages | |
shell: bash -l {0} | |
run: conda list | |
- name: Lint | |
shell: bash -l {0} | |
run: pylint --extension-pkg-whitelist=netCDF4 --ignored-modules=umpost -E umpost | |
- name: Entrypoint test | |
shell: bash -l {0} | |
run: esm1p5_convert_nc --help | |
- name: Run tests | |
shell: bash -l {0} | |
run: python -m pytest --cov=umpost --cov-report=xml -s test | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v4 | |
# Only upload once for the installed version | |
if: matrix.python-version == ${{ env.PY_VERSION }} | |
with: | |
token: ${{ secrets.codecov_token }} | |
files: ./coverage.xml |