Skip to content

CIで体裁チェックとビルドチェックを実行 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Language: Cpp
BasedOnStyle: Google

AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
BraceWrapping:
AfterClass: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BreakBeforeBraces: Custom
ColumnLimit: 100
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
PointerAlignment: Middle
ReflowComments: false
63 changes: 63 additions & 0 deletions .github/workflows/compile-sketches.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Compile Sketches

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

env:
# It's convenient to set variables for values used multiple times in the workflow
SKETCHES_REPORTS_PATH: sketches-reports
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports

jobs:
compile-sketches:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/compile-sketches@v1
with:
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: esp32:esp32:esp32s3
platforms: | # ESP32公式のpackage indexを使用する
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
sketch-paths: |
- pico_halfV2_STEP1_LED
- pico_halfV2_STEP2_SWITCH
- pico_halfV2_STEP3_Buzzer
- pico_halfV2_STEP4_Sensor
- pico_halfV2_STEP5_Straight
- pico_halfV2_STEP6_rotate
- pico_halfV2_STEP7_P_control
- pico_halfV2_STEP8_micromouse

# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
path: ${{ env.SKETCHES_REPORTS_PATH }}

report:
needs: compile-sketches # Wait for the compile job to finish to get the data for the report
if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
runs-on: ubuntu-latest
steps:
# This step is needed to get the size data produced by the compile jobs
- name: Download sketches reports artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
path: ${{ env.SKETCHES_REPORTS_PATH }}

- uses: arduino/report-size-deltas@v1
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
github-token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
arduino-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
recursive: true
compliance: specification
clang-format:
needs: arduino-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 各スケッチファイルの.ino、.hファイルに対してclang-formatによる整形が必要か判定する
# 正規表現を簡単にするためzshを使用する
- run: sudo apt install -y clang-format zsh
- run: clang-format --dry-run -Werror pico_halfV2_STEP*/*.(ino|h)
shell: zsh {0}
1 change: 1 addition & 0 deletions pico_halfV2_STEP1_LED/.clang-format
1 change: 1 addition & 0 deletions pico_halfV2_STEP2_SWITCH/.clang-format
4 changes: 2 additions & 2 deletions pico_halfV2_STEP2_SWITCH/pico_halfV2_STEP2_SWITCH.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void setup()
pinMode(SW_L, INPUT);
pinMode(SW_R, INPUT);

g_state_r = g_state_l = 0;
g_state_r = g_state_l = 0;
}

void loop()
{
// put your main code here, to run repeatedly:
while ( digitalRead(SW_L) && digitalRead(SW_R)) {
while (digitalRead(SW_L) && digitalRead(SW_R)) {
continue;
}
if (digitalRead(SW_R) == 0) {
Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP3_Buzzer/.clang-format
2 changes: 1 addition & 1 deletion pico_halfV2_STEP3_Buzzer/pico_halfV2_STEP3_Buzzer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void setup()
void loop()
{
// put your main code here, to run repeatedly:
while ( digitalRead(SW_L) & digitalRead(SW_R)) {
while (digitalRead(SW_L) & digitalRead(SW_R)) {
continue;
}
if (digitalRead(SW_R) == 0) {
Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP4_Sensor/.clang-format
2 changes: 1 addition & 1 deletion pico_halfV2_STEP4_Sensor/pico_halfV2_STEP4_Sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ portMUX_TYPE g_timer_mux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR onTimer1(void)
{
static char cnt = 0;
short temp_r,temp_l;
short temp_r, temp_l;
portENTER_CRITICAL_ISR(&g_timer_mux);
switch (cnt) {
case 0:
Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP5_Straight/.clang-format
2 changes: 1 addition & 1 deletion pico_halfV2_STEP5_Straight/pico_halfV2_STEP5_Straight.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define MIN_HZ 40
#define TIRE_DIAMETER (24.70)
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
#define MIN_SPEED (MIN_HZ * PULSE)

hw_timer_t * g_timer0 = NULL;
Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP6_rotate/.clang-format
2 changes: 1 addition & 1 deletion pico_halfV2_STEP6_rotate/pico_halfV2_STEP6_rotate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define MIN_HZ 40
#define TIRE_DIAMETER (24.70)
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
#define MIN_SPEED (MIN_HZ * PULSE)
#define TREAD_WIDTH (31.5)

Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP7_P_control/.clang-format
10 changes: 5 additions & 5 deletions pico_halfV2_STEP7_P_control/interrupt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void controlInterrupt(void)
void sensorInterrupt(void)
{
static char cnt = 0;
short temp_r,temp_l;
short temp_r, temp_l;

switch (cnt) {
case 0:
Expand All @@ -61,8 +61,8 @@ void sensorInterrupt(void)
for (int i = 0; i < 10; i++) {
asm("nop \n");
}
g_sen_fr.value = analogRead(AD4)-temp_r;
g_sen_fl.value = analogRead(AD1)-temp_l;
g_sen_fr.value = analogRead(AD4) - temp_r;
g_sen_fl.value = analogRead(AD1) - temp_l;
digitalWrite(SLED_F, LOW);
if (g_sen_fr.value > g_sen_fr.th_wall) {
g_sen_fr.is_wall = true;
Expand All @@ -83,8 +83,8 @@ void sensorInterrupt(void)
for (int i = 0; i < 10; i++) {
asm("nop \n");
}
g_sen_r.value = analogRead(AD3)-temp_r;
g_sen_l.value = analogRead(AD2)-temp_l;
g_sen_r.value = analogRead(AD3) - temp_r;
g_sen_l.value = analogRead(AD2) - temp_l;
digitalWrite(SLED_S, LOW);
if (g_sen_r.value > g_sen_r.th_wall) {
g_sen_r.is_wall = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#define MIN_HZ 40
#define TIRE_DIAMETER (24.70)
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
#define MIN_SPEED (MIN_HZ * PULSE)

//環境に合わせて変更する
Expand Down
1 change: 1 addition & 0 deletions pico_halfV2_STEP8_micromouse/.clang-format
24 changes: 12 additions & 12 deletions pico_halfV2_STEP8_micromouse/device.ino
Original file line number Diff line number Diff line change
Expand Up @@ -257,31 +257,31 @@ unsigned char getSW(void)
}

//sensor
void getSensorS(volatile short *r_value, volatile short *l_value)
void getSensorS(volatile short * r_value, volatile short * l_value)
{
short temp_r,temp_l;
temp_r=analogRead(AD3);
temp_l=analogRead(AD2);
short temp_r, temp_l;
temp_r = analogRead(AD3);
temp_l = analogRead(AD2);
digitalWrite(SLED_S, HIGH);
for (int i = 0; i < WAITLOOP_SLED; i++) {
asm("nop \n");
}
*r_value = analogRead(AD3)-temp_r;
*l_value = analogRead(AD2)-temp_l;
*r_value = analogRead(AD3) - temp_r;
*l_value = analogRead(AD2) - temp_l;
digitalWrite(SLED_S, LOW);
}

void getSensorF(volatile short *fr_value, volatile short *fl_value)
void getSensorF(volatile short * fr_value, volatile short * fl_value)
{
short temp_r,temp_l;
temp_r=analogRead(AD4);
temp_l=analogRead(AD1);
short temp_r, temp_l;
temp_r = analogRead(AD4);
temp_l = analogRead(AD1);
digitalWrite(SLED_F, HIGH); //LED点灯
for (int i = 0; i < WAITLOOP_SLED; i++) {
asm("nop \n");
}
*fr_value = analogRead(AD4)-temp_r;
*fl_value = analogRead(AD1)-temp_l;
*fr_value = analogRead(AD4) - temp_r;
*fl_value = analogRead(AD1) - temp_l;
digitalWrite(SLED_F, LOW); //LED消灯
}

Expand Down
4 changes: 2 additions & 2 deletions pico_halfV2_STEP8_micromouse/interrupt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void sensorInterrupt(void)
case 0:
g_sen_r.p_value = g_sen_r.value;
g_sen_l.p_value = g_sen_l.value;
getSensorS(&g_sen_r.value,&g_sen_l.value);
getSensorS(&g_sen_r.value, &g_sen_l.value);
if (g_sen_r.value > g_sen_r.th_wall) {
g_sen_r.is_wall = true;
} else {
Expand Down Expand Up @@ -91,7 +91,7 @@ void sensorInterrupt(void)
case 1:
g_sen_fr.p_value = g_sen_fr.value;
g_sen_fl.p_value = g_sen_fl.value;
getSensorF(&g_sen_fr.value,&g_sen_fl.value);
getSensorF(&g_sen_fr.value, &g_sen_fl.value);
if (g_sen_fr.value > g_sen_fr.th_wall) {
g_sen_fr.is_wall = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion pico_halfV2_STEP8_micromouse/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define TIRE_DIAMETER (24.7)
#define TREAD_WIDTH (31.5)
#define TREAD_CIRCUIT (TREAD_WIDTH * PI / 4)
#define PULSE (TIRE_DIAMETER * PI / (35.0/10.0*20.0*4.0))
#define PULSE (TIRE_DIAMETER * PI / (35.0 / 10.0 * 20.0 * 4.0))
#define MIN_HZ 40

#define WAITLOOP_SLED 10
Expand Down