Skip to content

Commit a1d9c85

Browse files
committed
Do code coverage in the same job as the main tests. Reenable CodeQL (without containers). Remove the dependency graph submission (useless for non-leaf packages). Bump Xcode version used on macOS 13 runners.
1 parent 9037e79 commit a1d9c85

File tree

1 file changed

+48
-78
lines changed

1 file changed

+48
-78
lines changed

.github/workflows/run-unit-tests.yml

+48-78
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222
required: false
2323
default: true
2424
description: "Set to 'true' to run tests with Thread Sanitizer. Defaults to 'true'."
25-
with_public_api_check:
25+
with_api_check:
2626
type: boolean
2727
required: false
2828
default: true
@@ -50,14 +50,14 @@ env:
5050
EXTRA_FLAGS: ${{ inputs.extra_flags }}
5151
WITH_TSAN: ${{ inputs.with_tsan && '--sanitize=thread' || '' }}
5252
TEST_FILTER: ${{ inputs.test_filter != '' && format('--filter={0}', inputs.test_filter) || '' }}
53+
WITH_COVERAGE: ${{ inputs.with_coverage && '--enable-code-coverage' || '' }}
5354

54-
# We use the unversioned "jammy" docker tag to specify the "latest" Swift release in several jobs.
5555
jobs:
5656
api-breakage:
57-
if: ${{ inputs.with_public_api_check && !(github.event.pull_request.draft || false) && github.event_name == 'pull_request' }}
57+
if: ${{ inputs.with_api_check && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
5858
runs-on: ubuntu-latest
5959
container: swift:jammy
60-
timeout-minutes: 20
60+
timeout-minutes: 30
6161
steps:
6262
- name: Check out code
6363
uses: actions/checkout@v4
@@ -67,70 +67,26 @@ jobs:
6767
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
6868
swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes origin/main ${EXTRA_FLAGS}
6969
70-
dependency-graph:
71-
if: ${{ inputs.with_deps_submission && github.event_name == 'push' }}
72-
runs-on: ubuntu-latest
73-
container: swift:jammy
74-
permissions:
75-
contents: write
76-
steps:
77-
- name: Check out code
78-
uses: actions/checkout@v4
79-
- name: Fix Git configuration
80-
run: |
81-
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
82-
apt-get update && apt-get install -y curl
83-
- name: Submit dependency graph
84-
uses: vapor-community/[email protected]
85-
with:
86-
path: ${{ inputs.package_root != '' && inputs.package_root || github.workspace }}
87-
88-
code-coverage:
89-
if: ${{ inputs.with_coverage && !(github.event.pull_request.draft || false) }}
70+
gh-codeql:
71+
if: ${{ inputs.with_gh_codeql && !(github.event.pull_request.draft || false) }}
9072
runs-on: ubuntu-latest
91-
container: swift:jammy
73+
permissions: { actions: write, contents: read, security-events: write }
9274
timeout-minutes: 30
9375
steps:
76+
- name: Install latest Swift toolchain
77+
uses: vapor/[email protected]
78+
with: { toolchain: latest }
9479
- name: Check out code
9580
uses: actions/checkout@v4
96-
- name: Run unit tests for coverage data
97-
run: |
98-
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${TEST_FILTER} --enable-code-coverage ${EXTRA_FLAGS}
99-
- name: Upload coverage data
100-
uses: vapor/[email protected]
101-
with:
102-
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
103-
package_path: ${{ inputs.package_root }}
104-
build_parameters: ${{ inputs.extra_flags }}
105-
106-
# gh-codeql:
107-
# if: ${{ (inputs.with_gh_codeql) && !(github.event.pull_request.draft || false) }}
108-
# runs-on: ubuntu-latest
109-
# container: swift:jammy
110-
# permissions: { actions: write, contents: read, security-events: write }
111-
# timeout-minutes: 30
112-
# steps:
113-
# - name: Check out code
114-
# uses: actions/checkout@v4
115-
# - name: Mark repo safe in non-fake global config
116-
# run: |
117-
# git config --global --add safe.directory "${GITHUB_WORKSPACE}"
118-
# - name: Check Swift compatibility
119-
# id: swift-check
120-
# uses: vapor/ci/.github/actions/check-compatible-swift@main
121-
# with:
122-
# package_root: ${{ inputs.package_root }}
123-
# - name: Initialize CodeQL
124-
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
125-
# uses: github/codeql-action/init@v3
126-
# with: { languages: swift }
127-
# - name: Perform build
128-
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
129-
# run: |
130-
# swift build ${PACKAGE_ROOT} ${EXTRA_FLAGS}
131-
# - name: Run CodeQL analyze
132-
# if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
133-
# uses: github/codeql-action/analyze@v3
81+
- name: Fix Git configuration
82+
run: 'git config --global --add safe.directory "${GITHUB_WORKSPACE}"'
83+
- name: Initialize CodeQL
84+
uses: github/codeql-action/init@v3
85+
with: { languages: swift }
86+
- name: Perform build
87+
run: 'swift build ${PACKAGE_ROOT} ${EXTRA_FLAGS}'
88+
- name: Run CodeQL analyze
89+
uses: github/codeql-action/analyze@v3
13490

13591
linux-unit:
13692
if: ${{ !(github.event.pull_request.draft || false) }}
@@ -149,15 +105,22 @@ jobs:
149105
steps:
150106
- name: Check out code
151107
uses: actions/checkout@v4
152-
- name: Check Swift compatibility
153-
id: swift-check
154-
uses: vapor/ci/.github/actions/check-compatible-swift@main
155-
with:
156-
package_root: ${{ inputs.package_root }}
157108
- name: Run unit tests
158-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
159109
run: |
160-
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${WITH_TSAN} ${TEST_FILTER} ${EXTRA_FLAGS}
110+
SWIFT_DETERMINISTIC_HASHING=1 \
111+
swift test \
112+
${PACKAGE_ROOT} \
113+
${WITH_TSAN} \
114+
${WITH_COVERAGE} \
115+
${TEST_FILTER} \
116+
${EXTRA_FLAGS}
117+
- name: Upload coverage data
118+
if: ${{ inputs.with_coverage }}
119+
uses: vapor/[email protected]
120+
with:
121+
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
122+
package_path: ${{ inputs.package_root }}
123+
build_parameters: ${{ inputs.extra_flags }}
161124

162125
macos-unit:
163126
if: ${{ !(github.event.pull_request.draft || false) }}
@@ -166,7 +129,7 @@ jobs:
166129
matrix:
167130
include:
168131
- macos-version: macos-13
169-
xcode-version: '~14.3'
132+
xcode-version: '~15.2'
170133
- macos-version: macos-14
171134
xcode-version: latest
172135
runs-on: ${{ matrix.macos-version }}
@@ -178,15 +141,22 @@ jobs:
178141
xcode-version: ${{ matrix.xcode-version }}
179142
- name: Check out code
180143
uses: actions/checkout@v4
181-
- name: Check Swift compatibility
182-
id: swift-check
183-
uses: vapor/ci/.github/actions/check-compatible-swift@main
184-
with:
185-
package_root: ${{ inputs.package_root }}
186144
- name: Run unit tests
187-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
188145
run: |
189-
SWIFT_DETERMINISTIC_HASHING=1 swift test ${PACKAGE_ROOT} ${WITH_TSAN} ${TEST_FILTER} ${EXTRA_FLAGS}
146+
SWIFT_DETERMINISTIC_HASHING=1 \
147+
swift test \
148+
${PACKAGE_ROOT} \
149+
${WITH_TSAN} \
150+
${WITH_COVERAGE} \
151+
${TEST_FILTER} \
152+
${EXTRA_FLAGS}
153+
- name: Upload coverage data
154+
if: ${{ inputs.with_coverage }}
155+
uses: vapor/[email protected]
156+
with:
157+
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
158+
package_path: ${{ inputs.package_root }}
159+
build_parameters: ${{ inputs.extra_flags }}
190160

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

0 commit comments

Comments
 (0)