From 151850e5ed52c21ce645a350e367eb593623013f Mon Sep 17 00:00:00 2001 From: Thomas Duigou Date: Thu, 6 Feb 2025 19:03:49 +0100 Subject: [PATCH] ci(test): now make use of coveralls --- .github/workflows/test.yml | 59 +++++---------------- .github/workflows/test_deprecated.yml | 74 +++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/test_deprecated.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5498024..00178dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,25 +1,17 @@ name: Test code -on: - - push: - branches: [ '*' ] - # paths: [ '**.py' ] +on: [push, pull_request] jobs: Test: - runs-on: ${{ matrix.os }}-latest - strategy: - matrix: - os: ["ubuntu", "macos", "windows"] + runs-on: ubuntu-latest defaults: run: shell: bash -l {0} steps: - - name: Checkout code uses: actions/checkout@v4 @@ -31,46 +23,21 @@ jobs: activate-environment: test-env conda-remove-defaults: "true" - - name: Install dev dependencies with conda - run: | - conda env update -n test-env --file environment-dev.yml - - name: Install as package run: | - pip -v install --no-deps --editable . + pip -v install --no-deps --editable . - - name: Run tests with coverage - run: | - coverage run -m pytest -xs - - - name: Generate coverage report - if: matrix.os == 'ubuntu' + - name: Install dependencies for testing run: | - coverage report --format markdown > coverage.md + conda install --channel conda-forge pytest + pip install coveralls - - name: Extract coverage percentage - if: matrix.os == 'ubuntu' + - name: Run tests run: | - export COV_PERCENT=$(coverage report --format total) - echo "COV_PERCENT=$COV_PERCENT" >> $GITHUB_ENV + coverage run -m pytest tests - - name: Create Coverage Badge - if: matrix.os == 'ubuntu' - uses: schneegans/dynamic-badges-action@v1.7.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: 056fdf29a6c0ab5b61a62f21468be178 - filename: molecule-signature-coverage.json - label: coverage - message: ${{ env.COV_PERCENT }}% - valColorRange: ${{ env.COV_PERCENT }} - minColorRange: 50 - maxColorRange: 90 - - - name: Upload coverage report - if: matrix.os == 'ubuntu' - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage.md - compression-level: 0 + - name: Report using coveralls + run: | + coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test_deprecated.yml b/.github/workflows/test_deprecated.yml new file mode 100644 index 0000000..2dd33a5 --- /dev/null +++ b/.github/workflows/test_deprecated.yml @@ -0,0 +1,74 @@ +name: Test code (deprecated) + +on: + push: + branches-ignore: [ '*' ] # Prevents this workflow from running + +jobs: + + Test: + + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: ["ubuntu", "macos", "windows"] + defaults: + run: + shell: bash -l {0} + + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install regular dependencies with conda + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: "latest" + environment-file: environment.yml + activate-environment: test-env + conda-remove-defaults: "true" + + - name: Install dev dependencies with conda + run: | + conda env update -n test-env --file environment-dev.yml + + - name: Install as package + run: | + pip -v install --no-deps --editable . + + - name: Run tests with coverage + run: | + coverage run -m pytest -xs + + - name: Generate coverage report + if: matrix.os == 'ubuntu' + run: | + coverage report --format markdown > coverage.md + + - name: Extract coverage percentage + if: matrix.os == 'ubuntu' + run: | + export COV_PERCENT=$(coverage report --format total) + echo "COV_PERCENT=$COV_PERCENT" >> $GITHUB_ENV + + - name: Create Coverage Badge + if: matrix.os == 'ubuntu' + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: 056fdf29a6c0ab5b61a62f21468be178 + filename: molecule-signature-coverage.json + label: coverage + message: ${{ env.COV_PERCENT }}% + valColorRange: ${{ env.COV_PERCENT }} + minColorRange: 50 + maxColorRange: 90 + + - name: Upload coverage report + if: matrix.os == 'ubuntu' + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage.md + compression-level: 0