generated from IRNAS/irnas-zephyr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (149 loc) · 5.32 KB
/
twister.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
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
name: Twister
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
env:
GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}
jobs:
twister-build:
name: "Run Unit Tests"
runs-on: self-hosted
defaults:
run:
shell: bash
# Set work dir to "project" for all 'run' calls. Beware, everything else
# (actions, 'with' params, etc.) still needs to reference full path.
working-directory: project
steps:
- name: Checkout last PR commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: project
# This is needed due to the later east update (west update) command that
# could be cloning from the private repos. The provided token in
# GIT_CREDENTIALS needs to be a fine-grained token, with access to all
# repositores, with "Read-only" access level to the Content repository
# permissions.
- name: Set Git credentials
run: |
git config --global credential.helper '!f() { printf "%s\n" "username=runner" "password=$GIT_CREDENTIALS"; };f'
- name: Install and cache apt packages
if: contains(runner.name, 'Github Action')
uses: awalsh128/cache-apt-pkgs-action@v1.4.1
with:
packages: gcc-multilib lcov
# Update this manually when changing the packages above, increment
# only minor version to keep APT caches separate.
version: 2.0
- name: Retrieve cache
if: contains(runner.name, 'Github Action')
uses: actions/cache@v4
env:
cache-name: cache-modules
with:
path: |
bootloader
modules
nrf
nrfxlib
test
tools
zephyr
~/.local/share/east/downloads/
~/.local/share/east/tooling/nrfutil
# Note above two lines, if we are caching entire ~/.local/share/east
# folder then cache action fails during download/extract step
key:
${{ runner.os }}-build-${{ env.cache-name }}-${{
hashFiles('project/west.yml') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: project/scripts/requirements.txt
- name: Install Python dependencies
run: pip install -r scripts/requirements.txt
- name: Install dependencies
run: make install-dep
- name: Setup project
run: make project-setup
- name: Run tests
run: make test
- name: Create test report
if: always()
run: make test-report-ci
- name: Create coverage report
run: |
make coverage-report-ci
# sed command removes "project/" from the paths in coverage.info,
# so that the GitHub action that makes the coverage report can create
# proper links to the source files.
sed -i 's|project/||g' twister-out/coverage.info
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report
path: |
project/twister-out/twister-report.html
project/twister-out/twister.xml
project/twister-out/twister.log
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
project/twister-out/coverage.info
- name: Post-build clean
# Only for self hosted runners
# Makes sure east init does not fail in the project setup
if: ${{ always() && !contains(runner.name, 'Github Action') }}
run: rm -rf ${{ github.workspace }}/.west
twister-test-results:
name: "Publish Unit Tests Results"
# WARNING: This step is incompatible with self-hosted runners as it uses the 'publish-unit-test-result' action.
# This would require us to run docker-in-docker in the self-hosted runner.
runs-on: ubuntu-22.04
permissions:
contents: read
issues: read
checks: write
needs: twister-build
if: always()
steps:
- name: Download Artefacts
uses: actions/download-artifact@v3
with:
name: test-report
path: test-report
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2.9.0
with:
check_name: Unit Test Results
files: test-report/twister.xml
comment_mode: off
coverage-report:
name: "Publish Coverage Report"
# NOTE: This action is not compatible with "workflow_dispatch" event, so
# it's not possible to run it manually.
runs-on: self-hosted
permissions:
issues: write
pull-requests: write
needs: twister-build
if:
${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
steps:
- name: Download Artefacts
uses: actions/download-artifact@v3
with:
name: coverage-report
path: coverage-report
- name: Publish Coverage Report
uses: romeovs/lcov-reporter-action@4cf015aa4afa87b78238301f1e3dc140ea0e1ec6
with:
lcov-file: ./coverage-report/coverage.info