From 256d8e8f479c293db5b94c2f0227a4879d83610c Mon Sep 17 00:00:00 2001 From: alsmith Date: Tue, 25 Jun 2024 11:43:46 +0100 Subject: [PATCH] chore: Restore conda env for each test --- .github/workflows/CI.yml | 66 +++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bfd42357..191aca4f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,6 +8,7 @@ on: env: CACHE_NUMBER: 1 + CACHE_ID_UNIQ: ${{ github.event.repository.updated_at}} jobs: install: @@ -36,13 +37,6 @@ jobs: # run: | # brew install curl-openssl coreutils - - name: Restore bowtie2 cache - uses: actions/cache@v3 - with: - path: tests/data/data_for_pipeline_run/chr14_bowtie2_indicies/*.bt2 - key: ${{ env.CACHE_NUMBER }} - id: bowtie2_cache - - name: Get Date id: get-date run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT @@ -81,6 +75,13 @@ jobs: run: | pip install .[full] pip install pytest-cov pytest-order pytest-xdist git+https://github.com/alsmith151/CoolBox.git + + - name: Cache the complete environment + uses: actions/cache@v3 + with: + path: ${{ env.CONDA }}/envs + key: ${{env.CACHE_ID_UNIQ}} + id: cache-conda-env-capcruncher test: runs-on: ${{ matrix.os }} @@ -92,21 +93,36 @@ jobs: tests: ['annotate', 'cli', 'counting', 'digest', 'pileup', 'plotting', 'slice_filtering', 'utils'] steps: - - name: Run test for ${{ matrix.tests }} - shell: bash -el {0} - run: | - pytest --cov=./ --cov-report=xml tests/test_${{matrix.tests}}.py - - - name: Run pipeline test for ${{ matrix.assay }} - shell: bash -el {0} - run: | - pytest -vv -s --log-cli-level info --cov=./ --cov-report=xml --cores 4 tests/test_pipeline.py::test_pipeline[${{ matrix.assay }}] - - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v4 - with: - env_vars: OS,PYTHON - token: ${{secrets.CODECOV_TOKEN}} - fail_ci_if_error: true - files: ./coverage.xml - verbose: true + + - name: Restore bowtie2 cache + uses: actions/cache@v3 + with: + path: tests/data/data_for_pipeline_run/chr14_bowtie2_indicies/*.bt2 + key: ${{ env.CACHE_NUMBER }} + id: bowtie2_cache + + - name: Restore capcruncher env + uses: actions/cache@v3 + with: + path: ${{ env.CONDA }}/envs + key: ${{env.CACHE_ID_UNIQ}} + id: cache-conda-env-capcruncher + + - name: Run test for ${{ matrix.tests }} + shell: bash -el {0} + run: | + pytest --cov=./ --cov-report=xml tests/test_${{matrix.tests}}.py + + - name: Run pipeline test for ${{ matrix.assay }} + shell: bash -el {0} + run: | + pytest -vv -s --log-cli-level info --cov=./ --cov-report=xml --cores 4 tests/test_pipeline.py::test_pipeline[${{ matrix.assay }}] + + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v4 + with: + env_vars: OS,PYTHON + token: ${{secrets.CODECOV_TOKEN}} + fail_ci_if_error: true + files: ./coverage.xml + verbose: true