From 54509cb96bbc0101daa7fd01b709d49a2d5f8bdd Mon Sep 17 00:00:00 2001 From: daklauss Date: Wed, 8 Jan 2025 20:20:22 +0100 Subject: [PATCH] Add coverage pipeline --- .github/workflows/coverage.yml | 70 ++++++++++++++++++++++++++++++++++ pyproject.toml | 3 ++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..ce79d4d9 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,70 @@ +name: coverage + +on: + push: + branches: + - master + - dev + - 144-monitor-test-coverage + workflow_dispatch: + +jobs: + test-job: + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.12"] + + env: + CONDA_FILE: environment.yml + + steps: + - uses: actions/checkout@v4 + + - name: Get Date + id: get-date + run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT + shell: bash + + - name: Setup Conda Environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + use-mamba: true + activate-environment: cadet-process + channels: conda-forge, + + - name: Cache conda + uses: actions/cache@v4 + env: + # Increase this value to reset cache if environment.yml has not changed + CACHE_NUMBER: 0 + with: + path: ${{ env.CONDA }}/envs + key: ${{ matrix.os }}-python_${{ matrix.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(env.CONDA_FILE) }}-${{ env.CACHE_NUMBER }} + + - name: Update environment + run: | + mamba install "setuptools>=69" "pip>=24" + mamba install python=${{ matrix.python-version }} + echo "python=${{ matrix.python-version }}.*" > $CONDA_PREFIX/conda-meta/pinned + mamba env update -n cadet-process -f ${{ env.CONDA_FILE }} + if: steps.cache.outputs.cache-hit != 'true' + + - name: Install + run: | + pip install -e ./[testing, coverage] + + - name: Test + run: | + coverage run -m pytest tests + + - name: Result + run: | + coverage report -m \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0083582b..ebc0171e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,9 @@ docs = [ ax = [ "ax-platform >=0.3.5" ] +coverage = [ + "coverage" +] [project.urls] homepage = "https://github.com/fau-advanced-separations/CADET-Process"