-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (47 loc) · 1.97 KB
/
all.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Testing, linting, and coverage
on: [ push ]
jobs:
test-lint-coverage:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9 ]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Lint with black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "jointly tests"
- name: Install dependencies
run: |
poetry install
- name: Test with pytest
run: |
poetry run python -m pytest
- if: ${{ matrix.python-version == '3.9' && github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest' }}
name: Calculate coverage
run: |
poetry run coverage run --source=jointly -m pytest
poetry run coverage xml
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; print(int(float(ET.parse('coverage.xml').getroot().attrib['line-rate']) * 100))")
COLOR=$(echo $COVERAGE | python -c "import sys; from bisect import bisect; i=bisect([0,60,70,80,95,100], int(sys.stdin.read()))-1; print(['red', 'orange', 'yellow', 'yellowgreen', 'green', 'brightgreen'][i])")
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV
- if: ${{ matrix.python-version == '3.9' && github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest' }}
name: Create the coverage gist
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: f731de158a21515e2d6c52ed48d406ad
filename: jointly_coverage_main.json
label: Test Coverage
message: ${{ env.COVERAGE }}%
color: ${{ env.COLOR }}