Debian Codegraph @

.github/workflows/tests.yaml

raw
1 name: pefile tests
2
3 on: push
4
5 jobs:
6 tests:
7 name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
8 runs-on: "${{ matrix.os }}"
9
10 strategy:
11 fail-fast: false
12 matrix:
13 os:
14 - ubuntu-latest
15 - macos-latest
16 - windows-latest
17 python-version:
18 - "3.8"
19 - "3.9"
20 - "3.10"
21 - "3.11"
22 - "3.12"
23 - "pypy3.9"
24 include:
25 - os: ubuntu-latest
26 python-version: "3.10"
27 coverage: 1
28
29 steps:
30 - name: Harden Runner
31 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
32 with:
33 egress-policy: audit
34
35 - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
36 - name: Set up Python ${{ matrix.python-version }}
37 uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
38 with:
39 python-version: ${{ matrix.python-version }}
40 - name: Install dependencies
41 run: |
42 python -m pip install --upgrade pip
43 pip install flake8 tox tox-gh-actions
44 - name: Lint with flake8
45 run: |
46 # stop the build if there are Python syntax errors or undefined names
47 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
48 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
49 flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
50
51 - name: Clone https://github.com/erocarrera/pefile-tests
52 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
53 with:
54 repository: erocarrera/pefile-tests
55 path: ./pefile-tests
56
57 - name: "Run tox for ${{ matrix.python-version }}"
58 run: |
59 python -m tox
60
61 - if: ${{matrix.coverage}}
62 name: "Upload coverage data"
63 uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
64 with:
65 name: covdata
66 path: .coverage.*
67
68 coverage:
69 name: Coverage
70 needs: tests
71 runs-on: ubuntu-latest
72 steps:
73 - name: Harden Runner
74 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
75 with:
76 egress-policy: audit
77
78 - name: "Check out the repo"
79 uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1
80
81 - name: "Set up Python"
82 uses: "actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d" # v5.1.0
83 with:
84 python-version: "3.10"
85
86 - name: "Install dependencies"
87 run: |
88 python -m pip install --upgrade pip
89 python -m pip install tox tox-gh-actions
90
91 - name: "Download coverage data"
92 uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
93 with:
94 name: covdata
95
96 - name: "Combine"
97 run: |
98 python -m tox -e coverage
99 export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
100 echo "total=$TOTAL" >> $GITHUB_ENV
101 echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
102
103 - name: "Make badge"
104 uses: schneegans/[email protected]
105 with:
106 # GIST_TOKEN is a GitHub personal access token with scope "gist".
107 auth: ${{ secrets.GIST_TOKEN }}
108 gistID: 2150adbc4ea8c61e381fdb9da0943723 # Gist id.
109 filename: covbadge.json
110 label: Coverage
111 message: ${{ env.total }}%
112 minColorRange: 50
113 maxColorRange: 90
114 valColorRange: ${{ env.total }}