Skip to content

Commit 9614996

Browse files
authored
[GHA] Create reusable workflow (#2767)
# 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.
1 parent 9730938 commit 9614996

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
7+
jobs:
8+
call-reusable-pull-request-workflow:
9+
name: Checks
10+
uses: ./.github/workflows/reusable_pull_request.yml

.github/workflows/pull_requests.yml renamed to .github/workflows/reusable_pull_request.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
name: Pull Request
22

33
on:
4-
pull_request:
5-
types: [opened, reopened, synchronize, ready_for_review]
4+
workflow_call:
5+
inputs:
6+
enable_unit_tests:
7+
type: boolean
8+
description: "Boolean to enable the unit tests job. Defaults to true."
9+
default: true
10+
enable_api_breakage_check:
11+
type: boolean
12+
description: "Boolean to enable the API breakage check job. Defaults to true."
13+
default: true
14+
enable_docs_check:
15+
type: boolean
16+
description: "Boolean to enable the docs check job. Defaults to true."
17+
default: true
618

719
## We are cancelling previously triggered workflow runs
820
concurrency:
@@ -12,6 +24,7 @@ concurrency:
1224
jobs:
1325
unit-tests:
1426
name: Unit tests
27+
if: ${{ inputs.enable_unit_tests }}
1528
runs-on: ubuntu-latest
1629
strategy:
1730
fail-fast: false
@@ -31,8 +44,9 @@ jobs:
3144
- name: Run tests
3245
run: swift test
3346

34-
api-breakage:
47+
api-breakage-check:
3548
name: API breakage check
49+
if: ${{ inputs.enable_api_breakage_check }}
3650
runs-on: ubuntu-latest
3751
container:
3852
image: swift:5.10-noble
@@ -51,6 +65,7 @@ jobs:
5165

5266
docs-check:
5367
name: Documentation check
68+
if: ${{ inputs.enable_docs_check }}
5469
runs-on: ubuntu-latest
5570
container:
5671
image: swift:5.10-noble

0 commit comments

Comments
 (0)