-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (78 loc) · 2.79 KB
/
e2e.yaml
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
name: sriov-e2e-test
run-name: sriov-e2e-test initiated by ${{ github.actor }}
on:
pull_request:
types: [labeled]
workflow_dispatch:
jobs:
e2e-tests:
runs-on: self-hosted
if: contains(github.event.label.name, 'e2e-test')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f sriov/requirements.txt ]; then pip install -r sriov/requirements.txt; fi
pip install mock
- name: e2e test
working-directory: ${{ github.workspace }}
run: |
files=`git diff --name-only origin/main`
echo "diff files: $files"
pyfiles="conftest.py config.py configtestdata.py utils.py exec.py macros.py"
mode=""
tests=()
for f in ${files}; do
file=$(basename $f)
if [[ " ${pyfiles} " =~ " ${file} " ]]; then
mode="full"
break
elif [[ "$f" =~ "sriov/tests/" ]]; then
parentdir=$(dirname "$f")
testname=$(basename "${parentdir}")
tests+=("${testname}")
fi
done
cd sriov/tests
cp /config/*.yaml ./
if [[ "${mode}" == "full" ]]; then
pytest -v --html=report.html --self-contained-html SR_IOV_* common
echo "generated=true" >> $GITHUB_ENV
elif [[ ${#tests[@]} -ne 0 ]]; then
test_string="pytest -v --html=report.html --self-contained-html"
for testname in $(echo "${tests[@]}" | tr ' ' '\n' | sort -u); do
test_string="${test_string} ${testname}"
echo "Testing ${testname}"
done
${test_string}
echo "generated=true" >> $GITHUB_ENV
else
echo "no common code or test case code change - no e2e run"
echo "generated=false" >> $GITHUB_ENV
fi
- name: Upload HTML Artifact
if: ${{ env.generated == 'true' }}
uses: actions/upload-artifact@v3
with:
name: html-report
path: sriov/tests/report.html
retention-days: 3
- name: Display Status
run: echo "This job's status is ${{ job.status }}."
remove-label:
needs: e2e-tests
permissions:
pull-requests: write
issues: write
runs-on: ubuntu-latest
if: always() && contains(github.event.label.name, 'e2e-test')
steps:
- name: remove label
run: |
curl --silent -X DELETE -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ github.token }}' 'https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/e2e-test'