-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (69 loc) · 2.36 KB
/
Copy pathpython_tests.yml
File metadata and controls
69 lines (69 loc) · 2.36 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Automated Python tests
on: [pull_request]
jobs:
Unit-Tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install Poetry (must be version <1.2 for Python 3.6 + 3.7 support)
run: python -m pip install "poetry<1.2"
- name: Install project
run: poetry install
- name: Test with pytest
run: poetry run pytest --junitxml=artifacts/python/junit.xml
Code-Coverage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install Poetry (must be version <1.2 for Python 3.6 + 3.7 support)
run: python -m pip install "poetry<1.2"
- name: Install project
run: poetry install
- name: Run coverage
run: |
poetry run pytest --cov
- name: Coverage badge
run: |
mkdir -p .badges/coverage
rm -f .badges/coverage/python.svg
poetry run coverage-badge -o .badges/coverage/python.svg
- name: Check if badge updated
id: check_badge
run: >
if git diff --quiet .badges/coverage/python.svg; then
echo "::set-output name=updated::0"
else
echo "::set-output name=updated::1"
fi
shell: bash
- name: Commit coverage badge
if: steps.check_badge.outputs.updated == 1
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .badges/coverage/python.svg
git commit -m "Updated Python coverage badge"
- name: Push coverage badge
if: steps.check_badge.outputs.updated == 1
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}