-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (76 loc) · 2.79 KB
/
run_tests.yml
File metadata and controls
88 lines (76 loc) · 2.79 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Test PHX Events
on: [pull_request]
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Get OS Version
run: echo "os_version=$(lsb_release -sr)" >> "$GITHUB_ENV"
- name: Cache pip
id: cache-pip
uses: actions/cache@v2
with:
path: |
${{ env.pythonLocation }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.os_version }}-${{ env.pythonLocation }}-${{ hashFiles('requirements/core.txt') }}-${{ hashFiles('requirements/dev.txt') }}
restore-keys: |
${{ runner.os }}-${{ env.os_version }}-${{ env.pythonLocation }}-${{ hashFiles('requirements/core.txt') }}-
${{ runner.os }}-${{ env.os_version }}-${{ env.pythonLocation }}-
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements/core.txt -r requirements/dev.txt
- name: Run pytest
id: pytest
run: pytest -n=2 --cov=phx_events/ --cov-report= --cov-report=xml --maxfail=2 --disable-warnings
- name: Record Diff Coverage
id: diff-coverage
if: steps.pytest.outcome == 'success'
run: |
echo 'DIFF_COVERAGE<<EOF' >> "$GITHUB_ENV"
# shellcheck disable=SC2005
echo "$(diff-cover coverage.xml --fail-under 100 2>&1)" >> "$GITHUB_ENV"
echo 'EOF' >> "$GITHUB_ENV"
- name: Add Diff Coverage Comment - Missing Coverage
uses: mshick/add-pr-comment@v1
continue-on-error: true
if: steps.diff-coverage.conclusion == 'success' && startsWith(env.DIFF_COVERAGE, 'Failure')
with:
message: |
@${{ github.actor }} please add tests to increase coverage 🙏
```
${{ env.DIFF_COVERAGE }}
```
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: false
- name: Add Diff Coverage Comment - Fully Covered
uses: mshick/add-pr-comment@v1
continue-on-error: true
if: steps.diff-coverage.conclusion == 'success' && !startsWith(env.DIFF_COVERAGE, 'Failure')
with:
message: |
All file changes covered 🎉
```
${{ env.DIFF_COVERAGE }}
```
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: false
- name: Fail If Diff Coverage Under 100%
if: startsWith(env.DIFF_COVERAGE, 'Failure')
run: |
echo "${{ env.DIFF_COVERAGE }}"
exit 1