Skip to content

Commit 0c01bed

Browse files
committed
ci: add arduino-lint github action
1 parent a26a709 commit 0c01bed

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/arduino_lint.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# yamllint disable rule:line-length
2+
---
3+
name: Arduino Lint
4+
on: # yamllint disable-line rule:truthy
5+
pull_request:
6+
branches: ['*']
7+
8+
jobs:
9+
arduino-lint:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: dtors/base-cpp:latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Configure Git Safe Directory
19+
run: |
20+
git config --global --add safe.directory $(pwd)
21+
22+
- name: Find affected files
23+
run: |
24+
git fetch origin ${{ github.base_ref }} --depth=1
25+
git diff --name-only origin/${{ github.base_ref }} > affected_files.txt
26+
echo "Affected files:"
27+
cat affected_files.txt
28+
29+
- name: Find affected ino files
30+
run: |
31+
> affected_ino_files.txt
32+
33+
while read file; do
34+
if [[ "$file" == *.ino ]]; then
35+
echo "$file" >> affected_ino_files.txt
36+
fi
37+
done < affected_files.txt
38+
39+
sort -u affected_ino_files.txt -o affected_ino_files.txt
40+
echo "Affected ino files:"
41+
cat affected_ino_files.txt
42+
echo "ino_files=$(cat affected_ino_files.txt | tr '\n' ' ')" >> $GITHUB_ENV
43+
shell: bash
44+
45+
- name: Run arduino-lint
46+
if: env.ino_files != ''
47+
run: |
48+
echo "Running: arduino-lint ./arduino"
49+
arduino-lint ./arduino
50+
51+
- name: Skip arduino-lint
52+
if: env.ino_files == ''
53+
run: echo "No affected ino files found. Skipping arduino-lint."

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ RUN apt-get update && apt-get install -y \
3737

3838
RUN pip install yamllint
3939

40+
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh | sh
41+
4042
RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.23.0/bazelisk-linux-amd64 && \
4143
chmod 755 bazelisk-linux-amd64 && \
4244
mv bazelisk-linux-amd64 /usr/bin/bazelisk
43-
RUN echo "alias bazel='bazelisk'" >> ~/.bashrc
45+
RUN echo "alias bazel='bazelisk'" >> $HOME/.profile
46+
47+
# Add the script to modify the PATH variable in .profile
48+
ENV HOME=/root
49+
RUN echo 'if [ -d "$HOME/bin" ] ; then\n PATH="$HOME/bin:$PATH"\nfi' >> $HOME/.profile && \
50+
echo 'if [ -d "$HOME/usr/bin" ] ; then\n PATH="$HOME/usr/bin:$PATH"\nfi' >> $HOME/.profile

0 commit comments

Comments
 (0)