Skip to content

Commit

Permalink
[GHA] Create reusable workflow (#2767)
Browse files Browse the repository at this point in the history
# Motivation

In the future, we want to share the workflow definition across multiple repos to avoid duplication.

# Modification

This PR extracts the current workflow definition into a reusable workflow and calls the reusable workflow from a new workflow that is triggered on PR events. The new reusable workflow starts off with a few simple inputs to enable/disable the three current jobs. By default all jobs are enabled.

# Result

First step into reusability of our workflow.
  • Loading branch information
FranzBusch authored Jul 5, 2024
1 parent 9730938 commit 9614996
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Pull Request

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
call-reusable-pull-request-workflow:
name: Checks
uses: ./.github/workflows/reusable_pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
name: Pull Request

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
workflow_call:
inputs:
enable_unit_tests:
type: boolean
description: "Boolean to enable the unit tests job. Defaults to true."
default: true
enable_api_breakage_check:
type: boolean
description: "Boolean to enable the API breakage check job. Defaults to true."
default: true
enable_docs_check:
type: boolean
description: "Boolean to enable the docs check job. Defaults to true."
default: true

## We are cancelling previously triggered workflow runs
concurrency:
Expand All @@ -12,6 +24,7 @@ concurrency:
jobs:
unit-tests:
name: Unit tests
if: ${{ inputs.enable_unit_tests }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -31,8 +44,9 @@ jobs:
- name: Run tests
run: swift test

api-breakage:
api-breakage-check:
name: API breakage check
if: ${{ inputs.enable_api_breakage_check }}
runs-on: ubuntu-latest
container:
image: swift:5.10-noble
Expand All @@ -51,6 +65,7 @@ jobs:

docs-check:
name: Documentation check
if: ${{ inputs.enable_docs_check }}
runs-on: ubuntu-latest
container:
image: swift:5.10-noble
Expand Down

0 comments on commit 9614996

Please sign in to comment.