|
9 | 9 | pull_request: |
10 | 10 | branches: [ master ] |
11 | 11 |
|
12 | | -jobs: |
| 12 | +env: |
| 13 | + PYTHON_VERSION: 3.9 |
13 | 14 |
|
14 | | - build: |
| 15 | +jobs: |
| 16 | + lint: |
15 | 17 | runs-on: ubuntu-latest |
16 | 18 | steps: |
17 | | - |
18 | | - - name: Checkout repository |
19 | | - uses: actions/checkout@v4 |
20 | | - |
21 | | - - name: Set up Python 3.9 |
22 | | - uses: actions/setup-python@v5 |
23 | | - with: |
24 | | - python-version: 3.9 |
25 | | - cache: 'pip' |
26 | | - |
27 | | - - name: Install packages with pip |
28 | | - run: | |
29 | | - python -m pip install --upgrade pip |
30 | | - pip install flake8 pytest pytest-cov |
31 | | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
32 | | -
|
33 | | - - name: Lint with Flake8 |
34 | | - run: | |
35 | | - # stop the build if there are Python syntax errors or undefined names |
36 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
37 | | - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
38 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
39 | | -
|
40 | | - - name: Run tests with pytest |
41 | | - run: | |
42 | | - pytest -v |
43 | | -
|
44 | | - - name: Generate coverage report with pytest-cov |
45 | | - run: | |
46 | | - pytest --cov=./ --cov-report=xml --cov-report=term |
47 | | -
|
48 | | - - name: Upload coverage report artifact |
49 | | - uses: actions/upload-artifact@v4 |
50 | | - with: |
51 | | - name: coverage.xml |
52 | | - path: ./coverage.xml |
53 | | - |
54 | | - coverage-codecov: |
55 | | - needs: build |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ env.PYTHON_VERSION }} |
| 26 | + cache: 'pip' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install -r requirements-lint.txt |
| 32 | +
|
| 33 | + - name: Lint with Flake8 |
| 34 | + run: | |
| 35 | + flake8 . |
| 36 | +
|
| 37 | + test: |
| 38 | + needs: lint |
56 | 39 | runs-on: ubuntu-latest |
57 | 40 | steps: |
58 | | - |
59 | | - - name: Checkout repository |
60 | | - uses: actions/checkout@v4 |
61 | | - |
62 | | - - name: Download coverage report artifact |
63 | | - uses: actions/download-artifact@v4 |
64 | | - with: |
65 | | - name: coverage.xml |
66 | | - |
67 | | - - name: Upload coverage report to Codecov |
68 | | - uses: codecov/codecov-action@v5 |
69 | | - with: |
70 | | - token: ${{ secrets.CODECOV_TOKEN }} |
71 | | - files: coverage.xml |
72 | | - |
73 | | - coverage-codacy: |
74 | | - needs: build |
| 41 | + - name: Checkout repository |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
| 45 | + uses: actions/setup-python@v5 |
| 46 | + with: |
| 47 | + python-version: ${{ env.PYTHON_VERSION }} |
| 48 | + cache: 'pip' |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + pip install -r requirements-test.txt |
| 54 | +
|
| 55 | + - name: Run tests with pytest |
| 56 | + run: | |
| 57 | + pytest -v |
| 58 | +
|
| 59 | + - name: Generate coverage report |
| 60 | + run: | |
| 61 | + pytest --cov=./ --cov-report=xml --cov-report=term |
| 62 | +
|
| 63 | + - name: Upload coverage report artifact |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: coverage.xml |
| 67 | + path: ./coverage.xml |
| 68 | + |
| 69 | + coverage: |
| 70 | + needs: test |
75 | 71 | runs-on: ubuntu-latest |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + service: [codecov, codacy] |
76 | 75 | steps: |
77 | | - |
78 | | - - name: Checkout repository |
79 | | - uses: actions/checkout@v4 |
80 | | - |
81 | | - - name: Download coverage report artifact |
82 | | - uses: actions/download-artifact@v4 |
83 | | - with: |
84 | | - name: coverage.xml |
85 | | - |
86 | | - - name: Upload coverage report to Codacy |
87 | | - uses: codacy/codacy-coverage-reporter-action@v1 |
88 | | - with: |
89 | | - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
90 | | - coverage-reports: coverage.xml |
| 76 | + - name: Checkout repository |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Download coverage report artifact |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: coverage.xml |
| 83 | + |
| 84 | + - name: Upload coverage report to ${{ matrix.service }} |
| 85 | + if: ${{ matrix.service == 'codecov' }} |
| 86 | + uses: codecov/codecov-action@v5 |
| 87 | + with: |
| 88 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 89 | + files: coverage.xml |
| 90 | + |
| 91 | + - name: Upload coverage report to ${{ matrix.service }} |
| 92 | + if: ${{ matrix.service == 'codacy' }} |
| 93 | + uses: codacy/codacy-coverage-reporter-action@v1 |
| 94 | + with: |
| 95 | + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 96 | + coverage-reports: coverage.xml |
0 commit comments