Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rnro committed Dec 3, 2024
1 parent dc4c2c1 commit 3eab60e
Show file tree
Hide file tree
Showing 6 changed files with 514 additions and 4 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/cxx_interop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Cxx interop

on:
workflow_call:
inputs:
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_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux 6.0 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

windows_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
default: false
windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
default: false
windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
default: false

jobs:
construct-matrix:
name: Construct Cxx interop matrix
runs-on: ubuntu-latest
outputs:
cxx-interop-matrix: '${{ steps.generate-matrix.outputs.cxx-interop-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- id: generate-matrix
run: echo "cxx-interop-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
env:
MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q curl jq"
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
MATRIX_LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.linux_nightly_6_0_enabled }}
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}

cxx-interop:
name: Cxx interop
needs: construct-matrix
# TODO: use global reference
uses: ./.github/workflows/swift_test_matrix.yml
with:
name: "Cxx interop"
matrix_string: '${{ needs.construct-matrix.outputs.cxx-interop-matrix }}'
25 changes: 21 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,33 @@ jobs:
license_header_check_project_name: "SwiftCrypto"
docs_check_enabled: false

construct-cmake-matrix:
name: Construct cmake matrix
runs-on: ubuntu-latest
outputs:
cmake-matrix: '${{ steps.generate-matrix.outputs.cmake-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- id: generate-matrix
run: echo "cmake-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
env:
MATRIX_LINUX_COMMAND: "./scripts/check-cmake-lists.sh"

cmake-lists:
name: Check cmake lists
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
needs: construct-cmake-matrix
# TODO: use global reference
uses: ./.github/workflows/swift_test_matrix.yml
with:
name: "Check cmake lists"
matrix_linux_command: ./scripts/check-cmake-lists.sh
matrix_string: '${{ needs.construct-cmake-matrix.outputs.cmake-matrix }}'

unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
Expand All @@ -37,4 +54,4 @@ jobs:

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
uses: ./.github/workflows/cxx_interop.yml
102 changes: 102 additions & 0 deletions .github/workflows/swift_test_matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Matrix

on:
workflow_call:
inputs:
name:
type: string
description: "The name of the workflow used for the concurrency group."
required: true
matrix_path:
type: string
description: "The path of the test matrix definition."
default: ""
matrix_string:
type: string
description: "The test matrix definition."
default: ""

# We will cancel previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
cancel-in-progress: true

jobs:
generate-matrix:
name: Prepare matrices
runs-on: ubuntu-latest
outputs:
swift-matrix: ${{ steps.load-matrix.outputs.swift-matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- id: file_check
run: |
if [ -n '${{ inputs.matrix_string }}' ]; then
echo "matrix_string_populated=true" >> $GITHUB_ENV
else
echo "matrix_string_populated=false" >> $GITHUB_ENV
fi
- id: cat-matrix
if: ${{ env.matrix_string_populated == 'false' }}
run: |
jq -c '.' ${{ inputs.matrix_path }} >| __coverage_matrix.json
- id: write-matrix
if: ${{ env.matrix_string_populated == 'true' }}
run: |
echo '${{ inputs.matrix_string }}' | jq -c '.' >| __coverage_matrix.json
- id: load-matrix
run: |
{
echo 'swift-matrix<<EOF'
echo "$(cat __coverage_matrix.json)"
echo EOF
} >> "$GITHUB_OUTPUT"
execute-matrix:
name: ${{ matrix.swift.platform }} (${{ matrix.swift.name }})
needs: generate-matrix
runs-on: ${{ matrix.swift.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.swift-matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Pull Docker image
run: docker pull ${{ matrix.swift.image }}
- name: Run matrix job
if: ${{ matrix.swift.platform != 'Windows' }}
run: |
if [[ -n "${{ matrix.swift.setup_command }}" ]]; then
setup_command_expression="${{ matrix.swift.setup_command }} &&"
else
setup_command_expression=""
fi
workspace="/$(basename ${{ github.workspace }})"
docker run -v ${{ github.workspace }}:"$workspace" \
-w "$workspace" \
-e SWIFT_VERSION="${{ matrix.swift.swift_version }}" \
-e setup_command_expression="$setup_command_expression" \
${{ matrix.swift.image }} \
bash -c "swift --version && git config --global --add safe.directory \"*\" && $setup_command_expression ${{ matrix.swift.command }} ${{ matrix.swift.command_arguments }}"
- name: Run matrix job (Windows)
if: ${{ matrix.swift.platform == 'Windows' }}
run: |
if (-not [string]::IsNullOrEmpty("${{ matrix.swift.setup_command }}")) {
$setup_command_expression = "${{ matrix.swift.setup_command }} &"
} else {
$setup_command_expression = ""
}
$workspace = "C:\" + (Split-Path ${{ github.workspace }} -Leaf)
docker run -v ${{ github.workspace }}:$($workspace) -w $($workspace) -e SWIFT_VERSION="${{ matrix.swift.swift_version }}" -e setup_command_expression=%setup_command_expression% ${{ matrix.swift.image }} cmd /s /c "swift --version & powershell Invoke-Expression ""$($setup_command_expression) ${{ matrix.swift.command }} ${{ matrix.swift.command_arguments }}"""
env:
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
112 changes: 112 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Unit tests

on:
workflow_call:
inputs:
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: ""
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: ""
linux_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux 6.0 Swift version matrix job. Defaults to true."
default: true
linux_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 6.0 Swift version matrix job."
default: ""
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: ""
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: ""

windows_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
default: false
windows_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows 6.0 Swift version matrix job."
default: ""
windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows nightly 6.0 Swift version matrix job."
default: ""
windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
default: false
windows_nightly_main_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows nightly main Swift version matrix job."
default: ""

jobs:
construct-matrix:
name: Construct unit test matrix
runs-on: ubuntu-latest
outputs:
unit-test-matrix: '${{ steps.generate-matrix.outputs.unit-test-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- id: generate-matrix
run: echo "unit-test-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
env:
MATRIX_LINUX_COMMAND: "swift test"
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
MATRIX_LINUX_5_9_COMMAND_ARGUMENTS: ${{ inputs.linux_5_9_arguments_override }}
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
MATRIX_LINUX_5_10_COMMAND_ARGUMENTS: ${{ inputs.linux_5_10_arguments_override }}
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
MATRIX_LINUX_6_0_COMMAND_ARGUMENTS: ${{ inputs.linux_6_0_arguments_override }}
MATRIX_LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.linux_nightly_6_0_enabled }}
MATRIX_LINUX_NIGHTLY_6_0_COMMAND_ARGUMENTS: ${{ inputs.linux_nightly_6_0_arguments_override }}
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}
MATRIX_LINUX_NIGHTLY_MAIN_COMMAND_ARGUMENTS: ${{ inputs.linux_nightly_main_arguments_override }}
MATRIX_WINDOWS_COMMAND: "swift test"
MATRIX_WINDOWS_6_0_ENABLED: ${{ inputs.windows_6_0_enabled }}
MATRIX_WINDOWS_6_0_COMMAND_ARGUMENTS: ${{ inputs.windows_6_0_arguments_override }}
MATRIX_WINDOWS_NIGHTLY_6_0_ENABLED: ${{ inputs.windows_nightly_6_0_enabled }}
MATRIX_WINDOWS_NIGHTLY_6_0_COMMAND_ARGUMENTS: ${{ inputs.windows_nightly_6_0_arguments_override }}
MATRIX_WINDOWS_NIGHTLY_MAIN_ENABLED: ${{ inputs.windows_nightly_main_enabled }}
MATRIX_WINDOWS_NIGHTLY_MAIN_COMMAND_ARGUMENTS: ${{ inputs.windows_nightly_main_arguments_override }}

unit-tests:
name: Unit tests
needs: construct-matrix
# TODO: use global reference
uses: ./.github/workflows/swift_test_matrix.yml
with:
name: "Unit tests"
matrix_string: '${{ needs.construct-matrix.outputs.unit-test-matrix }}'
57 changes: 57 additions & 0 deletions 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: PR

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

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftCrypto"
docs_check_enabled: false

construct-cmake-matrix:
name: Construct cmake matrix
runs-on: ubuntu-latest
outputs:
cmake-matrix: '${{ steps.generate-matrix.outputs.cmake-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- id: generate-matrix
run: echo "cmake-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
env:
MATRIX_LINUX_COMMAND: "./scripts/check-cmake-lists.sh"

cmake-lists:
name: Check cmake lists
needs: construct-cmake-matrix
# TODO: use global reference
uses: ./.github/workflows/swift_test_matrix.yml
with:
name: "Check cmake lists"
matrix_string: '${{ needs.construct-cmake-matrix.outputs.cmake-matrix }}'

unit-tests:
name: Unit tests
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_nightly_6_0_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

cxx-interop:
name: Cxx interop
uses: ./.github/workflows/cxx_interop.yml
Loading

0 comments on commit 3eab60e

Please sign in to comment.