-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (116 loc) · 3.82 KB
/
test_imas.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Tests in Imas Container
on:
schedule:
# At 05:34 on Sunday
- cron: "34 5 * * 0"
workflow_dispatch:
jobs:
test:
if: github.event.pull_request.draft == false
name: Tests in IMAS container
runs-on: ubuntu-latest
container:
image: gitlab.eufus.psnc.pl:5050/containerization/imas/imas-installer/rockylinux8.6/ual
credentials:
password: ${{ secrets.GITLAB_PSNC_TOKEN }}
username: ${{ secrets.GITLAB_PSNC_USERNAME }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SSH_KEY_CONTAINERIZED_RUNS_REPO }}
repository: duqtools/containerized_runs
path: containerized_runs
- name: Set up containerized runs directory
run: |
echo "CONTAINERIZED_RUNS_DIR=`pwd`/containerized_runs" >> $GITHUB_ENV
- name: Python and Environment info
run: |
whoami
which python
python --version
pwd
ls -alh
- uses: actions/cache@v3
with:
path: .imasenv
key: ${{ hashFiles('pyproject.toml') }}
- name: Create venv and setup duqtools
run: |
if ! test -d ".imasenv"; then
python3 -m venv .imasenv
. .imasenv/bin/activate
python -m pip install -U pip wheel
python -m pip install -e .[develop]
else
. .imasenv/bin/activate
fi
echo "VIRTUAL_ENV=${VIRTUAL_ENV}" >> $GITHUB_ENV
echo "PATH=${PATH}" >> $GITHUB_ENV
- name: Test if IMAS is really available
run: |
. /docker-entrypoint.sh
python -m imas
- name: Test with pytest
run: |
. /docker-entrypoint.sh
coverage run -p -m pytest
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: covdata
path: .coverage.*
coverage:
name: Coverage
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install coverage[toml]
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: covdata
- name: Combine
run: |
coverage combine
- name: Fix paths
shell: python
run: |
import sqlite3
from pathlib import Path
cwd = str(Path.cwd())
with sqlite3.connect('.coverage') as conn:
for (idx, path) in conn.execute('select * from file'):
new_path = path.replace('/__w/duqtools/duqtools', cwd)
q = 'update file set path = :new_path where id = :idx;'
conn.execute(q, {'idx': idx, 'new_path': new_path})
conn.commit()
- name: Report coverage
run: |
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY
coverage report >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY
- name: Make badge
if: ${{ github.ref == 'refs/heads/main' }}
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: ea916a5b3c3d9bc59065a7304e4ca707
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}