From bc5a69c2d195302288dfe404355ef4545099f092 Mon Sep 17 00:00:00 2001 From: "Davide Palma (ElDavo)" Date: Fri, 24 May 2024 20:39:25 +0200 Subject: [PATCH] workflow update run on push on all branches cache dependencies don't run coveralls on pull request --- .github/workflows/codeql-analysis.yml | 2 +- .../{lint-test.yml => lint-test-coverage.yml} | 34 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) rename .github/workflows/{lint-test.yml => lint-test-coverage.yml} (58%) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 11d37e2..f626b1d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,7 +13,7 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: [ '*' ] pull_request: # The branches below must be a subset of the branches above branches: [ main ] diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test-coverage.yml similarity index 58% rename from .github/workflows/lint-test.yml rename to .github/workflows/lint-test-coverage.yml index 5fa9e5d..04fbcd6 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test-coverage.yml @@ -1,16 +1,18 @@ -name: Lint and test +name: "Lint, tests, coverage" on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + push: + branches: + - '*' + pull_request: + branches: + - main permissions: contents: read jobs: - build: + job: runs-on: ubuntu-latest strategy: @@ -23,11 +25,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install flake8 pytest codecov pytest-cov coveralls - python -m pip install . + python -m pip install -e .[test] - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -36,17 +39,10 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - python -m pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=./ - - name: Pytest-cov - uses: lpenz/ghaction-pytest-cov@v1 - - name: Report Coveralls (Linux) - if: startsWith(runner.os, 'Linux') - run: curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls + python -m pytest --cov + - name: Coveralls + uses: coverallsapp/github-action@v2 + if: github.event_name != 'pull_request' env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload pytest test results - uses: actions/upload-artifact@v4 - with: - name: pytest-results-${{ matrix.python-version }} - path: junit/test-results-${{ matrix.python-version }}.xml + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file