|
1 | | -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
3 | | - |
4 | | -name: build |
5 | | - |
6 | | -env: |
7 | | - package: codext |
8 | | - |
9 | | -on: |
10 | | - push: |
11 | | - branches: [ "main" ] |
12 | | - pull_request: |
13 | | - branches: [ "main" ] |
14 | | - |
15 | | -jobs: |
16 | | - build: |
17 | | - runs-on: ${{ matrix.os }} |
18 | | - strategy: |
19 | | - fail-fast: false |
20 | | - matrix: |
21 | | - os: [ubuntu-latest] |
22 | | - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] |
23 | | - steps: |
24 | | - - uses: actions/checkout@v3 |
25 | | - - name: Set up Python ${{ matrix.python-version }} |
26 | | - uses: actions/setup-python@v4 |
27 | | - with: |
28 | | - python-version: ${{ matrix.python-version }} |
29 | | - - name: Install ${{ env.package }} |
30 | | - run: | |
31 | | - python -m pip install --upgrade pip |
32 | | - python -m pip install flake8 pytest pytest-cov coverage |
33 | | - pip install -r requirements.txt |
34 | | - pip install . |
35 | | - - name: Lint with flake8 |
36 | | - run: | |
37 | | - # stop the build if there are Python syntax errors or undefined names |
38 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
39 | | - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
40 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
41 | | - - name: Test ${{ env.package }} with pytest |
42 | | - run: | |
43 | | - pytest --cov=$package |
44 | | - coverage: |
45 | | - needs: build |
46 | | - runs-on: ubuntu-latest |
47 | | - env: |
48 | | - cov_badge_path: docs/coverage.svg |
49 | | - steps: |
50 | | - - uses: actions/checkout@v3 |
51 | | - - name: Install ${{ env.package }} |
52 | | - run: | |
53 | | - python -m pip install --upgrade pip |
54 | | - python -m pip install pytest pytest-cov |
55 | | - pip install -r requirements.txt |
56 | | - pip install . |
57 | | - - name: Make coverage badge for ${{ env.package }} |
58 | | - run: | |
59 | | - pip install genbadge[coverage] |
60 | | - pytest --cov=$package --cov-report=xml |
61 | | - genbadge coverage -i coverage.xml -o $cov_badge_path |
62 | | - - name: Verify Changed files |
63 | | - uses: tj-actions/verify-changed-files@v12 |
64 | | - id: changed_files |
65 | | - with: |
66 | | - files: ${{ env.cov_badge_path }} |
67 | | - - name: Commit files |
68 | | - if: steps.changed_files.outputs.files_changed == 'true' |
69 | | - run: | |
70 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
71 | | - git config --local user.name "github-actions[bot]" |
72 | | - git add $cov_badge_path |
73 | | - git commit -m "Updated coverage.svg" |
74 | | - - name: Push changes |
75 | | - if: steps.changed_files.outputs.files_changed == 'true' |
76 | | - uses: ad-m/github-push-action@master |
77 | | - with: |
78 | | - github_token: ${{ secrets.github_token }} |
79 | | - branch: ${{ github.ref }} |
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| 3 | + |
| 4 | +name: build |
| 5 | + |
| 6 | +env: |
| 7 | + package: codext |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [ "main" ] |
| 12 | + pull_request: |
| 13 | + branches: [ "main" ] |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [ubuntu-latest] |
| 22 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v4 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + - name: Install ${{ env.package }} |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + python -m pip install flake8 pytest pytest-cov pytest-pythonpath coverage |
| 33 | + pip install -r requirements.txt |
| 34 | + pip install . |
| 35 | + - name: Lint with flake8 |
| 36 | + run: | |
| 37 | + # stop the build if there are Python syntax errors or undefined names |
| 38 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 39 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 40 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 41 | + - name: Test ${{ env.package }} with pytest |
| 42 | + run: | |
| 43 | + pytest --cov=$package |
| 44 | + coverage: |
| 45 | + needs: build |
| 46 | + runs-on: ubuntu-latest |
| 47 | + env: |
| 48 | + cov_badge_path: docs/coverage.svg |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v3 |
| 51 | + - name: Install ${{ env.package }} |
| 52 | + run: | |
| 53 | + python -m pip install --upgrade pip |
| 54 | + python -m pip install pytest pytest-cov pytest-pythonpath |
| 55 | + pip install -r requirements.txt |
| 56 | + pip install . |
| 57 | + - name: Make coverage badge for ${{ env.package }} |
| 58 | + run: | |
| 59 | + pip install genbadge[coverage] |
| 60 | + pytest --cov=$package --cov-report=xml |
| 61 | + genbadge coverage -i coverage.xml -o $cov_badge_path |
| 62 | + - name: Verify Changed files |
| 63 | + uses: tj-actions/verify-changed-files@v12 |
| 64 | + id: changed_files |
| 65 | + with: |
| 66 | + files: ${{ env.cov_badge_path }} |
| 67 | + - name: Commit files |
| 68 | + if: steps.changed_files.outputs.files_changed == 'true' |
| 69 | + run: | |
| 70 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 71 | + git config --local user.name "github-actions[bot]" |
| 72 | + git add $cov_badge_path |
| 73 | + git commit -m "Updated coverage.svg" |
| 74 | + - name: Push changes |
| 75 | + if: steps.changed_files.outputs.files_changed == 'true' |
| 76 | + uses: ad-m/github-push-action@master |
| 77 | + with: |
| 78 | + github_token: ${{ secrets.github_token }} |
| 79 | + branch: ${{ github.ref }} |
0 commit comments