Skip to content

Format C code with Artistic Style #586

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

Merged
merged 1 commit into from
Jun 4, 2025
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
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ jobs:
run: |
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"

standardrb:
name: standardrb
formatting:
name: Code formatting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -569,3 +569,12 @@ jobs:
- name: Check standardrb
shell: bash
run: bundle exec standardrb

- name: Check artistic style
uses: per1234/artistic-style-action@v1
with:
options-file-path: "astyle.conf"
target-paths: "./ext/"
name-patterns: |
- '*.c'
- '*.h'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ $ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure

### Code formatting

We are using `standardrb` to format our code. Just run `bundle exec standardrb --fix` to format all Ruby files.
We are using `standardrb` to format the Ruby code and Artistic Style for the C code. Run `bundle exec rake format` to format both types in one operation. Artistic Style needs to be manually installed through your package manager (e.g. `apt install -y astyle`).

### Compiling Gems for Windows and Linux

Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ end

task build: [:clean, :compile]
task default: [:build, :test]

task :format do
system("bundle exec standardrb --fix")
system('astyle --options=astyle.conf "./ext/*.c" "./ext/*.h"')
end
8 changes: 8 additions & 0 deletions astyle.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--style=1tbs
--break-blocks
--indent-preproc-block
--indent-preproc-cond
--indent=spaces=2
--indent-switches
--recursive
--suffix=none
Loading