Skip to content

Bump actions/download-artifact from 4 to 7 #253

Bump actions/download-artifact from 4 to 7

Bump actions/download-artifact from 4 to 7 #253

Workflow file for this run

name: CI
on:
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build_gem:
name: build_on_ruby_${{ matrix.ruby_version }}_and_rails_${{ matrix.rails_version }}_${{ matrix.bundler_option.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby_version: ['3.2', '3.3', '3.4', '4.0']
rails_version: ['7.2', '8.0', '8.1']
bundler_option:
- name: with_integrations
with: integrations
without: ""
- name: without_integrations
with: ""
without: integrations
steps:
- uses: actions/checkout@v6
- name: Set up Ruby ${{ matrix.ruby_version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: false
- name: Install Bundler 2.x
run: gem install bundler -v "~> 2.0"
- name: Configure Bundler options
env:
BUNDLE_WITH: ${{ matrix.bundler_option.with }}
BUNDLE_WITHOUT: ${{ matrix.bundler_option.without }}
run: |
if [ -n "${BUNDLE_WITH}" ]; then
bundle config set --local with "${BUNDLE_WITH}"
else
bundle config unset --local with || true
fi
if [ -n "${BUNDLE_WITHOUT}" ]; then
bundle config set --local without "${BUNDLE_WITHOUT}"
else
bundle config unset --local without || true
fi
- name: Use Rails ${{ matrix.rails_version }} appraisal
run: cp gemfiles/rails_${{ matrix.rails_version }}.gemfile Gemfile
- name: Update ActiveSupport
run: bundle update activesupport
- name: Execute RSpec
env:
SIMPLECOV_COMMAND_NAME: build_gem_ruby_${{ matrix.ruby_version }}_rails_${{ matrix.rails_version }}_${{ matrix.bundler_option.name }}
run: |
bundle exec rspec --format documentation \
--color \
--format RspecJunitFormatter
- name: Rake build
run: bundle exec rake build
- name: Prepare coverage artifact
if: ${{ always() && hashFiles('coverage/.resultset.json') != '' }}
run: cp coverage/.resultset.json coverage/resultset.json
- name: Upload coverage artifact
if: ${{ always() && hashFiles('coverage/resultset.json') != '' }}
uses: actions/upload-artifact@v6
with:
name: simplecov-resultset-ruby_${{ matrix.ruby_version }}-rails_${{ matrix.rails_version }}-${{ matrix.bundler_option.name }}
path: coverage/resultset.json
verify_generator:
name: verify_generator_on_ruby_${{ matrix.ruby_version }}_and_rails_${{ matrix.rails_version }}
runs-on: ubuntu-latest
env:
BUNDLE_PATH: vendor/bundle
strategy:
fail-fast: false
matrix:
ruby_version: ['3.2', '3.3', '3.4', '4.0']
rails_version: ['7.2', '8.0', '8.1']
defaults:
run:
working-directory: rails_app/rails_${{ matrix.rails_version }}
steps:
- uses: actions/checkout@v6
- name: Set up Ruby ${{ matrix.ruby_version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: false
- name: Install Bundler 2.x
run: gem install bundler -v "~> 2.0"
- name: Bundle install
run: bundle install
- name: Add compatibility symlink for libffi
run: |
if [ ! -e /usr/lib/x86_64-linux-gnu/libffi.so.6 ]; then
latest_libffi="$(find /usr/lib/x86_64-linux-gnu -maxdepth 1 -type f -name 'libffi.so.*.*.*' | sort -V | tail -n 1)"
if [ -n "${latest_libffi}" ]; then
sudo ln -s "${latest_libffi}" /usr/lib/x86_64-linux-gnu/libffi.so.6
fi
fi
- name: Generate new API client files
run: |
bin/rails g api_client path/to/resource \
get:path/to/resource \
post:path/to/resource \
--endpoint https://example.com/myapi
- name: Check generated API client files
run: |
test -e "app/api_clients/application_api_client.rb" && \
test -e "app/api_clients/path/to/resource_api_client.rb" && \
test -e "spec/api_clients/path/to/resource_api_client_spec.rb"
- name: Run rspec with the generated spec file
run: bundle exec rspec -f d spec/api_clients/path/to
integration_api:
name: integration_api_via_docker_compose
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build and start my_api
run: docker compose up -d --build my_api
- name: Run integration specs against my_api
env:
MY_API_ENDPOINT: http://my_api:3000
SIMPLECOV_COMMAND_NAME: integration_api
run: |
docker compose run --rm test bash -lc "
bundle config set --local with integrations &&
bundle install &&
bundle exec rspec spec/integrations/api_clients
"
- name: Fix coverage directory ownership
if: ${{ always() && hashFiles('coverage/.resultset.json') != '' }}
run: sudo chown -R "$(id -u):$(id -g)" coverage
- name: Prepare coverage artifact
if: ${{ always() && hashFiles('coverage/.resultset.json') != '' }}
run: cp coverage/.resultset.json coverage/resultset.json
- name: Upload coverage artifact
if: ${{ always() && hashFiles('coverage/resultset.json') != '' }}
uses: actions/upload-artifact@v6
with:
name: simplecov-resultset-integration_api
path: coverage/resultset.json
- name: Show my_api logs when failed
if: ${{ failure() }}
run: docker compose logs my_api
- name: Shutdown compose services
if: ${{ always() }}
run: docker compose down --volumes --remove-orphans
my_api_request_specs:
name: my_api_request_specs_via_docker_compose
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build and start my_api
run: docker compose up -d --build my_api
- name: Run my_api request specs
env:
SIMPLECOV_COMMAND_NAME: my_api_request_specs
run: docker compose run --rm my_api bundle exec rspec spec/requests
- name: Fix my_api coverage directory ownership
if: ${{ always() && hashFiles('my_api/coverage/.resultset.json') != '' }}
run: sudo chown -R "$(id -u):$(id -g)" my_api/coverage
- name: Prepare coverage artifact
if: ${{ always() && hashFiles('my_api/coverage/.resultset.json') != '' }}
run: cp my_api/coverage/.resultset.json my_api/coverage/resultset.json
- name: Upload coverage artifact
if: ${{ always() && hashFiles('my_api/coverage/resultset.json') != '' }}
uses: actions/upload-artifact@v6
with:
name: simplecov-resultset-my_api_request_specs
path: my_api/coverage/resultset.json
- name: Show my_api logs when failed
if: ${{ failure() }}
run: docker compose logs my_api
- name: Shutdown compose services
if: ${{ always() }}
run: docker compose down --volumes --remove-orphans
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: false
- name: Install Bundler 2.x
run: gem install bundler -v "~> 2.0"
- name: Bundle install
run: bundle install
- name: Run RuboCop
run: bundle exec rubocop
yardoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: false
- name: Install Bundler 2.x
run: gem install bundler -v "~> 2.0"
- name: Bundle install
run: bundle install
- name: Generate YARDoc
run: bundle exec yardoc -o ./yardoc
- name: Store YARDoc artifact
uses: actions/upload-artifact@v6
with:
name: yardoc
path: ./yardoc
upload_coverage:
name: upload-coverage
environment: coverage
# This job runs on pull_request as well.
# On fork-based pull requests, secrets are unavailable, so the Qlty upload
# step is skipped by its token guard. On same-repository pull requests,
# QLTY_COVERAGE_TOKEN is available and upload can run.
needs:
- build_gem
- verify_generator
- integration_api
- my_api_request_specs
runs-on: ubuntu-latest
env:
QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_COVERAGE_TOKEN }}
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: false
- name: Install Bundler 2.x
run: gem install bundler -v "~> 2.0"
- name: Bundle install
run: bundle install
- name: Download coverage artifacts
uses: actions/download-artifact@v7
with:
pattern: simplecov-resultset-*
path: tmp/simplecov-results
- name: Collate SimpleCov coverage
run: |
bundle exec ruby -e "
require 'simplecov'
require 'simplecov_json_formatter'
resultset_files = Dir['tmp/simplecov-results/**/resultset.json'].sort
abort('No SimpleCov resultset files found') if resultset_files.empty?
SimpleCov.collate(resultset_files) do
formatter SimpleCov::Formatter::JSONFormatter
coverage_dir('coverage')
end
"
- name: Upload merged coverage artifact
if: ${{ hashFiles('coverage/coverage.json') != '' }}
uses: actions/upload-artifact@v6
with:
name: merged-simplecov-coverage
path: coverage/coverage.json
- name: Upload coverage to Qlty
if: ${{ env.QLTY_COVERAGE_TOKEN != '' && hashFiles('coverage/coverage.json') != '' }}
uses: qltysh/qlty-action/coverage@v2
with:
token: ${{ env.QLTY_COVERAGE_TOKEN }}
files: coverage/coverage.json
- name: Notify when Qlty token is missing
if: ${{ env.QLTY_COVERAGE_TOKEN == '' }}
run: |
echo "QLTY_COVERAGE_TOKEN is not set. Skipping coverage upload."