forked from mysensors/MySensors
-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (132 loc) · 4.77 KB
/
build.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
name: Build Arduino Project
on:
push:
branches:
- main
- master
- development
- dev_actions
pull_request:
branches:
- main
- master
- development
- dev_actions
# Allows you to run this workflow manually from the Actions tab for every branch
workflow_dispatch:
jobs:
get_commits:
runs-on: ubuntu-latest
outputs:
commits: ${{ steps.get_commits.outputs.commits }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get list of commits
id: get_commits
run: |
# Use `--no-merges` if you want to exclude merge commits
commits=$(git rev-list --reverse --format="format:%H" --no-merges ${{ github.event.before }}..${{ github.sha }} | grep -v "^commit ")
# Convert the list of hashes into a JSON array
commits_json=$(echo "$commits" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "commits=$commits_json" >> $GITHUB_OUTPUT
#### ToDo: Check if the output is correct
echo "C"
echo "$commits_json"
echo "D"
commit-msg-tests:
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{ fromJson(needs.get_commits.outputs.commits || '[]') }}
needs: get_commits
steps:
#### ToDo: Check if the output is correct
- name: Debug commits output
run: |
echo "Commits: ${{ matrix.commit }}"
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ matrix.commit }}
- name: Set execute permissions for shell scripts
run: chmod +x ./.github/workflows/.ci_scripts/*.sh
- name: Check commit message format
run: ./.github/workflows/.ci_scripts/check-commit-message.sh
static-code-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set execute permissions for shell scripts
run: chmod +x ./.github/workflows/.ci_scripts/*.sh
- name: Check missing keywords and keywords format
run: ./.github/workflows/.ci_scripts/check-missing-keywords.sh
- name: Install astyle
run: sudo apt-get install -y astyle
- name: Check wellformed code style with astyle app
id: check_astyle
run: ./.github/workflows/.ci_scripts/check-astyle-code.sh
continue-on-error: true
- name: Upload astyle restyling.patch file if exists
if: ${{ steps.check_astyle.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: restyling.patch
path: restyling.patch
- name: End job execution on astyle error
if: ${{ steps.check_astyle.outcome == 'failure' }}
run: |
# End job execution with error.
echo "::error::Code style is not wellformed. Find the Git restyling.patch in Artifacts section below."
exit 1
- name: Install cppcheck
run: sudo apt-get install -y cppcheck
- name: Run static code analysis with cppcheck
id: cppcheck_avr
run: ./.github/workflows/.ci_scripts/check-static-cpp-code.sh
continue-on-error: true
- name: Upload cppcheck reports artifact
if: ${{ steps.cppcheck_avr.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: cppcheck-avr.xml
path: cppcheck-avr.xml
- name: Upload cppcheck reports folder
if: ${{ steps.cppcheck_avr.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: cppcheck_reports_folder
path: cppcheck-avr_cppcheck_reports/
- name: End job execution on cppcheck error
if: ${{ steps.cppcheck_avr.outcome == 'failure' }}
run: |
# End job execution with error.
echo "::error::C++ Code with errors detected. See detailed report in Artifacts section below."
exit 1
build-arduino-AVR:
needs: static-code-tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set execute permissions for shell scripts
run: chmod +x ./.github/workflows/.ci_scripts/*.sh
- name: Set up Arduino CLI
uses: arduino/setup-arduino-cli@master
- name: Add library symlink to this MySensors repository
run: |
mkdir -p "$HOME/Arduino/libraries"
ln -s "$PWD" "$HOME/Arduino/libraries/."
- name: Install dependencies
run: |
arduino-cli core update-index
arduino-cli core install arduino:avr
# arduino-cli lib install "Servo" # Uncomment if you need to install a library
- name: Compile sketch
run: |
arduino-cli compile --fqbn arduino:avr:uno ./examples/LightSensor/LightSensor.ino
- name: Compile all sketches from examples folder
run: ./.github/workflows/.ci_scripts/compile-arduino-AVR-UNO-sketches.sh