From 541f0d30e0bf40b1ab24d6ec4650418d268b2f0a Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Fri, 5 Jul 2024 07:59:17 +0100 Subject: [PATCH] [GHA] Create reusable workflow # 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. --- .github/workflows/pull_request.yml | 9 ++++++++ ...requests.yml => reusable_pull_request.yml} | 21 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pull_request.yml rename .github/workflows/{pull_requests.yml => reusable_pull_request.yml} (74%) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000000..e58ca73cf1 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,9 @@ +name: Pull Request + +on: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + +jobs: + call-reusable-pull-request-workflow: + uses: ./.github/workflows/reusable_pull_request.yml \ No newline at end of file diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/reusable_pull_request.yml similarity index 74% rename from .github/workflows/pull_requests.yml rename to .github/workflows/reusable_pull_request.yml index a455b2dabd..4a4b05bc5e 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/reusable_pull_request.yml @@ -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: @@ -12,6 +24,7 @@ concurrency: jobs: unit-tests: name: Unit tests + if: ${{ inputs.enable_unit_tests }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -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 @@ -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