Convert optional UTF8 String <-> Data conversion to non-optional ones #264
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
pull_request: | |
paths: | |
- .github/workflows/test.yml | |
- Package.* | |
- Sources/**/*.swift | |
- Tests/**/*.swift | |
- .github/matrix.json | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
extract-matrix: | |
name: Extract latest Xcode version from matrix | |
runs-on: ubuntu-latest | |
outputs: | |
xcode-versions: ${{ steps.extract-matrix.outputs.xcode-versions }} | |
latest: ${{ steps.extract-matrix.outputs.latest-xcode-version }} | |
swift-versions: ${{ steps.extract-matrix.outputs.swift-versions }} | |
platforms: ${{ steps.extract-matrix.outputs.platforms }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: extract-matrix | |
run: | | |
echo "xcode-versions=$(cat .github/matrix.json | jq -rc '.xcode_version')" >> $GITHUB_OUTPUT | |
echo "latest-xcode-version=$(cat .github/matrix.json | jq -r '.xcode_version | max')" >> $GITHUB_OUTPUT | |
echo "swift-versions=$(cat .github/matrix.json | jq -rc '.swift_version')" >> $GITHUB_OUTPUT | |
echo "platforms=$(cat .github/matrix.json | jq -rc '.platform')" >> $GITHUB_OUTPUT | |
- name: dump matrix | |
run: | | |
echo 'xcode-versions = ${{ steps.extract-matrix.outputs.xcode-versions }}' | |
echo 'latest-xcode-version = ${{ steps.extract-matrix.outputs.latest-xcode-version }}' | |
echo 'swift-versions = ${{ steps.extract-matrix.outputs.swift-versions }}' | |
echo 'platforms = ${{ steps.extract-matrix.outputs.platforms }}' | |
test-macos: | |
name: Test | |
needs: extract-matrix | |
runs-on: macOS-14 | |
concurrency: | |
group: ${{ github.head_ref }}-${{ github.workflow }}-${{ matrix.xcode }}-${{ matrix.destination }} | |
cancel-in-progress: true | |
strategy: | |
matrix: | |
xcode: ${{ fromJson(needs.extract-matrix.outputs.xcode-versions) }} | |
destination: ${{ fromJson(needs.extract-matrix.outputs.platforms) }} | |
fail-fast: false | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer | |
steps: | |
- uses: actions/checkout@v4 | |
- id: create-destination-key | |
name: Create destination key for cache | |
run: echo "destination-key=$(echo "${{ matrix.destination }}" | sed -r 's/[, ]/_/g')" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
.build/SourcePackages/checkouts | |
key: ${{ runner.os }}-xcode-${{ matrix.xcode }}-${{ steps.create-destination-key.outputs.destination-key }}-${{ hashFiles('Package.swift') }} | |
restore-keys: | | |
${{ runner.os }}-xcode-${{ matrix.xcode }}-${{ steps.create-destination-key.outputs.destination-key }}- | |
- name: test | |
run: | | |
defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1 | |
set -o pipefail && \ | |
rm -rf 'MultipartFormDataParser.xcodeproj' && \ | |
xcrun xcodebuild \ | |
-enableCodeCoverage YES \ | |
-scheme MultipartFormDataParser \ | |
-destination "${{ matrix.destination }}" \ | |
-derivedDataPath '.build' \ | |
-resultBundlePath 'test_output/TestResult.xcresult' \ | |
clean test | xcpretty | |
- name: Upload test result | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.xcode == needs.extract-matrix.outputs.latest && (success() || failure()) }} | |
with: | |
name: ${{ steps.create-destination-key.outputs.destination-key }} | |
path: test_output | |
if-no-files-found: error | |
retention-days: 1 | |
xcodebuild_result: | |
name: Export xcodebuild test result | |
needs: test-macos | |
runs-on: macOS-14 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: test_output | |
- name: Merge xcresult files | |
run: | |
xcrun xcresulttool merge test_output/**/*.xcresult --output-path test_output/TestResults.xcresult | |
- uses: kishikawakatsumi/xcresulttool@v1 | |
if: success() || failure() | |
with: | |
path: test_output/TestResults.xcresult | |
show-passed-tests: false | |
show-code-coverage: false | |
upload-bundles: true | |
test-linux: | |
name: Test | |
needs: extract-matrix | |
runs-on: ubuntu-latest | |
container: swift:${{ matrix.swift }} | |
concurrency: | |
group: ${{ github.head_ref }}-${{ github.workflow }}-${{ matrix.swift }} | |
cancel-in-progress: true | |
strategy: | |
matrix: | |
swift: ${{ fromJson(needs.extract-matrix.outputs.swift-versions) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
.build/SourcePackages/checkouts | |
key: ${{ runner.os }}-xcode-${{ matrix.swift }}-${{ hashFiles('Package.swift') }} | |
restore-keys: | | |
${{ runner.os }}-xcode-${{ matrix.swift }}- | |
- name: test | |
run: swift test |