Skip to content

Commit ae20036

Browse files
committed
Test static code analyzer
1 parent 7bb7270 commit ae20036

File tree

7 files changed

+70
-10
lines changed

7 files changed

+70
-10
lines changed

Diff for: .github/scripts/install-arduino-cli.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
OSBITS=`arch`
3+
OSBITS=`uname -m`
44
if [[ "$OSTYPE" == "linux"* ]]; then
55
export OS_IS_LINUX="1"
66
if [[ "$OSBITS" == "i686" ]]; then

Diff for: .github/scripts/on-push.sh

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -e
44

5-
export ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
6-
75
function build(){
86
local target=$1
97
local fqbn=$2

Diff for: .github/scripts/sketch_utils.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
131131
echo "Skipping $sketchname for target $target"
132132
exit 0
133133
fi
134-
134+
135135
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
136136
if [ -n "$ARDUINO_BUILD_DIR" ]; then
137137
build_dir="$ARDUINO_BUILD_DIR"
138138
elif [ $len -eq 1 ]; then
139139
# build_dir="$sketchdir/build"
140-
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
140+
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp/$target"
141141
fi
142142

143143
mkdir -p "$ARDUINO_CACHE_DIR"
@@ -165,7 +165,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
165165
--build-cache-path "$ARDUINO_CACHE_DIR" \
166166
--build-path "$build_dir" \
167167
$xtra_opts "${sketchdir}"
168-
168+
169169
exit_status=$?
170170
if [ $exit_status -ne 0 ]; then
171171
echo ""ERROR: Compilation failed with error code $exit_status""

Diff for: .github/workflows/pre-commit.yml

+48-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ on:
44
pull_request:
55
types: [opened, reopened, synchronize, labeled]
66

7+
concurrency:
8+
group: pre-commit-${{github.event.pull_request.number || github.ref}}
9+
cancel-in-progress: true
10+
711
jobs:
812
lint:
9-
if: |
10-
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
11-
name: Checking if any fixes are needed
13+
#if: ${{ contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') }}
14+
name: Run pre-commit hooks
1215
runs-on: ubuntu-latest
1316
steps:
1417
- name: Checkout latest commit
@@ -35,9 +38,49 @@ jobs:
3538
~/.cache/pip
3639
key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
3740

41+
- name: Install apt dependencies
42+
uses: awalsh128/cache-apt-pkgs-action@latest
43+
with:
44+
packages: cppcheck
45+
version: 1.0
46+
3847
- name: Install python dependencies
3948
run: python -m pip install pre-commit docutils
4049

50+
# - name: Wait on other jobs to finish
51+
# uses: lucasssvaz/wait-on-workflow@v1
52+
# id: wait-on-jobs
53+
# continue-on-error: true
54+
# with:
55+
# workflow: push.yml
56+
# max-wait: 5
57+
# interval: 30
58+
# timeout: 120
59+
# sha: ${{ github.event.pull_request.head.sha || github.sha }}
60+
61+
- name: Download compilation artifacts
62+
uses: actions/download-artifact@v4
63+
# if: ${{ steps.wait-on-jobs.outputs.run-id != '' }}
64+
with:
65+
pattern: build-job-*
66+
merge-multiple: true
67+
path: ~/.arduino/tests/
68+
# run-id: ${{ steps.wait-on-jobs.outputs.run-id }}
69+
run-id: 8674717774
70+
github-token: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Merge compile commands
73+
# if: ${{ steps.wait-on-jobs.outputs.run-id != '' }}
74+
run: |
75+
find ~/.arduino/tests/ -iname "compile_commands.json" | xargs jq -s 'map(.[])' > ~/compile_commands.json
76+
77+
- name: Upload compile commands
78+
# if: ${{ steps.wait-on-jobs.outputs.run-id != '' }}
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: compile_commands
82+
path: ~/compile_commands.json
83+
4184
- name: Get changed files
4285
id: changed-files
4386
uses: tj-actions/[email protected]
@@ -58,3 +101,5 @@ jobs:
58101
- name: Push changes using pre-commit-ci-lite
59102
uses: pre-commit-ci/[email protected]
60103
if: always()
104+
with:
105+
msg: "ci(pre-commit): Apply automatic fixes"

Diff for: .github/workflows/push.yml

+11
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ jobs:
4848
- name: Build Sketches
4949
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
5050

51+
- name: Upload artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: build-job-${{ matrix.chunk }}
55+
path: |
56+
~/.arduino/tests/**/*.h
57+
~/.arduino/tests/**/*.cpp
58+
~/.arduino/tests/**/*.bin
59+
~/.arduino/tests/**/compile_commands.json
60+
if-no-files-found: error
61+
5162
# Windows and MacOS
5263
build-arduino-win-mac:
5364
name: Arduino on ${{ matrix.os }}

Diff for: .pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ repos:
3030
hooks:
3131
- id: clang-format
3232
types_or: [c, c++]
33+
- repo: https://github.com/pocc/pre-commit-hooks
34+
rev: "v1.3.5"
35+
hooks:
36+
- id: cppcheck
37+
types_or: [c, c++]
38+
args: [--force, --enable=all, --suppress=missingInclude, --inline-suppr, --inconclusive]
3339
- repo: https://github.com/psf/black-pre-commit-mirror
3440
rev: "22.10.0"
3541
hooks:

Diff for: cores/esp32/HEXBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
You should have received a copy of the GNU Lesser General Public
1616
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAa
1818
*/
1919

2020
#include <Arduino.h>

0 commit comments

Comments
 (0)