Skip to content

Commit

Permalink
Do code coverage in the same job as the main tests. Reenable CodeQL (…
Browse files Browse the repository at this point in the history
…without containers). Remove the dependency graph submission (useless for non-leaf packages). Bump Xcode version used on macOS 13 runners.
  • Loading branch information
gwynne committed May 13, 2024
1 parent 9037e79 commit a1d9c85
Showing 1 changed file with 48 additions and 78 deletions.
126 changes: 48 additions & 78 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
required: false
default: true
description: "Set to 'true' to run tests with Thread Sanitizer. Defaults to 'true'."
with_public_api_check:
with_api_check:
type: boolean
required: false
default: true
Expand Down Expand Up @@ -50,14 +50,14 @@ env:
EXTRA_FLAGS: ${{ inputs.extra_flags }}
WITH_TSAN: ${{ inputs.with_tsan && '--sanitize=thread' || '' }}
TEST_FILTER: ${{ inputs.test_filter != '' && format('--filter={0}', inputs.test_filter) || '' }}
WITH_COVERAGE: ${{ inputs.with_coverage && '--enable-code-coverage' || '' }}

# We use the unversioned "jammy" docker tag to specify the "latest" Swift release in several jobs.
jobs:
api-breakage:
if: ${{ inputs.with_public_api_check && !(github.event.pull_request.draft || false) && github.event_name == 'pull_request' }}
if: ${{ inputs.with_api_check && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
runs-on: ubuntu-latest
container: swift:jammy
timeout-minutes: 20
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -67,70 +67,26 @@ jobs:
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes origin/main ${EXTRA_FLAGS}
dependency-graph:
if: ${{ inputs.with_deps_submission && github.event_name == 'push' }}
runs-on: ubuntu-latest
container: swift:jammy
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fix Git configuration
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
apt-get update && apt-get install -y curl
- name: Submit dependency graph
uses: vapor-community/[email protected]
with:
path: ${{ inputs.package_root != '' && inputs.package_root || github.workspace }}

code-coverage:
if: ${{ inputs.with_coverage && !(github.event.pull_request.draft || false) }}
gh-codeql:
if: ${{ inputs.with_gh_codeql && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
permissions: { actions: write, contents: read, security-events: write }
timeout-minutes: 30
steps:
- name: Install latest Swift toolchain
uses: vapor/[email protected]
with: { toolchain: latest }
- name: Check out code
uses: actions/checkout@v4
- name: Run unit tests for coverage data
run: |
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${TEST_FILTER} --enable-code-coverage ${EXTRA_FLAGS}
- name: Upload coverage data
uses: vapor/[email protected]
with:
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
package_path: ${{ inputs.package_root }}
build_parameters: ${{ inputs.extra_flags }}

# gh-codeql:
# if: ${{ (inputs.with_gh_codeql) && !(github.event.pull_request.draft || false) }}
# runs-on: ubuntu-latest
# container: swift:jammy
# permissions: { actions: write, contents: read, security-events: write }
# timeout-minutes: 30
# steps:
# - name: Check out code
# uses: actions/checkout@v4
# - name: Mark repo safe in non-fake global config
# run: |
# git config --global --add safe.directory "${GITHUB_WORKSPACE}"
# - name: Check Swift compatibility
# id: swift-check
# uses: vapor/ci/.github/actions/check-compatible-swift@main
# with:
# package_root: ${{ inputs.package_root }}
# - name: Initialize CodeQL
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
# uses: github/codeql-action/init@v3
# with: { languages: swift }
# - name: Perform build
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
# run: |
# swift build ${PACKAGE_ROOT} ${EXTRA_FLAGS}
# - name: Run CodeQL analyze
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
# uses: github/codeql-action/analyze@v3
- name: Fix Git configuration
run: 'git config --global --add safe.directory "${GITHUB_WORKSPACE}"'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with: { languages: swift }
- name: Perform build
run: 'swift build ${PACKAGE_ROOT} ${EXTRA_FLAGS}'
- name: Run CodeQL analyze
uses: github/codeql-action/analyze@v3

linux-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
Expand All @@ -149,15 +105,22 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check Swift compatibility
id: swift-check
uses: vapor/ci/.github/actions/check-compatible-swift@main
with:
package_root: ${{ inputs.package_root }}
- name: Run unit tests
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
run: |
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${WITH_TSAN} ${TEST_FILTER} ${EXTRA_FLAGS}
SWIFT_DETERMINISTIC_HASHING=1 \
swift test \
${PACKAGE_ROOT} \
${WITH_TSAN} \
${WITH_COVERAGE} \
${TEST_FILTER} \
${EXTRA_FLAGS}
- name: Upload coverage data
if: ${{ inputs.with_coverage }}
uses: vapor/[email protected]
with:
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
package_path: ${{ inputs.package_root }}
build_parameters: ${{ inputs.extra_flags }}

macos-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
Expand All @@ -166,7 +129,7 @@ jobs:
matrix:
include:
- macos-version: macos-13
xcode-version: '~14.3'
xcode-version: '~15.2'
- macos-version: macos-14
xcode-version: latest
runs-on: ${{ matrix.macos-version }}
Expand All @@ -178,15 +141,22 @@ jobs:
xcode-version: ${{ matrix.xcode-version }}
- name: Check out code
uses: actions/checkout@v4
- name: Check Swift compatibility
id: swift-check
uses: vapor/ci/.github/actions/check-compatible-swift@main
with:
package_root: ${{ inputs.package_root }}
- name: Run unit tests
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
run: |
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${WITH_TSAN} ${TEST_FILTER} ${EXTRA_FLAGS}
SWIFT_DETERMINISTIC_HASHING=1 \
swift test \
${PACKAGE_ROOT} \
${WITH_TSAN} \
${WITH_COVERAGE} \
${TEST_FILTER} \
${EXTRA_FLAGS}
- name: Upload coverage data
if: ${{ inputs.with_coverage }}
uses: vapor/[email protected]
with:
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
package_path: ${{ inputs.package_root }}
build_parameters: ${{ inputs.extra_flags }}

# windows-unit:
# if: ${{ !(github.event.pull_request.draft || false) }}
Expand Down

0 comments on commit a1d9c85

Please sign in to comment.