-
Notifications
You must be signed in to change notification settings - Fork 5
98 lines (85 loc) · 3.26 KB
/
tests.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
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
89
90
91
92
93
94
95
96
97
98
name: Python tests
on:
workflow_run:
workflows: [ 'Linting' ]
types:
- completed
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.10']
redis-version: [6]
environment: tests
steps:
- name: Get PR information
uses: potiuk/get-workflow-origin@v1_5
if: ${{ github.event.workflow_run.event == 'pull_request' }}
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- uses: actions/checkout@v3
if: ${{ github.event.workflow_run.event == 'pull_request' }}
with:
ref: ${{ steps.source-run-info.outputs.mergeCommitSha }}
- uses: actions/checkout@v3
if: ${{ github.event.workflow_run.event != 'pull_request' }}
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements.txt
tests_requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r tests_requirements.txt
cd resources/HTML
python setup.py install
- name: Setup Redis ${{ matrix.redis-version }}
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}
- name: Test with pytest
run: |
export PYTHONPATH="$PWD":$PYTHONPATH
export VIRTUAL_ENV="$PWD"
export TESTS_RESOURCES_DIR="$PWD"/tests/resources
export YANGCATALOG_CONFIG_PATH="$TESTS_RESOURCES_DIR"/test.conf
sed -i "s|<TESTS_RESOURCES_DIR>|${TESTS_RESOURCES_DIR}|g" "$YANGCATALOG_CONFIG_PATH"
coverage run -am pytest
coverage xml
- name: Coverage report PR
if: ${{ github.repository == 'YangCatalog/module-compilation' && github.event.workflow_run.event == 'pull_request' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
override_commit: ${{ steps.source-run-info.outputs.mergeCommitSha }}
override_pr: ${{ steps.source-run-info.outputs.pullRequestNumber }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
- name: Coverage report
if: ${{ github.repository == 'YangCatalog/module-compilation' && github.event.workflow_run.event != 'pull_request'}}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
- uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.event.workflow_run.head_sha }}
name: Tests
conclusion: ${{ job.status }}
output: "{\"summary\":\"Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"