Skip to content

CI

CI #728

Workflow file for this run

# This file is synced from hanakai-rb/repo-sync
name: CI
run-name: ${{ github.ref_type == 'tag' && format('Release {0}', github.ref_name) || 'CI' }}
on:
push:
branches: ["main", "release-*", "ci/*"]
tags: ["v*"]
pull_request:
branches: ["main", "release-*"]
schedule:
- cron: "30 4 * * *"
jobs:
tests:
name: Tests (Ruby ${{ matrix.ruby }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.optional || false }}
strategy:
fail-fast: false
matrix:
ruby:
- "4.0"
- "3.4"
- "3.3"
- "3.2"
include:
- ruby: "4.0"
coverage: "true"
- ruby: "jruby"
optional: true
env:
COVERAGE: ${{ matrix.coverage }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install package dependencies
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run all tests
id: test
run: |
status=0
bundle exec rake || status=$?
if [ ${status} -ne 0 ] && [ "${{ matrix.optional }}" == "true" ]; then
echo "::warning::Optional matrix job failed."
echo "optional_fail=true" >> "${GITHUB_OUTPUT}"
echo "optional_fail_status=${status}" >> "${GITHUB_OUTPUT}"
exit 0 # Ignore error here to keep the green checkmark
fi
exit ${status}
- name: Create optional failure comment
if: ${{ matrix.optional && github.event.pull_request }}
uses: hanakai-rb/repo-sync/pr-comment-artifact@main
with:
name: ci-ruby-${{ matrix.ruby }}
pr-number: ${{ github.event.pull_request.number }}
comment-tag: ruby-${{ matrix.ruby }}-optional-failure
message: "ℹ️ Optional job failed: Ruby ${{ matrix.ruby }}"
mode: ${{ steps.test.outputs.optional_fail == 'true' && 'upsert' || 'delete' }}
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1
release:
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs: tests
steps:
- name: Trigger release workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.RELEASE_MACHINE_DISPATCH_TOKEN }}
script: |
const tag = context.ref.replace("refs/tags/", "");
const repo = context.repo.owner + "/" + context.repo.repo;
const tagMessage = await github.rest.git.getTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag_sha: context.sha
}).then(res => res.data.message).catch(() => "");
const announce = /(skip-announce|no-announce)/i.test(tagMessage) ? "false" : "true";
await github.rest.actions.createWorkflowDispatch({
owner: "hanakai-rb",
repo: "release-machine",
workflow_id: "release.yml",
ref: "main",
inputs: { repo, tag, announce }
});
const workflowUrl = "https://github.com/hanakai-rb/release-machine/actions/workflows/release.yml";
await core.summary
.addHeading("Release Triggered")
.addRaw(`Triggered release workflow for <code>${tag}</code>`)
.addLink("View release workflow", workflowUrl)
.write();