-
Notifications
You must be signed in to change notification settings - Fork 5
141 lines (134 loc) · 4.58 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
name: PlatformIO CI
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/main.yaml"
- "firmware/src/**/*.c"
- "firmware/src/**/*.h"
- "firmware/*.json"
- "firmware/*.ini"
- "firmware/linker_options_pio.py"
pull_request:
paths:
- ".github/workflows/main.yaml"
- "firmware/src/**/*.c"
- "firmware/src/**/*.h"
- "firmware/*.json"
- "firmware/*.ini"
- "firmware/linker_options_pio.py"
jobs:
build_and_check:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Run tests on the native platform
run: |
cd firmware
pio test -e PC_UnitTest
- name: PlatformIO build
run: |
cd firmware
pio run
- name: Upload firmware
uses: actions/upload-artifact@v3
with:
name: firmware
path: firmware/.pio/build/ServoCAN_release/firmware.bin
- name: PlatformIO Check
run: |
cd firmware
echo "${{ secrets.MISRA_TEXT }}" > misra_rules_set_cppcheck.txt
cat misra_rules_set_cppcheck.txt
pio check --fail-on-defect high > report.txt
- name: Upload report
uses: actions/upload-artifact@v3
with:
name: pio check report
path: firmware/report.txt
SonarCloud:
name: Test using SonarCloud
needs: build_and_check
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 4.7.0.2747 # Find the latest version in the "Linux" link on this page:
# https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/
SONAR_SERVER_URL: "https://sonarcloud.io"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Platformio Compilation Database
run: |
cd firmware
pio run -t compiledb
- name: Upload Compilation Database
uses: actions/upload-artifact@v3
with:
name: CompilationDB
path: firmware/compile_commands.json
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: |
cd firmware
# Set the property "sonar.cfamily.compile-commands" to the compilation database file
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.compile-commands=compile_commands.json