Skip to content

Commit

Permalink
Use 'swift' instead of 'xcodebuild' for CI. Enable code coverage. (#1)
Browse files Browse the repository at this point in the history
* Use 'swift' instead of 'xcodebuild' for CI. Enable code coverage.

* Make prepare-coverage-reports.sh work with 'swift test'

* Make codecov target reasonable
  • Loading branch information
dfed authored Nov 26, 2023
1 parent 55e96d5 commit ec3ecc0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 231 deletions.
21 changes: 2 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,17 @@ on:

jobs:
spm-15:
name: Build Xcode 15
name: Swift Build Xcode 15
runs-on: macos-13
strategy:
matrix:
platforms: [
'iOS_17,watchOS_10',
'macOS_14,tvOS_17',
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer
- name: Build and Test Framework
run: Scripts/build.swift ${{ matrix.platforms }}
run: xcrun swift test -c release --enable-code-coverage -Xswiftc -enable-testing
- name: Prepare Coverage Reports
run: ./Scripts/prepare-coverage-reports.sh
- name: Upload Coverage Reports
if: success()
uses: codecov/codecov-action@v3
spm-15-swift:
name: Swift Build Xcode 15
runs-on: macos-13
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer
- name: Build and Test Framework
run: xcrun swift test -c release -Xswiftc -enable-testing
199 changes: 0 additions & 199 deletions Scripts/build.swift

This file was deleted.

18 changes: 5 additions & 13 deletions Scripts/prepare-coverage-reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
set -e

function exportlcov() {
build_type=$1
executable_name=$2
executable_name=$1

executable=$(find "${directory}" -type f -name $executable_name)
profile=$(find "${directory}" -type f -name 'Coverage.profdata')
executable=$(find .build/*/*/$executable_name.xctest/Contents/*/$executable_name -type f)
profile=$(find .build -type f -name 'default.profdata')
output_file_name="$executable_name.lcov"

can_proceed=true
if [[ $build_type == watchOS* ]]; then
echo "\tAborting creation of $output_file_name – watchOS not supported."
elif [[ -z $profile ]]; then
if [[ -z $profile ]]; then
echo "\tAborting creation of $output_file_name – no profile found."
elif [[ -z $executable ]]; then
echo "\tAborting creation of $output_file_name – no executable found."
Expand All @@ -26,9 +23,4 @@ function exportlcov() {
fi
}

for directory in $(git rev-parse --show-toplevel)/.build/derivedData/*/; do
build_type=$(basename $directory)
echo "Finding coverage information for $build_type"

exportlcov $build_type 'SafeDITests'
done
exportlcov 'SafeDIPackageTests'
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
codecov:
require_ci_to_pass: yes

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no

coverage:
status:
project:
default:
target: 60%
patch: off

0 comments on commit ec3ecc0

Please sign in to comment.