Skip to content

Commit 76367b2

Browse files
authored
Add ci workflow (#4)
* Add ci workflow * Add lint and format
1 parent f4a4ffb commit 76367b2

File tree

14 files changed

+272
-178
lines changed

14 files changed

+272
-178
lines changed

.clang-format

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
---
2+
Language: Cpp
23
BasedOnStyle: Google
3-
AccessModifierOffset: '-4'
4+
AccessModifierOffset: -4
45
AlignEscapedNewlines: Left
5-
AlignTrailingComments: 'false'
6-
AllowAllArgumentsOnNextLine: 'false'
7-
AllowShortBlocksOnASingleLine: 'false'
6+
AlignTrailingComments: true
7+
AlignAfterOpenBracket: true
8+
AllowAllArgumentsOnNextLine: true
9+
AllowShortBlocksOnASingleLine: false
810
AllowShortFunctionsOnASingleLine: Empty
911
AllowShortIfStatementsOnASingleLine: Never
1012
AllowShortLambdasOnASingleLine: Empty
11-
AlwaysBreakTemplateDeclarations: 'Yes'
12-
BinPackArguments: 'true'
13-
BinPackParameters: 'false'
13+
AlwaysBreakTemplateDeclarations: "Yes"
14+
AlignArrayOfStructures: Left
15+
BinPackArguments: true
16+
BinPackParameters: false
1417
BraceWrapping:
15-
AfterEnum: 'false'
16-
BeforeCatch: 'true'
17-
BeforeElse: 'true'
18-
BeforeLambdaBody: 'false'
19-
BeforeWhile: 'false'
18+
AfterEnum: false
19+
BeforeCatch: true
20+
BeforeElse: true
21+
BeforeLambdaBody: false
22+
BeforeWhile: false
2023
BreakBeforeBinaryOperators: NonAssignment
2124
BreakBeforeBraces: Custom
22-
BreakBeforeTernaryOperators: 'false'
25+
BreakBeforeTernaryOperators: false
2326
BreakConstructorInitializers: BeforeColon
2427
BreakInheritanceList: BeforeColon
25-
BreakStringLiterals: 'false'
26-
ColumnLimit: '80'
27-
DerivePointerAlignment: 'false'
28+
BreakStringLiterals: false
29+
ColumnLimit: 0
30+
DerivePointerAlignment: false
2831
#EmptyLineAfterAccessModifier: Leave
2932
#EmptyLineBeforeAccessModifier: LogicalBlock
30-
ExperimentalAutoDetectBinPacking: 'true'
31-
FixNamespaceComments: 'false'
32-
IndentCaseLabels: 'true'
33-
IndentWidth: '4'
34-
KeepEmptyLinesAtTheStartOfBlocks: 'true'
35-
Language: Cpp
36-
MaxEmptyLinesToKeep: '10'
33+
ExperimentalAutoDetectBinPacking: true
34+
FixNamespaceComments: false
35+
IndentCaseLabels: true
36+
IndentWidth: 4
37+
KeepEmptyLinesAtTheStartOfBlocks: true
38+
MaxEmptyLinesToKeep: 10
3739
NamespaceIndentation: All
38-
PenaltyBreakComment: '20'
39-
PenaltyExcessCharacter: '5'
40+
PenaltyBreakComment: 20
41+
PenaltyExcessCharacter: 5
4042
PointerAlignment: Middle
41-
SortUsingDeclarations: 'false'
42-
SpaceAfterTemplateKeyword: 'false'
43-
SpaceBeforeCpp11BracedList: 'true'
44-
SpacesBeforeTrailingComments: '1'
43+
SortUsingDeclarations: false
44+
SpaceAfterTemplateKeyword: false
45+
SpaceBeforeCpp11BracedList: true
46+
SpacesBeforeTrailingComments: 1
4547
UseTab: Never
46-
47-
...

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Lint & Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
14+
jobs:
15+
# test:
16+
# runs-on: ubuntu-latest
17+
18+
# steps:
19+
# - uses: actions/checkout@v4
20+
21+
# - name: Install dependencies
22+
# run: sudo apt-get install -y build-essential gcc-multilib g++-multilib
23+
24+
# - name: Install gcovr
25+
# run: pip install gcovr
26+
27+
# - name: Setup project
28+
# run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug
29+
30+
# - name: Build
31+
# run: cmake --build ${BUILD_DIR}
32+
33+
# # - name: Test
34+
# # working-directory: build
35+
# # run: ctest -V
36+
37+
# - name: Test with Coverage
38+
# working-directory: build
39+
# run: cmake --build ${BUILD_DIR} --target os_test_coverage
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
44+
strategy:
45+
matrix:
46+
folder:
47+
- src
48+
- examples
49+
- tests
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Lint ${{ matrix.folder }}
55+
uses: jidicula/clang-format-action@v4.14.0
56+
with:
57+
clang-format-version: "20"
58+
check-path: ${{ matrix.folder }}
59+
60+
increment_version:
61+
name: Increment Version
62+
uses: automas-dev/reusable-workflows/.github/workflows/increment_version.yml@main
63+
if: github.ref == 'refs/heads/main'
64+
secrets: inherit
65+
66+
needs:
67+
# - test
68+
- lint
69+
70+
permissions:
71+
contents: write

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ build:
2222
install:
2323
cmake --install ${PWD}/build --config ${CONFIG}
2424

25-
.PHONY: config build install
25+
lint:
26+
@find src include examples tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format --dry-run --Werror --sort-includes
27+
28+
format:
29+
@find src include examples tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format -i --Werror --sort-includes
30+
31+
.PHONY: config build install lint format

examples/01_triangle/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ int main() {
111111

112112
const float vertices[] = {
113113
-0.5f, -0.5f, 0.0f, // Bottom Left
114-
0.5f, -0.5f, 0.0f, // Bottom Right
115-
0.0f, 0.5f, 0.0f // Top Center
114+
0.5f, -0.5f, 0.0f, // Bottom Right
115+
0.0f, 0.5f, 0.0f // Top Center
116116
};
117117

118118
const float colors[] = {
119119
1.0, 0.0, 0.0, // Bottom Left
120120
0.0, 1.0, 0.0, // Bottom Right
121-
0.0, 0.0, 1.0 // Top Center
121+
0.0, 0.0, 1.0 // Top Center
122122
};
123123

124124
const unsigned int indices[] = {
125125
0, 1, 2, // First Triangle
126126
};
127127

128-
Buffer::Attribute a0 (0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
129-
Buffer::Attribute a1 (1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
128+
Buffer::Attribute a0(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
129+
Buffer::Attribute a1(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
130130

131131
BufferArray array(vector<vector<Buffer::Attribute>> {{a0}, {a1}});
132132
array.bind();

examples/02_camera/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ int main() {
105105

106106
const float vertices[] = {
107107
-0.5f, -0.5f, 0.0f, // Bottom Left
108-
0.5f, -0.5f, 0.0f, // Bottom Right
109-
0.0f, 0.5f, 0.0f, // Top Center
108+
0.5f, -0.5f, 0.0f, // Bottom Right
109+
0.0f, 0.5f, 0.0f, // Top Center
110110

111-
0.0f, -0.5f, 0.0f, //
112-
1.0f, -0.5f, 0.0f, //
113-
1.0f, -0.5f, 1.0f, //
111+
0.0f, -0.5f, 0.0f, //
112+
1.0f, -0.5f, 0.0f, //
113+
1.0f, -0.5f, 1.0f, //
114114

115-
0.5f, 0.0f, 0.0f, //
116-
0.5f, 1.0f, 0.0f, //
117-
0.5f, 1.0f, 1.0f, //
115+
0.5f, 0.0f, 0.0f, //
116+
0.5f, 1.0f, 0.0f, //
117+
0.5f, 1.0f, 1.0f, //
118118
};
119119

120120
const float colors[] = {
@@ -131,8 +131,8 @@ int main() {
131131
0.0, 0.0, 1.0, // Top Center
132132
};
133133

134-
Buffer::Attribute a0 (0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
135-
Buffer::Attribute a1 (1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
134+
Buffer::Attribute a0(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
135+
Buffer::Attribute a1(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
136136

137137
BufferArray array(vector<vector<Buffer::Attribute>> {{a0}, {a1}});
138138
array.bind();

examples/03_grid/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ int main() {
108108

109109
const float vertices[] = {
110110
-0.5f, -0.5f, 0.0f, // Bottom Left
111-
0.5f, -0.5f, 0.0f, // Bottom Right
112-
0.0f, 0.5f, 0.0f, // Top Center
111+
0.5f, -0.5f, 0.0f, // Bottom Right
112+
0.0f, 0.5f, 0.0f, // Top Center
113113

114-
0.0f, -0.5f, 0.0f, //
115-
1.0f, -0.5f, 0.0f, //
116-
1.0f, -0.5f, 1.0f, //
114+
0.0f, -0.5f, 0.0f, //
115+
1.0f, -0.5f, 0.0f, //
116+
1.0f, -0.5f, 1.0f, //
117117

118-
0.5f, 0.0f, 0.0f, //
119-
0.5f, 1.0f, 0.0f, //
120-
0.5f, 1.0f, 1.0f, //
118+
0.5f, 0.0f, 0.0f, //
119+
0.5f, 1.0f, 0.0f, //
120+
0.5f, 1.0f, 1.0f, //
121121
};
122122

123123
const float colors[] = {
@@ -134,8 +134,8 @@ int main() {
134134
0.0, 0.0, 1.0, // Top Center
135135
};
136136

137-
Buffer::Attribute a0 (0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
138-
Buffer::Attribute a1 (1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
137+
Buffer::Attribute a0(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
138+
Buffer::Attribute a1(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
139139

140140
BufferArray array(vector<vector<Buffer::Attribute>> {{a0}, {a1}});
141141
array.bind();

examples/04_framebuffer/main.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ int main() {
111111

112112
const float vertices[] = {
113113
-0.5f, -0.5f, 0.0f, // Bottom Left
114-
0.5f, -0.5f, 0.0f, // Bottom Right
115-
0.0f, 0.5f, 0.0f // Top Center
114+
0.5f, -0.5f, 0.0f, // Bottom Right
115+
0.0f, 0.5f, 0.0f // Top Center
116116
};
117117

118118
const float texCoords[] = {
119119
-0.5f, -0.5f, // Bottom Left
120-
0.5f, -0.5f, // Bottom Right
121-
0.0f, 0.5f, // Top Center
120+
0.5f, -0.5f, // Bottom Right
121+
0.0f, 0.5f, // Top Center
122122
};
123123

124124
const unsigned int indices[] = {
125125
0, 1, 2, // First Triangle
126126
};
127127

128-
Buffer::Attribute a0 (0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
129-
Buffer::Attribute a1 (1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float));
128+
Buffer::Attribute a0(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float));
129+
Buffer::Attribute a1(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float));
130130

131131
BufferArray array(vector<vector<Buffer::Attribute>> {{a0}, {a1}});
132132
array.bind();
@@ -135,7 +135,7 @@ int main() {
135135
array.bufferElements(sizeof(indices), indices);
136136
array.unbind();
137137

138-
Quad quad ({0, 0}, {1, 1});
138+
Quad quad({0, 0}, {1, 1});
139139

140140
// Needed because FrameBuffer is storing size for future blit to default
141141
FrameBuffer::getDefault().resize(uvec2(width, height));
@@ -146,14 +146,14 @@ int main() {
146146
fbo.attach(rbo, GL_DEPTH_STENCIL_ATTACHMENT);
147147

148148
Texture::Ptr tex2 = make_shared<Texture>(uvec2(width, height),
149-
Texture::RGBA,
150-
Texture::RGBA,
151-
GL_FLOAT,
152-
0,
153-
Texture::Linear,
154-
Texture::Linear,
155-
Texture::Clamp,
156-
false);
149+
Texture::RGBA,
150+
Texture::RGBA,
151+
GL_FLOAT,
152+
0,
153+
Texture::Linear,
154+
Texture::Linear,
155+
Texture::Clamp,
156+
false);
157157
fbo.attach(tex2, GL_COLOR_ATTACHMENT0);
158158

159159
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {

0 commit comments

Comments
 (0)