-
Notifications
You must be signed in to change notification settings - Fork 67
204 lines (184 loc) · 5.9 KB
/
continuous-integration-workflow.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
name: Continuous Integration & Deployment
on:
workflow_dispatch:
push:
tags:
- '*'
branches:
- master
pull_request:
branches:
- master
jobs:
linter:
name: Linter on C code
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint C code
uses: DoozyX/[email protected]
with:
source: 'src tests'
extensions: 'c,h'
clangFormatVersion: 11
misspell:
name: Check misspellings
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check misspellings
uses: codespell-project/actions-codespell@v1
with:
builtin: clear,rare
check_filenames: true
ignore_words_file: .codespell-ignore
skip: ./speculos/api/static/swagger/swagger-ui.css,./speculos/api/static/swagger/swagger-ui-bundle.js,./speculos/api/static/swagger/swagger-ui-standalone-preset.js,./speculos/fonts
coverage:
name: Code coverage
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Rebuild with code coverage instrumentation
env:
CTEST_OUTPUT_ON_FAILURE: 1
RNG_SEED: 0
run: |
cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 -DCODE_COVERAGE=ON
make -C build clean
make -C build
make -C build test
python3 -m pip install pytest-cov
python3 -m pytest --cov=speculos --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: codecov-speculos
build:
name: Clone, build, test
runs-on: ubuntu-latest
permissions:
packages: write
# Use https://ghcr.io/ledgerhq/speculos-builder which has all the required
# dependencies
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build
run: |
cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1
make -C build
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
make -C build/ test
python3 -m pytest
package_python:
name: Build and deploy Speculos Python Package
runs-on: ubuntu-latest
needs: [build]
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use pip to install Speculos in a virtual environment
run: |
python3 -m venv venv-test
./venv-test/bin/pip install .
./venv-test/bin/speculos --help
echo "TAG_VERSION=$(python -c 'from speculos import __version__; print(__version__)')" >> "$GITHUB_ENV"
- name: Build Speculos python package
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
if [ -e dist ] ; then
echo >&2 "Error: dist/ directory already exists and this is unexpected. Refusing to build new packages."
exit 1
fi
python3 -m venv venv-build
./venv-build/bin/pip install --upgrade pip build twine
./venv-build/bin/python -m build
./venv-build/bin/python -m twine check dist/*
- name: Display current status
shell: bash
run: |
echo "Current status is:"
if [[ ${{ github.ref }} == "refs/tags/"* ]]; \
then \
echo "- Triggered from tag, will be deployed on pypi.org"; \
else \
echo "- Not triggered from tag, will be deployed on test.pypi.org"; \
fi
echo "- Tag version: ${{ env.TAG_VERSION }}"
- name: Check version against CHANGELOG
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
CHANGELOG_VERSION=$(grep -Po '(?<=## \[)(\d\.)+[^\]]' CHANGELOG.md | head -n 1)
if [ "${{ env.TAG_VERSION }}" == "${CHANGELOG_VERSION}" ]; \
then \
exit 0; \
else \
echo "Tag '${{ env.TAG_VERSION }}' and CHANGELOG '${CHANGELOG_VERSION}' versions mismatch!"; \
exit 1; \
fi
- name: Publish Python package on pypi.org
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: ./venv-build/bin/python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLIC_API_TOKEN }}
TWINE_NON_INTERACTIVE: 1
- name: Publish Python package on test.pypi.org
if: success() && github.event_name == 'push'
run: ./venv-build/bin/python -m twine upload --repository testpypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PUBLIC_API_TOKEN }}
TWINE_NON_INTERACTIVE: 1
package_and_test_docker:
name: Build and test the Speculos docker
uses: ./.github/workflows/reusable_ragger_tests_latest_speculos.yml
with:
app_repository: LedgerHQ/app-boilerplate
app_branch_name: master
test_dir: tests
speculos_app_branch_name: ${{ github.ref }}
deploy_docker:
name: Build and Upload the Speculos docker
runs-on: ubuntu-latest
if: |
github.event_name == 'push' &&
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
needs: [build]
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build and publish to GitHub Packages
uses: docker/build-push-action@v1
with:
repository: ledgerhq/speculos
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tag_with_sha: true
tags: latest