Skip to content

Commit 31c8e83

Browse files
authored
ci: Add CI (#5)
* Add ci * Fix path * Fix path * Fix path * Fix checkout * Add vscode format on save * Format server * Fix path * Fix path * Add ci badge to readme * Fix path * Update ci.yml * Use different gitgub action for compile * Update ci.yml * use ubuntu * Rename .ino file * Revert switch case * Update src.ino * Update src.ino * Mover format check to back * Add prettier * Add web format check * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml
1 parent e171b7d commit 31c8e83

File tree

9 files changed

+487
-55
lines changed

9 files changed

+487
-55
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: ci
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
SERVER_PATH: server/src/
7+
WEB_PATH: web/
8+
9+
jobs:
10+
Server-Compile:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
fqbn:
16+
- arduino:avr:uno
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Setup Arduino CLI
22+
uses: arduino/compile-sketches@v1
23+
with:
24+
fqbn: ${{ matrix.fqbn }}
25+
libraries: |
26+
- name: Ethernet
27+
- name: SD
28+
sketch-paths: |
29+
- ${{ env.SERVER_PATH }}
30+
31+
Server-Format-Check:
32+
needs: [Server-Compile]
33+
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
40+
- name: Setup Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: '3.x'
44+
45+
- name: Setup Clang Formatter
46+
uses: actions/checkout@v3
47+
with:
48+
repository: adafruit/ci-arduino
49+
path: ci
50+
51+
- name: Check correct code formatting with clang-format
52+
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" --extensions "ino" -r ${{ env.SERVER_PATH }}
53+
54+
Web-Format-Check:
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v3
60+
61+
- name: Setup Node
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: 18.x
65+
66+
- name: Get yarn cache directory path
67+
id: yarn-cache-dir-path
68+
run: echo "YARN_CACHE_DIR_PATH=$(yarn cache dir)" >> $GITHUB_OUTPUT
69+
70+
- name: Cache yarn dependencies
71+
uses: actions/cache@v3
72+
id: yarn-cache
73+
with:
74+
path: |
75+
${{ steps.yarn-cache-dir-path.outputs.YARN_CACHE_DIR_PATH }}
76+
**/node_modules
77+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
78+
restore-keys: |
79+
${{ runner.os }}-yarn-
80+
81+
- name: Install dependecies
82+
working-directory: ${{ env.WEB_PATH }}
83+
if: steps.yarn-cache.outputs.cache-hit != 'true'
84+
run: yarn --frozen-lockfile
85+
86+
- name: Check format
87+
working-directory: ${{ env.WEB_PATH }}
88+
run: yarn check-format

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Arduino Remote Switch
1+
# Arduino Remote Switch [![ci](https://github.com/MatiasG19/arduino-remote-switch/actions/workflows/ci.yml/badge.svg)](https://github.com/MatiasG19/arduino-remote-switch/actions/workflows/ci.yml)
22

33
Remote switch to turn on, off, reset or kill PC via a web interface.
44

docs/BuildInstructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
3. Put SD card into ethernet shield.
2525
4. Connect Arduino to a powerd on PC via USB and the shield to a router via ethernet.
2626
5. Open router configuration, set a static IP range and choose a free IP address.
27-
6. Set the IP address in the `server.ino` file and save.
28-
7. Open Arduino IDE and upload `server.ino` to Arduino.
27+
6. Set the IP address in the `src.ino` file and save.
28+
7. Open Arduino IDE and upload `src.ino` to Arduino.
2929
8. Test if the website can be reached by typing the IP into the webbrowser.
3030
9. Unplug all the cables from the Arduino for the next steps.
3131

server/.clang-format

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignArrayOfStructures: None
7+
AlignConsecutiveMacros: None
8+
AlignConsecutiveAssignments: None
9+
AlignConsecutiveBitFields: None
10+
AlignConsecutiveDeclarations: None
11+
AlignEscapedNewlines: Right
12+
AlignOperands: Align
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortEnumsOnASingleLine: true
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: All
20+
AllowShortLambdasOnASingleLine: All
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: MultiLine
27+
AttributeMacros:
28+
- __capability
29+
BinPackArguments: true
30+
BinPackParameters: true
31+
BraceWrapping:
32+
AfterCaseLabel: false
33+
AfterClass: false
34+
AfterControlStatement: Never
35+
AfterEnum: false
36+
AfterFunction: false
37+
AfterNamespace: false
38+
AfterObjCDeclaration: false
39+
AfterStruct: false
40+
AfterUnion: false
41+
AfterExternBlock: false
42+
BeforeCatch: false
43+
BeforeElse: false
44+
BeforeLambdaBody: false
45+
BeforeWhile: false
46+
IndentBraces: false
47+
SplitEmptyFunction: true
48+
SplitEmptyRecord: true
49+
SplitEmptyNamespace: true
50+
BreakBeforeBinaryOperators: None
51+
BreakBeforeConceptDeclarations: true
52+
BreakBeforeBraces: Attach
53+
BreakBeforeInheritanceComma: false
54+
BreakInheritanceList: BeforeColon
55+
BreakBeforeTernaryOperators: true
56+
BreakConstructorInitializersBeforeComma: false
57+
BreakConstructorInitializers: BeforeColon
58+
BreakAfterJavaFieldAnnotations: false
59+
BreakStringLiterals: true
60+
ColumnLimit: 80
61+
CommentPragmas: '^ IWYU pragma:'
62+
QualifierAlignment: Leave
63+
CompactNamespaces: false
64+
ConstructorInitializerIndentWidth: 4
65+
ContinuationIndentWidth: 4
66+
Cpp11BracedListStyle: true
67+
DeriveLineEnding: true
68+
DerivePointerAlignment: false
69+
DisableFormat: false
70+
EmptyLineAfterAccessModifier: Never
71+
EmptyLineBeforeAccessModifier: LogicalBlock
72+
ExperimentalAutoDetectBinPacking: false
73+
PackConstructorInitializers: BinPack
74+
BasedOnStyle: ''
75+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
76+
AllowAllConstructorInitializersOnNextLine: true
77+
FixNamespaceComments: true
78+
ForEachMacros:
79+
- foreach
80+
- Q_FOREACH
81+
- BOOST_FOREACH
82+
IfMacros:
83+
- KJ_IF_MAYBE
84+
IncludeBlocks: Preserve
85+
IncludeCategories:
86+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
87+
Priority: 2
88+
SortPriority: 0
89+
CaseSensitive: false
90+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
91+
Priority: 3
92+
SortPriority: 0
93+
CaseSensitive: false
94+
- Regex: '.*'
95+
Priority: 1
96+
SortPriority: 0
97+
CaseSensitive: false
98+
IncludeIsMainRegex: '(Test)?$'
99+
IncludeIsMainSourceRegex: ''
100+
IndentAccessModifiers: false
101+
IndentCaseLabels: false
102+
IndentCaseBlocks: false
103+
IndentGotoLabels: true
104+
IndentPPDirectives: None
105+
IndentExternBlock: AfterExternBlock
106+
IndentRequires: false
107+
IndentWidth: 2
108+
IndentWrappedFunctionNames: false
109+
InsertTrailingCommas: None
110+
JavaScriptQuotes: Leave
111+
JavaScriptWrapImports: true
112+
KeepEmptyLinesAtTheStartOfBlocks: true
113+
LambdaBodyIndentation: Signature
114+
MacroBlockBegin: ''
115+
MacroBlockEnd: ''
116+
MaxEmptyLinesToKeep: 1
117+
NamespaceIndentation: None
118+
ObjCBinPackProtocolList: Auto
119+
ObjCBlockIndentWidth: 2
120+
ObjCBreakBeforeNestedBlockParam: true
121+
ObjCSpaceAfterProperty: false
122+
ObjCSpaceBeforeProtocolList: true
123+
PenaltyBreakAssignment: 2
124+
PenaltyBreakBeforeFirstCallParameter: 19
125+
PenaltyBreakComment: 300
126+
PenaltyBreakFirstLessLess: 120
127+
PenaltyBreakOpenParenthesis: 0
128+
PenaltyBreakString: 1000
129+
PenaltyBreakTemplateDeclaration: 10
130+
PenaltyExcessCharacter: 1000000
131+
PenaltyReturnTypeOnItsOwnLine: 60
132+
PenaltyIndentedWhitespace: 0
133+
PointerAlignment: Right
134+
PPIndentWidth: -1
135+
ReferenceAlignment: Pointer
136+
ReflowComments: true
137+
RemoveBracesLLVM: false
138+
SeparateDefinitionBlocks: Leave
139+
ShortNamespaceLines: 1
140+
SortIncludes: CaseSensitive
141+
SortJavaStaticImport: Before
142+
SortUsingDeclarations: true
143+
SpaceAfterCStyleCast: false
144+
SpaceAfterLogicalNot: false
145+
SpaceAfterTemplateKeyword: true
146+
SpaceBeforeAssignmentOperators: true
147+
SpaceBeforeCaseColon: false
148+
SpaceBeforeCpp11BracedList: false
149+
SpaceBeforeCtorInitializerColon: true
150+
SpaceBeforeInheritanceColon: true
151+
SpaceBeforeParens: ControlStatements
152+
SpaceBeforeParensOptions:
153+
AfterControlStatements: true
154+
AfterForeachMacros: true
155+
AfterFunctionDefinitionName: false
156+
AfterFunctionDeclarationName: false
157+
AfterIfMacros: true
158+
AfterOverloadedOperator: false
159+
BeforeNonEmptyParentheses: false
160+
SpaceAroundPointerQualifiers: Default
161+
SpaceBeforeRangeBasedForLoopColon: true
162+
SpaceInEmptyBlock: false
163+
SpaceInEmptyParentheses: false
164+
SpacesBeforeTrailingComments: 1
165+
SpacesInAngles: Never
166+
SpacesInConditionalStatement: false
167+
SpacesInContainerLiterals: true
168+
SpacesInCStyleCastParentheses: false
169+
SpacesInLineCommentPrefix:
170+
Minimum: 1
171+
Maximum: -1
172+
SpacesInParentheses: false
173+
SpacesInSquareBrackets: false
174+
SpaceBeforeSquareBrackets: false
175+
BitFieldColonSpacing: Both
176+
Standard: Latest
177+
StatementAttributeLikeMacros:
178+
- Q_EMIT
179+
StatementMacros:
180+
- Q_UNUSED
181+
- QT_REQUIRE_VERSION
182+
TabWidth: 8
183+
UseCRLF: false
184+
UseTab: Never
185+
WhitespaceSensitiveMacros:
186+
- STRINGIZE
187+
- PP_STRINGIZE
188+
- BOOST_PP_STRINGIZE
189+
- NS_SWIFT_NAME
190+
- CF_SWIFT_NAME
191+
...
192+

0 commit comments

Comments
 (0)