Skip to content

Commit

Permalink
Merge pull request #614 from sparklemotion/flavorjones-ci-and-dep-cle…
Browse files Browse the repository at this point in the history
…anup

dep: move style and docs deps into a separate group
  • Loading branch information
flavorjones authored Jan 30, 2025
2 parents 5092a75 + 03f57c1 commit ed1b96a
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 65 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:
branches:
- '*'

env:
BUNDLE_WITHOUT: "development"

jobs:
ruby_versions:
outputs:
Expand All @@ -31,6 +34,8 @@ jobs:
#
rubocop:
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: "" # we need rubocop, obviously
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -101,7 +106,7 @@ jobs:
steps:
- run: |
dnf group install -y "C Development Tools and Libraries"
dnf install -y ruby ruby-devel libyaml-devel
dnf install -y ruby ruby-devel
- uses: actions/checkout@v4
- run: bundle install
- run: bundle exec rake compile -- --disable-system-libraries
Expand All @@ -118,6 +123,7 @@ jobs:
usesh: true
copyback: false
prepare: pkg install -y ruby devel/ruby-gems pkgconf
envs: BUNDLE_WITHOUT
run: |
gem install bundler
bundle install --local || bundle install
Expand Down Expand Up @@ -294,10 +300,10 @@ jobs:
ruby: ${{ fromJSON(needs.ruby_versions.outputs.image_tag) }}
include:
# declare docker image for each platform
- { platform: aarch64-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base yaml-dev &&" }
- { platform: arm-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base yaml-dev &&" }
- { platform: x86-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base yaml-dev &&" }
- { platform: x86_64-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base yaml-dev &&" }
- { platform: aarch64-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base &&" }
- { platform: arm-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base &&" }
- { platform: x86-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base &&" }
- { platform: x86_64-linux-musl, docker_tag: "-alpine", bootstrap: "apk add build-base &&" }
# declare docker platform for each platform
- { platform: aarch64-linux-gnu, docker_platform: "--platform=linux/arm64" }
- { platform: aarch64-linux-musl, docker_platform: "--platform=linux/arm64" }
Expand Down Expand Up @@ -371,5 +377,5 @@ jobs:
with:
name: cruby-x86_64-linux-musl-gem
path: gems
- run: apk add build-base yaml-dev
- run: apk add build-base
- run: ./bin/test-gem-install ./gems
4 changes: 2 additions & 2 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: "3.3"
ruby-version: "3.4"
bundler: latest
bundler-cache: true
apt-get: sqlite3 # active record test suite uses the sqlite3 cli
Expand All @@ -37,7 +37,7 @@ jobs:
run: |
git clone --depth 1 --branch main https://github.com/rails/rails
cd rails
bundle install
bundle install --prefer-local
bundle remove sqlite3
bundle add sqlite3 --path=".."
- name: run tests
Expand Down
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ source "https://rubygems.org"

gemspec

group :development do
group :test do
gem "minitest", "5.25.4"

gem "ruby_memcheck", "3.0.1" if Gem::Platform.local.os == "linux"

gem "rake-compiler", "1.2.9"
gem "rake-compiler-dock", "1.9.1"
end

gem "ruby_memcheck", "3.0.1" if Gem::Platform.local.os == "linux"

group :development do
gem "rdoc", "6.11.0"

gem "rubocop", "1.59.0", require: false
Expand Down
1 change: 1 addition & 0 deletions bin/test-gem-build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test -e /etc/os-release && cat /etc/os-release

set -x

bundle config set without development
bundle install --local || bundle install
bundle exec rake set-version-to-timestamp

Expand Down
3 changes: 2 additions & 1 deletion bin/test-gem-install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# run as part of CI
#
if [[ $# -lt 1 ]] ; then
if [ $# -lt 1 ] ; then
echo "usage: $(basename $0) <gems_dir> [install_flags]"
exit 1
fi
Expand All @@ -24,6 +24,7 @@ cd $GEMS_DIR

cd ..

bundle config set without development
bundle install --local || bundle install

rm -rf lib ext # ensure we don't use the local files
Expand Down
111 changes: 58 additions & 53 deletions rakelib/format.rake
Original file line number Diff line number Diff line change
@@ -1,70 +1,75 @@
require "rake/clean"
require "rubocop/rake_task"

module AstyleHelper
class << self
def run(files)
assert
command = ["astyle", args, files].flatten.shelljoin
system(command)
end

def assert
require "mkmf"
find_executable0("astyle") || raise("Could not find command 'astyle'")
end
begin
require "rubocop/rake_task"

def args
[
# indentation
"--indent=spaces=4",
"--indent-switches",
module AstyleHelper
class << self
def run(files)
assert
command = ["astyle", args, files].flatten.shelljoin
system(command)
end

# brackets
"--style=1tbs",
"--keep-one-line-blocks",
def assert
require "mkmf"
find_executable0("astyle") || raise("Could not find command 'astyle'")
end

# where do we want spaces
"--unpad-paren",
"--pad-header",
"--pad-oper",
"--pad-comma",
def args
[
# indentation
"--indent=spaces=4",
"--indent-switches",

# "void *pointer" and not "void* pointer"
"--align-pointer=name",
# brackets
"--style=1tbs",
"--keep-one-line-blocks",

# function definitions and declarations
"--break-return-type",
"--attach-return-type-decl",
# where do we want spaces
"--unpad-paren",
"--pad-header",
"--pad-oper",
"--pad-comma",

# gotta set a limit somewhere
"--max-code-length=100",
# "void *pointer" and not "void* pointer"
"--align-pointer=name",

# be quiet about files that haven't changed
"--formatted",
"--verbose"
]
end
# function definitions and declarations
"--break-return-type",
"--attach-return-type-decl",

def c_files
SQLITE3_SPEC.files.grep(%r{ext/sqlite3/.*\.[ch]\Z})
# gotta set a limit somewhere
"--max-code-length=100",

# be quiet about files that haven't changed
"--formatted",
"--verbose"
]
end

def c_files
SQLITE3_SPEC.files.grep(%r{ext/sqlite3/.*\.[ch]\Z})
end
end
end
end

namespace "format" do
desc "Format C code"
task "c" do
puts "Running astyle on C files ..."
AstyleHelper.run(AstyleHelper.c_files)
end
namespace "format" do
desc "Format C code"
task "c" do
puts "Running astyle on C files ..."
AstyleHelper.run(AstyleHelper.c_files)
end

CLEAN.add(AstyleHelper.c_files.map { |f| "#{f}.orig" })
CLEAN.add(AstyleHelper.c_files.map { |f| "#{f}.orig" })

desc "Format Ruby code"
task "ruby" => "rubocop:autocorrect"
end
desc "Format Ruby code"
task "ruby" => "rubocop:autocorrect"
end

RuboCop::RakeTask.new
RuboCop::RakeTask.new

task "format" => ["format:c", "format:ruby"]
task "format" => ["format:c", "format:ruby"]
rescue LoadError => e
puts "NOTE: Rubocop is not available in this environment: #{e.message}"
end

0 comments on commit ed1b96a

Please sign in to comment.