Skip to content

Commit de4961d

Browse files
committed
Lock clang-format dep and lint C code in CI
1 parent a43312c commit de4961d

File tree

5 files changed

+104
-5
lines changed

5 files changed

+104
-5
lines changed

.clang-format-ignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git
2+
build
3+
emsdk
4+
node_modules
5+
target
6+
vendor

.github/workflows/ci.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ jobs:
159159
- name: Lint and check formatting with Rubocop
160160
run: bundle exec rubocop --format github
161161

162+
c:
163+
name: Lint and format C
164+
runs-on: ubuntu-latest
165+
steps:
166+
- name: Checkout repository
167+
uses: actions/checkout@v4.1.1
168+
169+
- name: Setup Node.js runtime
170+
uses: actions/setup-node@v4.0.1
171+
with:
172+
node-version: "lts/*"
173+
174+
- name: Install toolchain
175+
run: npm ci
176+
177+
- name: Lint and check formatting with clang-format
178+
run: npm run fmt:c -- --check
179+
162180
text:
163181
name: Lint and format text
164182
runs-on: ubuntu-latest

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ namespace :format do
4848

4949
desc 'Format text, YAML, and Markdown sources with prettier'
5050
task :text do
51-
sh 'npx prettier --write "**/*"'
51+
sh 'npm run fmt'
5252
end
5353

5454
desc 'Format .c and .h sources with clang-format'
5555
task :c do
56-
sh 'npx --yes github:artichoke/clang-format'
56+
sh 'npm run fmt:c'
5757
end
5858
end
5959

@@ -68,12 +68,12 @@ namespace :fmt do
6868

6969
desc 'Format text, YAML, and Markdown sources with prettier'
7070
task :text do
71-
sh 'npx prettier --write "**/*"'
71+
sh 'npm run fmt'
7272
end
7373

7474
desc 'Format .c and .h sources with clang-format'
7575
task :c do
76-
sh 'npx --yes github:artichoke/clang-format'
76+
sh 'npm run fmt:c'
7777
end
7878
end
7979

package-lock.json

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
"homepage": "https://www.artichokeruby.org",
1515
"bugs": "https://github.com/artichoke/sysdir-rs/issues",
1616
"devDependencies": {
17+
"@artichokeruby/clang-format": "github:artichoke/clang-format#semver:^0.16.0",
1718
"prettier": "^3.2.5"
1819
},
1920
"scripts": {
20-
"fmt": "prettier --write \"**/*\""
21+
"fmt": "prettier --write \"**/*\"",
22+
"fmt:c": "clang-format"
2123
}
2224
}

0 commit comments

Comments
 (0)