forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (175 loc) · 6.92 KB
/
main.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Build and test
on:
push:
pull_request:
schedule:
# run daily, this refreshes the cache
- cron: '13 2 * * *'
concurrency: # On new push, cancel old workflows from the same PR, branch or tag:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
python-test:
name: Python tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['2.7', '3.11']
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # To check which files changed: origin/master..HEAD
- uses: LizardByte/setup-python-action@master
with:
python-version: ${{matrix.python-version}}
- uses: actions/cache@v3
name: Setup cache for running pre-commit fast
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: echo "::add-matcher::.github/workflows/python-warning-matcher.json"
name: "Setup GitHub for reporting Python warnings as annotations in pull request code review"
- uses: pre-commit/[email protected]
name: Run pre-commit checks (no spaces at end of lines, etc)
if: ${{ matrix.python-version != '2.7' }}
with:
extra_args: --all-files --verbose --hook-stage commit
env:
SKIP: no-commit-to-branch
- name: Install dependencies only needed for python 2
if: ${{ matrix.python-version == '2.7' }}
run: pip install enum
- name: Install dependencies only needed for python 3
if: ${{ matrix.python-version != '2.7' }}
run: pip install pandas pytype toml
- name: Install common dependencies for Python ${{matrix.python-version}}
run: pip install future mock pytest-coverage pytest-mock
- name: Run Pytest and get code coverage for Codecov
run: >
pytest
--cov=scripts --cov=ocaml/xcp-rrdd
scripts/ ocaml/xcp-rrdd -vv -rA
--junitxml=.git/pytest${{matrix.python-version}}.xml
--cov-report term-missing
--cov-report xml:.git/coverage${{matrix.python-version}}.xml
env:
PYTHONDEVMODE: yes
- name: Upload Python ${{matrix.python-version}} coverage report to Codecov
uses: codecov/codecov-action@v3
with:
directory: .git
files: coverage${{matrix.python-version}}.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: python${{matrix.python-version}}
name: coverage${{matrix.python-version}}
verbose: true
- uses: dciborow/[email protected]
if: ${{ matrix.python-version != '2.7' }}
with:
reporter: github-pr-review
level: warning
# To be customized to cover remaining Python scripts:
glob_pattern: "**/*.py"
- name: Run pytype checks
if: ${{ matrix.python-version != '2.7' }}
run: ./pytype_reporter.py
env:
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTYPE_REPORTER_DEBUG: True
# Try to add pytype_report.py's summary file as a comment to the PR:
# Documentation: https://github.com/marketplace/actions/add-pr-comment
- name: Add the pytype summary as a comment to the PR (if permitted)
uses: mshick/add-pr-comment@v2
# Depends on pytype checks, which are not run for python 2.7:
if: ${{ matrix.python-version != '2.7' }}
# Fails for user workflows without permissions(fork-based pull requests):
continue-on-error: true
with:
message-path: .git/pytype-summary.md # Add the content of it as comment
ocaml-test:
name: Ocaml tests
runs-on: ubuntu-20.04
env:
XAPI_VERSION: "v0.0.0"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Free space
run: sudo rm -rf /usr/local/lib/android
- name: Pull configuration from xs-opam
run: |
curl --fail --silent https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env | cut -f2 -d " " > .env
- name: Load environment file
id: dotenv
uses: falti/[email protected]
- name: Update Ubuntu repositories
run: sudo apt-get update
- name: Use disk with more space for TMPDIR and XDG_CACHE_HOME
run: |
df -h || true
export TMPDIR="/mnt/build/tmp"
export XDG_CACHE_HOME="/mnt/build/cache"
sudo mkdir -p "${TMPDIR}" "${XDG_CACHE_HOME}"
sudo chown "$(id -u):$(id -g)" "${TMPDIR}" "${XDG_CACHE_HOME}"
echo "TMPDIR=${TMPDIR}" >>"$GITHUB_ENV"
echo "XDG_CACHE_HOME=${XDG_CACHE_HOME}" >>"$GITHUB_ENV"
- name: Use ocaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ steps.dotenv.outputs.ocaml_version_full }}
opam-repositories: |
xs-opam: ${{ steps.dotenv.outputs.repository }}
dune-cache: true
- name: Install dependencies
run: opam install . --deps-only --with-test -v
- name: Configure
run: opam exec -- ./configure --xapi_version="$XAPI_VERSION"
- name: Build
run: opam exec -- make
- name: Run tests
run: opam exec -- make test
- name: Check all code
run: opam exec -- make check
- name: Run stress tests
run: opam exec -- make stresstest
if: ${{ github.event_name == 'schedule' }}
- name: Build SDK
run: |
mkdir -p /opt/xensource/sm
wget -O /opt/xensource/sm/XE_SR_ERRORCODES.xml https://raw.githubusercontent.com/xapi-project/sm/master/drivers/XE_SR_ERRORCODES.xml
opam exec -- make sdk
- name: Make install smoketest
run: |
opam exec -- make install DESTDIR=$(mktemp -d)
opam exec -- make install DESTDIR=$(mktemp -d) BUILD_PY2=NO
- name: Sanity test SDK
run: |
opam exec -- make sdksanity
- name: Check disk space
run: df -h || true
- name: Uninstall unversioned packages and remove pins
# This should purge them from the cache, unversioned package have
# 'master' as its version
run: |
opam list | awk -F " " '$2 == "master" { print $1 }' | xargs opam uninstall
opam pin list | cut -f1 -d "." | xargs opam unpin
deprecation-test:
name: Deprecation tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate empty configuration for make to be happy
run: touch config.mk
- name: quality-gate
run: make quality-gate
- name: pyflakes
uses: reviewdog/action-pyflakes@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error