Skip to content

Commit a31f9ad

Browse files
authored
CIで体裁チェックとビルドチェックを実行 (#1)
* .clang-formatを追加 * lint.yamlを追加 * ディレクトリ名がマッチするように修正 * clang-formatコマンドを適用 * checkoutのバージョンを更新 * ビルドチェック用の設定ファイルを追加 * upload-artifactのバージョンを修正
1 parent 7521b2b commit a31f9ad

File tree

21 files changed

+145
-27
lines changed

21 files changed

+145
-27
lines changed

.clang-format

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: AlwaysBreak
6+
BraceWrapping:
7+
AfterClass: true
8+
AfterFunction: true
9+
AfterNamespace: true
10+
AfterStruct: true
11+
BreakBeforeBraces: Custom
12+
ColumnLimit: 100
13+
ConstructorInitializerIndentWidth: 0
14+
ContinuationIndentWidth: 2
15+
DerivePointerAlignment: false
16+
PointerAlignment: Middle
17+
ReflowComments: false
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Compile Sketches
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
pull_request:
8+
paths-ignore:
9+
- '**.md'
10+
workflow_dispatch:
11+
12+
env:
13+
# It's convenient to set variables for values used multiple times in the workflow
14+
SKETCHES_REPORTS_PATH: sketches-reports
15+
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports
16+
17+
jobs:
18+
compile-sketches:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: arduino/compile-sketches@v1
23+
with:
24+
enable-deltas-report: true
25+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
fqbn: esp32:esp32:esp32s3
28+
platforms: | # ESP32公式のpackage indexを使用する
29+
- name: esp32:esp32
30+
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
31+
sketch-paths: |
32+
- pico_halfV2_STEP1_LED
33+
- pico_halfV2_STEP2_SWITCH
34+
- pico_halfV2_STEP3_Buzzer
35+
- pico_halfV2_STEP4_Sensor
36+
- pico_halfV2_STEP5_Straight
37+
- pico_halfV2_STEP6_rotate
38+
- pico_halfV2_STEP7_P_control
39+
- pico_halfV2_STEP8_micromouse
40+
41+
# This step is needed to pass the size data to the report job
42+
- name: Upload sketches report to workflow artifact
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
46+
path: ${{ env.SKETCHES_REPORTS_PATH }}
47+
48+
report:
49+
needs: compile-sketches # Wait for the compile job to finish to get the data for the report
50+
if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
51+
runs-on: ubuntu-latest
52+
steps:
53+
# This step is needed to get the size data produced by the compile jobs
54+
- name: Download sketches reports artifact
55+
uses: actions/download-artifact@v3
56+
with:
57+
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
58+
path: ${{ env.SKETCHES_REPORTS_PATH }}
59+
60+
- uses: arduino/report-size-deltas@v1
61+
with:
62+
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
63+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
pull_request:
8+
paths-ignore:
9+
- '**.md'
10+
workflow_dispatch:
11+
12+
jobs:
13+
arduino-lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: arduino/arduino-lint-action@v1
18+
with:
19+
recursive: true
20+
compliance: specification
21+
clang-format:
22+
needs: arduino-lint
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
# 各スケッチファイルの.ino、.hファイルに対してclang-formatによる整形が必要か判定する
27+
# 正規表現を簡単にするためzshを使用する
28+
- run: sudo apt install -y clang-format zsh
29+
- run: clang-format --dry-run -Werror pico_halfV2_STEP*/*.(ino|h)
30+
shell: zsh {0}

pico_halfV2_STEP1_LED/.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP2_SWITCH/pico_halfV2_STEP2_SWITCH.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ void setup()
3333
pinMode(SW_L, INPUT);
3434
pinMode(SW_R, INPUT);
3535

36-
g_state_r = g_state_l = 0;
36+
g_state_r = g_state_l = 0;
3737
}
3838

3939
void loop()
4040
{
4141
// put your main code here, to run repeatedly:
42-
while ( digitalRead(SW_L) && digitalRead(SW_R)) {
42+
while (digitalRead(SW_L) && digitalRead(SW_R)) {
4343
continue;
4444
}
4545
if (digitalRead(SW_R) == 0) {
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP3_Buzzer/pico_halfV2_STEP3_Buzzer.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void setup()
101101
void loop()
102102
{
103103
// put your main code here, to run repeatedly:
104-
while ( digitalRead(SW_L) & digitalRead(SW_R)) {
104+
while (digitalRead(SW_L) & digitalRead(SW_R)) {
105105
continue;
106106
}
107107
if (digitalRead(SW_R) == 0) {
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP4_Sensor/pico_halfV2_STEP4_Sensor.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ portMUX_TYPE g_timer_mux = portMUX_INITIALIZER_UNLOCKED;
3333
void IRAM_ATTR onTimer1(void)
3434
{
3535
static char cnt = 0;
36-
short temp_r,temp_l;
36+
short temp_r, temp_l;
3737
portENTER_CRITICAL_ISR(&g_timer_mux);
3838
switch (cnt) {
3939
case 0:
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP5_Straight/pico_halfV2_STEP5_Straight.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#define MIN_HZ 40
3030
#define TIRE_DIAMETER (24.70)
31-
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
31+
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
3232
#define MIN_SPEED (MIN_HZ * PULSE)
3333

3434
hw_timer_t * g_timer0 = NULL;
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP6_rotate/pico_halfV2_STEP6_rotate.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#define MIN_HZ 40
3030
#define TIRE_DIAMETER (24.70)
31-
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
31+
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
3232
#define MIN_SPEED (MIN_HZ * PULSE)
3333
#define TREAD_WIDTH (31.5)
3434

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP7_P_control/interrupt.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void controlInterrupt(void)
5050
void sensorInterrupt(void)
5151
{
5252
static char cnt = 0;
53-
short temp_r,temp_l;
53+
short temp_r, temp_l;
5454

5555
switch (cnt) {
5656
case 0:
@@ -61,8 +61,8 @@ void sensorInterrupt(void)
6161
for (int i = 0; i < 10; i++) {
6262
asm("nop \n");
6363
}
64-
g_sen_fr.value = analogRead(AD4)-temp_r;
65-
g_sen_fl.value = analogRead(AD1)-temp_l;
64+
g_sen_fr.value = analogRead(AD4) - temp_r;
65+
g_sen_fl.value = analogRead(AD1) - temp_l;
6666
digitalWrite(SLED_F, LOW);
6767
if (g_sen_fr.value > g_sen_fr.th_wall) {
6868
g_sen_fr.is_wall = true;
@@ -83,8 +83,8 @@ void sensorInterrupt(void)
8383
for (int i = 0; i < 10; i++) {
8484
asm("nop \n");
8585
}
86-
g_sen_r.value = analogRead(AD3)-temp_r;
87-
g_sen_l.value = analogRead(AD2)-temp_l;
86+
g_sen_r.value = analogRead(AD3) - temp_r;
87+
g_sen_l.value = analogRead(AD2) - temp_l;
8888
digitalWrite(SLED_S, LOW);
8989
if (g_sen_r.value > g_sen_r.th_wall) {
9090
g_sen_r.is_wall = true;

pico_halfV2_STEP7_P_control/pico_halfV2_STEP7_P_control.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#define MIN_HZ 40
3939
#define TIRE_DIAMETER (24.70)
40-
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
40+
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
4141
#define MIN_SPEED (MIN_HZ * PULSE)
4242

4343
//環境に合わせて変更する
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.clang-format

pico_halfV2_STEP8_micromouse/device.ino

+12-12
Original file line numberDiff line numberDiff line change
@@ -257,31 +257,31 @@ unsigned char getSW(void)
257257
}
258258

259259
//sensor
260-
void getSensorS(volatile short *r_value, volatile short *l_value)
260+
void getSensorS(volatile short * r_value, volatile short * l_value)
261261
{
262-
short temp_r,temp_l;
263-
temp_r=analogRead(AD3);
264-
temp_l=analogRead(AD2);
262+
short temp_r, temp_l;
263+
temp_r = analogRead(AD3);
264+
temp_l = analogRead(AD2);
265265
digitalWrite(SLED_S, HIGH);
266266
for (int i = 0; i < WAITLOOP_SLED; i++) {
267267
asm("nop \n");
268268
}
269-
*r_value = analogRead(AD3)-temp_r;
270-
*l_value = analogRead(AD2)-temp_l;
269+
*r_value = analogRead(AD3) - temp_r;
270+
*l_value = analogRead(AD2) - temp_l;
271271
digitalWrite(SLED_S, LOW);
272272
}
273273

274-
void getSensorF(volatile short *fr_value, volatile short *fl_value)
274+
void getSensorF(volatile short * fr_value, volatile short * fl_value)
275275
{
276-
short temp_r,temp_l;
277-
temp_r=analogRead(AD4);
278-
temp_l=analogRead(AD1);
276+
short temp_r, temp_l;
277+
temp_r = analogRead(AD4);
278+
temp_l = analogRead(AD1);
279279
digitalWrite(SLED_F, HIGH); //LED点灯
280280
for (int i = 0; i < WAITLOOP_SLED; i++) {
281281
asm("nop \n");
282282
}
283-
*fr_value = analogRead(AD4)-temp_r;
284-
*fl_value = analogRead(AD1)-temp_l;
283+
*fr_value = analogRead(AD4) - temp_r;
284+
*fl_value = analogRead(AD1) - temp_l;
285285
digitalWrite(SLED_F, LOW); //LED消灯
286286
}
287287

pico_halfV2_STEP8_micromouse/interrupt.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void sensorInterrupt(void)
6262
case 0:
6363
g_sen_r.p_value = g_sen_r.value;
6464
g_sen_l.p_value = g_sen_l.value;
65-
getSensorS(&g_sen_r.value,&g_sen_l.value);
65+
getSensorS(&g_sen_r.value, &g_sen_l.value);
6666
if (g_sen_r.value > g_sen_r.th_wall) {
6767
g_sen_r.is_wall = true;
6868
} else {
@@ -91,7 +91,7 @@ void sensorInterrupt(void)
9191
case 1:
9292
g_sen_fr.p_value = g_sen_fr.value;
9393
g_sen_fl.p_value = g_sen_fl.value;
94-
getSensorF(&g_sen_fr.value,&g_sen_fl.value);
94+
getSensorF(&g_sen_fr.value, &g_sen_fl.value);
9595
if (g_sen_fr.value > g_sen_fr.th_wall) {
9696
g_sen_fr.is_wall = true;
9797
} else {

pico_halfV2_STEP8_micromouse/parameter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define TIRE_DIAMETER (24.7)
55
#define TREAD_WIDTH (31.5)
66
#define TREAD_CIRCUIT (TREAD_WIDTH * PI / 4)
7-
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
7+
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
88
#define MIN_HZ 40
99

1010
#define WAITLOOP_SLED 10

0 commit comments

Comments
 (0)