Skip to content

Commit

Permalink
[GHA] Make unit tests, benchmarks and cxx interop easier to reuse
Browse files Browse the repository at this point in the history
# Motivation

Currently the `pull_request_swift_matrix` workflow provided an easy way to run a command across many Swift versions. We do have a few common commands that we want to run across the repos. Namely, unit tests, benchmarks and cxx interop.

# Modification

This PR creates new workflows for the above common matrix commands so it's easier to reuse them from other repos.

# Result

Even easier to share these workflows.
  • Loading branch information
FranzBusch committed Jul 22, 2024
1 parent 4feff3c commit 97e57b7
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 34 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Benchmarks

on:
workflow_call:
inputs:
linux_5_8_enabled:
type: boolean
description: "Boolean to enable the Linux 5.8 Swift version matrix job. Defaults to true."
default: true
linux_5_9_enabled:
type: boolean
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
default: true
linux_5_10_enabled:
type: boolean
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
default: true
linux_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
default: true
linux_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true

jobs:
benchmarks:
name: Benchmarks
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Benchmarks"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev && swift package --package-path Benchmarks/ --disable-sandbox benchmark baseline check --check-absolute-path Benchmarks/Thresholds/${SWIFT_VERSION}/"
matrix_linux_5_8_enabled: ${{ inputs.linux_5_8_enabled }}
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
38 changes: 38 additions & 0 deletions .github/workflows/cxx_interop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cxx interop

on:
workflow_call:
inputs:
linux_5_8_enabled:
type: boolean
description: "Boolean to enable the Linux 5.8 Swift version matrix job. Defaults to true."
default: true
linux_5_9_enabled:
type: boolean
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
default: true
linux_5_10_enabled:
type: boolean
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
default: true
linux_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
default: true
linux_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true

jobs:
cxx-interop:
name: Cxx interop
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Cxx interop"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q jq && ./scripts/check-cxx-interop-compatibility.sh"
matrix_linux_5_8_enabled: ${{ inputs.linux_5_8_enabled }}
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
55 changes: 21 additions & 34 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,30 @@
name: Pull Request

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

jobs:
call-pull-request-soundness-workflow:
name: Soundness
uses: ./.github/workflows/pull_request_soundness.yml
with:
license_header_check_project_name: "SwiftNIO"
soundness:
name: Soundness
uses: ./.github/workflows/pull_request_soundness.yml
with:
license_header_check_project_name: "SwiftNIO"

call-pull-request-unit-tests-workflow:
name: Unit tests
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Unit tests"
matrix_linux_command: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
# Disable warnings as errors: Swift 6 emits sendability warnings that haven't been dealt with yet.
matrix_linux_nightly_main_command_override: "swift test --explicit-target-dependency-import-check error"
matrix_linux_nightly_6_0_command_override: "swift test --explicit-target-dependency-import-check error"
unit-tests:
uses: ./.github/workflows/unit_tests.yml
with:
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

call-pull-request-benchmark-workflow:
name: Benchmarks
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Benchmarks"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev && swift package --package-path Benchmarks/ --disable-sandbox benchmark baseline check --check-absolute-path Benchmarks/Thresholds/${SWIFT_VERSION}/"
benchmarks:
uses: ./.github/workflows/benchmarks.yml

call-pull-request-cxx-interop-workflow:
name: Cxx interop
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Cxx interop"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q jq && ./scripts/check-cxx-interop-compatibility.sh"
cxx-interop:
uses: ./.github/workflows/cxx_interop.yml

call-pull-request-integration-tests-workflow:
name: Integration tests
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Integration tests"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq && ./scripts/integration_tests.sh"
integration-tests:
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Integration tests"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq && ./scripts/integration_tests.sh"
63 changes: 63 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Unit tests

on:
workflow_call:
inputs:
linux_5_8_enabled:
type: boolean
description: "Boolean to enable the Linux 5.8 Swift version matrix job. Defaults to true."
default: true
linux_5_8_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 5.8 Swift version matrix job."
default: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_9_enabled:
type: boolean
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
default: true
linux_5_9_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 5.9 Swift version matrix job."
default: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_enabled:
type: boolean
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
default: true
linux_5_10_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 5.10 Swift version matrix job."
default: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
default: true
linux_nightly_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux nightly 6.0 Swift version matrix job."
default: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true
linux_nightly_main_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
default: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"

jobs:
unit-tests:
name: Unit tests
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Unit tests"
matrix_linux_command: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
matrix_linux_5_8_enabled: ${{ inputs.linux_5_8_enabled }}
matrix_linux_5_8_command_override: "swift test ${{ inputs.linux_5_8_arguments_override }}"
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
matrix_linux_5_9_command_override: "swift test ${{ inputs.linux_5_9_arguments_override }}"
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
matrix_linux_5_10_command_override: "swift test ${{ inputs.linux_5_10_arguments_override }}"
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
matrix_linux_nightly_6_0_command_override: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
matrix_linux_nightly_main_command_override: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"

0 comments on commit 97e57b7

Please sign in to comment.