Skip to content
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
60 changes: 49 additions & 11 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1
with:
bundler-cache: false
- run: bundle install
bundler-cache: true

- name: Get GitHub OIDC token
id: github-oidc
Expand All @@ -49,10 +48,12 @@ jobs:

lint:
timeout-minutes: 10
name: lint
name: lint (rubocop)
permissions:
contents: read
runs-on: ${{ inputs.runner }}
env:
RUBOCOP_CACHE_ROOT: ${{ github.workspace }}/.cache/rubocop
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
Expand All @@ -61,10 +62,46 @@ jobs:
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1
with:
ruby-version: '4.0'
bundler-cache: false
- run: bundle install
- name: Run lints
run: ./scripts/lint
bundler-cache: true
- name: Restore RuboCop cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ env.RUBOCOP_CACHE_ROOT }}
key: >-
rubocop-${{ runner.os }}-ruby-4.0-${{ hashFiles('Gemfile.lock', '.rubocop.yml') }}-${{ github.sha }}
restore-keys: |
rubocop-${{ runner.os }}-ruby-4.0-${{ hashFiles('Gemfile.lock', '.rubocop.yml') }}-
- name: Run RuboCop
run: bundle exec rake lint:rubocop

typecheck:
timeout-minutes: 10
name: typecheck (${{ matrix.format }})
permissions:
contents: read
runs-on: ${{ inputs.runner }}
env:
# Steep defaults to two workers in CI; eight is the measured balance for this runner.
STEEP_JOBS: 8
strategy:
fail-fast: false
matrix:
include:
- format: rbi
task: typecheck:sorbet
- format: rbs
task: typecheck:steep
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1
with:
ruby-version: '4.0'
bundler-cache: true
- name: Typecheck ${{ matrix.format }} files
run: bundle exec rake ${{ matrix.task }}

package:
timeout-minutes: 10
Expand All @@ -80,8 +117,7 @@ jobs:
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1
with:
ruby-version: '4.0'
bundler-cache: false
- run: bundle install
bundler-cache: true
- name: Build gem
run: bundle exec rake build:gem

Expand All @@ -103,8 +139,7 @@ jobs:
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- run: bundle install
bundler-cache: true
- name: Run tests
run: ./scripts/test

Expand All @@ -115,6 +150,7 @@ jobs:
needs:
- stainless-artifact
- lint
- typecheck
- package
- test-ruby
if: ${{ always() }}
Expand All @@ -125,10 +161,12 @@ jobs:
env:
ARTIFACT_RESULT: ${{ needs.stainless-artifact.result }}
LINT_RESULT: ${{ needs.lint.result }}
TYPECHECK_RESULT: ${{ needs.typecheck.result }}
PACKAGE_RESULT: ${{ needs.package.result }}
TEST_RESULT: ${{ needs.test-ruby.result }}
run: |
test "$ARTIFACT_RESULT" = "success" || test "$ARTIFACT_RESULT" = "skipped"
test "$LINT_RESULT" = "success"
test "$TYPECHECK_RESULT" = "success"
test "$PACKAGE_RESULT" = "success"
test "$TEST_RESULT" = "success"
21 changes: 11 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ filtered = ->(ext, dirs) do
end

desc("Lint `*.rb(i)`")
multitask(:"lint:rubocop") do
find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0]

rubocop = %w[rubocop]
rubocop += %w[--format github] if ENV.key?("CI")
RuboCop::RakeTask.new(:"lint:rubocop") do |task|
task.patterns = FileList[
"./{lib,test,rbi,examples}/**/*.rb",
"./{lib,test,rbi,examples}/**/*.rbi",
]
task.formatters = %w[github] if ENV.key?("CI")

# some lines cannot be shortened
rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength]

lint = xargs + rubocop
sh("#{find.shelljoin} | #{lint.shelljoin}")
task.options = %w[--parallel --except Lint/RedundantCopDisableDirective,Layout/LineLength]
end

norm_lines = %w[tr -- \n \0].shelljoin
Expand Down Expand Up @@ -133,7 +131,10 @@ multitask(format: [:"format:rb", :"format:rbi", :"format:rbs"])

desc("Typecheck `*.rbs`")
multitask(:"typecheck:steep") do
sh(*%w[steep check])
steep = %w[steep check]
steep += ["--jobs", ENV.fetch("STEEP_JOBS")] if ENV.key?("STEEP_JOBS")
steep += %w[--format=github] if ENV.key?("CI")
sh(*steep)
end

directory(examples)
Expand Down
2 changes: 1 addition & 1 deletion scripts/detect-breaking-changes
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ done

# Instead of running the tests, use the linter to check if an
# older test is no longer compatible with the latest SDK.
./scripts/lint
bundle exec rake lint
9 changes: 0 additions & 9 deletions scripts/lint

This file was deleted.