Skip to content
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

Lock clang-format dep and lint C code in CI #36

Merged
merged 1 commit into from
Feb 24, 2024
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
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"
}
}