Skip to content

Ensure "complete" CI steps always run #4506

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

Closed
wants to merge 3 commits into from
Closed
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
20 changes: 20 additions & 0 deletions .github/actions/complete/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Ensure complete'

description: 'Ensure complete for GitHub Actions'

inputs:
needs:
description: 'JSON of needs context from workflow'
required: true

runs:
using: "composite"
steps:
- name: Check if any needs jobs failed or were skipped
shell: bash
env:
NEEDS: ${{ inputs.needs }}
run: ruby ${GITHUB_WORKSPACE}/.github/scripts/check_completion.rb "$NEEDS"
- name: Done
shell: bash
run: echo "DONE!"
36 changes: 36 additions & 0 deletions .github/scripts/check_completion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env ruby

require 'json'

begin
# Check if an argument was provided
if ARGV.empty?
puts 'Error: No JSON input provided. Please provide needs JSON as first argument.'
exit 1
end

# Parse from command line argument
jobs = JSON.parse(ARGV[0])

puts jobs

all_success = true

jobs.each do |name, data|
if data['result'] != 'success'
puts "Job #{name} failed or was skipped (status: #{data['result']})"
all_success = false
end
end

if all_success
puts 'All needed jobs completed successfully'
exit 0
else
puts 'Some required jobs did not complete successfully'
exit 1
end
rescue JSON::ParserError => e
puts "Error parsing needs JSON: #{e.message}"
exit 1
end
2 changes: 1 addition & 1 deletion .github/workflows/_unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Unit Test Template

on: # yamllint disable-line rule:truthy
on:
workflow_call:
inputs:
# TODO: Provides concurrency control for each ruby version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add-milestone-to-pull-requests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Add milestone to merged pull requests

on: # yamllint disable-line rule:truthy
on:
pull_request:
types: [closed]

Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build-gem.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build gem

on: # yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
push:
Expand Down Expand Up @@ -134,7 +134,13 @@ jobs:
complete:
name: Build Gem (complete)
runs-on: ubuntu-24.04
if: ${{ !cancelled() }}
needs:
- test
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion .github/workflows/cache-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

name: Cleanup caches by a branch

on: # yamllint disable-line rule:truthy
on:
pull_request:
types:
- closed
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Static Analysis

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -143,6 +143,8 @@ jobs:

complete:
name: Static Analysis (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- 'steep'
- 'rubocop'
Expand All @@ -151,6 +153,10 @@ jobs:
- 'zizmor'
- 'actionlint'
- 'yaml-lint'
runs-on: ubuntu-24.04
steps:
- run: echo "Done"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "CodeQL"

on: # yamllint disable-line rule:truthy
on:
push:
branches: [master, release]
pull_request:
Expand Down Expand Up @@ -53,7 +53,13 @@ jobs:
complete:
name: CodeQL (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- analyze
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion .github/workflows/ensure-changelog-entry.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check change log entry

on: # yamllint disable-line rule:truthy
on:
pull_request:
types: [opened, reopened, edited]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-supported-versions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Generate Supported Versions"

on: # yamllint disable-line rule:truthy
on:
workflow_dispatch:

concurrency:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/lock-dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Lock Dependencies
# TODO: Make this job mandatory
# TODO: Make this on workflow_dispatch

on: # yamllint disable-line rule:truthy
on:
pull_request:
branches:
- master
Expand Down Expand Up @@ -106,7 +106,13 @@ jobs:
complete:
name: Lock Dependencies (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- commit
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test Nix

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -64,7 +64,13 @@ jobs:
complete:
name: Nix (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- test
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/parametric-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Parametric Tests

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -75,7 +75,13 @@ jobs:
complete:
name: Parametric Tests (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- parametric
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish gem

# TODO: Implement a dry-run mode to verify the checks without publishing
on: workflow_dispatch # yamllint disable-line rule:truthy
on: workflow_dispatch

concurrency: "rubygems" # Only one publish job at a time

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Pull Request Labeler"

on: # yamllint disable-line rule:truthy
on:
- pull_request_target # zizmor: ignore[dangerous-triggers]

jobs:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: System Tests

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -508,7 +508,13 @@ jobs:
complete:
name: System Tests (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- test
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/test-macos.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test macOS

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -58,7 +58,13 @@ jobs:
complete:
name: Test macOS (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- test-macos
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/test-memory-leaks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test for memory leaks

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -48,8 +48,14 @@ jobs:
complete:
name: Test for memory leaks (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- test-memcheck
- test-asan
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/test-yjit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test YJIT

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -60,7 +60,13 @@ jobs:
complete:
name: Test YJIT (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- test-yjit
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Unit Tests

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- master
Expand Down Expand Up @@ -216,6 +216,7 @@ jobs:
complete:
name: Unit Tests (complete)
runs-on: ubuntu-24.04
if: ${{ always() }}
needs:
- ruby-34
- ruby-33
Expand All @@ -229,4 +230,9 @@ jobs:
- jruby-93
- jruby-92
steps:
- run: echo "DONE!"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: ./.github/actions/complete
with:
needs: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion .github/workflows/update-latest-dependency.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Update Latest Dependency"

on: # yamllint disable-line rule:truthy
on:
schedule:
- cron: '0 0 * * 0' # Every Sunday at midnight
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Deploy Yard documentation to Pages

on: # yamllint disable-line rule:truthy
on:
push:
branches: ["release"]

Expand Down
Loading
Loading