Skip to content

Run tests for implementations #65

Run tests for implementations

Run tests for implementations #65

# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: "2022 smdn <smdn@smdn.jp>"
name: Run tests for implementations
on:
push:
branches: [main]
paths:
- "src/impls/**/*"
- "!src/impls/**/.editorconfig"
- "!src/impls/**/.gitignore"
- "!src/impls/**/README.md"
- "tests/impls/**/*"
pull_request:
types:
- opened
- review_requested
- synchronize
paths:
- "src/impls/**/*"
- "!src/impls/**/.editorconfig"
- "!src/impls/**/.gitignore"
- "!src/impls/**/README.md"
- "tests/impls/**/*"
workflow_dispatch:
inputs:
os:
description: "The OS label which run the test on. (ex: ubuntu-latest, windows-latest, macos-latest)"
required: false
type: string
target-impl:
description: "The target implementation ID to run the tests."
required: false
type: string
verbose:
description: "If true, enables verbose output."
required: false
type: boolean
default: false
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_MINIMUM_VERSION: "8.0.100"
NODEJS_MINIMUM_VERSION: 18
JAVA_MINIMUM_VERSION: 11
jobs:
setup:
name: Set up
runs-on: ubuntu-latest
outputs:
runs-ons: ${{ steps.runs-on-os-list.outputs.runs-ons }}
target-impls: ${{ steps.test-target-impls.outputs.target-impls }}
env:
RUNS_ON_OS_LIST_DEFAULT: "['ubuntu-latest', 'windows-latest', 'macos-latest']"
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Determine OS list which run the tests on
id: runs-on-os-list
shell: pwsh
run: |
$verbose = '${{ inputs.verbose }}' -ieq 'true'
$os_list = $Env:RUNS_ON_OS_LIST_DEFAULT | ConvertFrom-Json
if ( ! [string]::IsNullOrEmpty( '${{ inputs.os }}' ) ) {
$os_list = @('${{ inputs.os }}')
}
if ( $verbose ) {
"::notice::test runs on: $($os_list -join ', ')"
}
"runs-ons=$($os_list | ConvertTo-Json -Compress)" >> $Env:GITHUB_OUTPUT
- name: Determine target implementation list which run the tests to
id: test-target-impls
shell: pwsh
run: |
$verbose = '${{ inputs.verbose }}' -ieq 'true'
$target_impls = Get-Content ./tests/impls/implementations.jsonc | ConvertFrom-Json | Select-Object -ExpandProperty ImplementationId | Get-Unique
if ( ! [string]::IsNullOrEmpty( '${{ inputs.target-impl }}' ) ) {
$target_impls = @('${{ inputs.target-impl }}')
}
if ( $verbose ) {
"::notice::target implementations: $($target_impls -join ', ')"
}
"target-impls=$($target_impls | ConvertTo-Json -Compress)" >> $Env:GITHUB_OUTPUT
run-tests:
name: Test '${{ matrix.target-impl }}' on ${{ matrix.os }}
needs: [setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ${{ fromJson(needs.setup.outputs.runs-ons) }}
target-impl:
- ${{ fromJson(needs.setup.outputs.target-impls) }}
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare .NET SDK ${{ env.DOTNET_SDK_MINIMUM_VERSION }}
uses: smdn/workflows-dotnet/actions/prepare-dotnet-sdk@actions/prepare-dotnet-sdk/v1.0.0
if: ${{ matrix.target-impl == 'csharp' || matrix.target-impl == 'visualbasic' }}
with:
minimal_dotnet_sdk_version: '${{ env.DOTNET_SDK_MINIMUM_VERSION }}'
- name: Setup Java
if: ${{ matrix.target-impl == 'java' }}
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_MINIMUM_VERSION }}
- name: Setup Node.js
if: ${{ matrix.target-impl == 'javascript' }}
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODEJS_MINIMUM_VERSION }}
- name: Setup MSBuild
if: ${{ runner.os == 'Windows' && matrix.target-impl == 'cpp' }}
uses: microsoft/setup-msbuild@v1.3
- name: Run tests with ${{ matrix.target-impl }} on ${{ matrix.os }}
shell: pwsh
run: |
$verbose = '${{ inputs.verbose }}' -ieq 'true'
$run_tests_options = @(
'--target-impl', '${{ matrix.target-impl }}'
)
if ($verbose) {
$run_tests_options += "-v"
}
if ($verbose) {
"pwsh tests/impls/run-tests.ps1 $($run_tests_options -join ' ')"
}
pwsh tests/impls/run-tests.ps1 $run_tests_options