Skip to content

Commit

Permalink
Merge pull request #36 from artichoke/lopopolo/clang-format
Browse files Browse the repository at this point in the history
Lock clang-format dep and lint C code in CI
  • Loading branch information
lopopolo authored Feb 24, 2024
2 parents a43312c + de4961d commit baaf8ab
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
build
emsdk
node_modules
target
vendor
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,24 @@ jobs:
- name: Lint and check formatting with Rubocop
run: bundle exec rubocop --format github

c:
name: Lint and format C
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.1

- name: Setup Node.js runtime
uses: actions/setup-node@v4.0.1
with:
node-version: "lts/*"

- name: Install toolchain
run: npm ci

- name: Lint and check formatting with clang-format
run: npm run fmt:c -- --check

text:
name: Lint and format text
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ namespace :format do

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

desc 'Format .c and .h sources with clang-format'
task :c do
sh 'npx --yes github:artichoke/clang-format'
sh 'npm run fmt:c'
end
end

Expand All @@ -68,12 +68,12 @@ namespace :fmt do

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

desc 'Format .c and .h sources with clang-format'
task :c do
sh 'npx --yes github:artichoke/clang-format'
sh 'npm run fmt:c'
end
end

Expand Down
73 changes: 73 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"homepage": "https://www.artichokeruby.org",
"bugs": "https://github.com/artichoke/sysdir-rs/issues",
"devDependencies": {
"@artichokeruby/clang-format": "github:artichoke/clang-format#semver:^0.16.0",
"prettier": "^3.2.5"
},
"scripts": {
"fmt": "prettier --write \"**/*\""
"fmt": "prettier --write \"**/*\"",
"fmt:c": "clang-format"
}
}

0 comments on commit baaf8ab

Please sign in to comment.