Skip to content

Commit f795237

Browse files
ci: Migrate to GitHub Actions and reusable workflows, part two (#117)
### Motivation Following #116 we can now cut over to the soundness checks from the GithHub Actions CI and short-circuit the old CI checks. ### Modifications - Remove most scripts used by old CI - Short-circuit API checking script - Short-circuit the docker CI - Enable soundness tests in GitHub Actions workflow - Ignore docker/* for license check - Remove DocC plugin from package manifest - Update CONTRIBUTING.md with instructions for local run ### Result GitHub Actions CI is the one that we care about. We can then update the branch rules, disable the old webhook, and, finally, remove the vestigial stuff.
1 parent e1f390a commit f795237

14 files changed

+39
-431
lines changed

.github/workflows/pull_request.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ jobs:
99
name: Soundness
1010
uses: apple/swift-nio/.github/workflows/soundness.yml@main
1111
with:
12-
# These are set to false to stage this in with the old CI.
13-
# A follow-up PR will cut them over.
14-
api_breakage_check_enabled: false
15-
broken_symlink_check_enabled: false
16-
docs_check_enabled: false
17-
format_check_enabled: false
18-
license_header_check_enabled: false
12+
api_breakage_check_enabled: true
13+
broken_symlink_check_enabled: true
14+
docs_check_enabled: true
15+
format_check_enabled: true
16+
license_header_check_enabled: true
1917
license_header_check_project_name: "SwiftOpenAPIGenerator"
20-
shell_check_enabled: false
21-
unacceptable_language_check_enabled: false
18+
shell_check_enabled: true
19+
unacceptable_language_check_enabled: true
2220

2321
unit-tests:
2422
name: Unit tests

.licenseignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
**.md
88
**.txt
99
Package.swift
10+
docker/*

CONTRIBUTING.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,40 @@ A good patch is:
5656
3. Documented, adding API documentation as needed to cover new functions and properties.
5757
4. Accompanied by a great commit message, using our commit message template.
5858

59-
### Run `./scripts/soundness.sh`
59+
### Run CI checks locally
6060

61-
The scripts directory contains a [soundness.sh script](https://github.com/apple/swift-openapi-runtime/blob/main/scripts/soundness.sh)
62-
that enforces additional checks, like license headers and formatting style.
61+
You can run the Github Actions workflows locally using
62+
[act](https://github.com/nektos/act). To run all the jobs that run on a pull
63+
request, use the following command:
6364

64-
Please make sure to `./scripts/soundness.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail
65-
on minor changes such as a missing `self.` or similar formatting issues.
65+
```
66+
% act pull_request
67+
```
6668

67-
For frequent contributors, we recommend adding the script as a [git pre-push hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), which you can do via executing the following command in the project root directory:
69+
To run just a single job, use `workflow_call -j <job>`, and specify the inputs
70+
the job expects. For example, to run just shellcheck:
71+
72+
```
73+
% act workflow_call -j soundness --input shell_check_enabled=true
74+
```
6875

69-
```bash
70-
cat << EOF > .git/hooks/pre-push
76+
To bind-mount the working directory to the container, rather than a copy, use
77+
`--bind`. For example, to run just the formatting, and have the results
78+
reflected in your working directory:
7179

72-
if [[ -f "scripts/soundness.sh" ]]; then
73-
scripts/soundness.sh
74-
fi
75-
EOF
80+
```
81+
% act --bind workflow_call -j soundness --input format_check_enabled=true
7682
```
7783

78-
Which makes the script execute, and only allow the `git push` to complete if the check has passed.
84+
If you'd like `act` to always run with certain flags, these can be be placed in
85+
an `.actrc` file either in the current working directory or your home
86+
directory, for example:
7987

80-
In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.
88+
```
89+
--container-architecture=linux/amd64
90+
--remote-name upstream
91+
--action-offline-mode
92+
```
8193

8294
## How to contribute your work
8395

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ let package = Package(
3434
],
3535
dependencies: [
3636
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.0"),
37-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
3837
],
3938
targets: [
4039
.target(

docker/docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ services:
2626

2727
soundness:
2828
<<: *common
29-
command: /bin/bash -xcl "swift -version && uname -a && ./scripts/soundness.sh"
29+
command: echo "skipping; moved to Github Actions"
3030

3131
test:
3232
<<: *common
33-
command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} $${STRICT_CONCURRENCY_ARG-}"
33+
command: echo "skipping; moved to Github Actions"
3434

3535
shell:
3636
<<: *common
3737
entrypoint: /bin/bash
3838

3939
integration-test:
4040
<<: *common
41-
command: /bin/bash -xcl "swift -version && uname -a && bash ./scripts/run-integration-test.sh"
41+
command: echo "skipping; moved to Github Actions"
4242

4343
docc-test:
4444
<<: *common
45-
command: /bin/bash -xcl "swift -version && uname -a && bash ./scripts/check-for-docc-warnings.sh"
45+
command: echo "skipping; moved to Github Actions"
4646
environment:
4747
DOCC_TARGET: OpenAPIRuntime

scripts/check-for-breaking-api-changes.sh

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,4 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16-
set -euo pipefail
17-
18-
log() { printf -- "** %s\n" "$*" >&2; }
19-
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
20-
fatal() { error "$@"; exit 1; }
21-
22-
CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23-
REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)"
24-
25-
log "Checking required environment variables..."
26-
test -n "${BASELINE_REPO_URL:-}" || fatal "BASELINE_REPO_URL unset"
27-
test -n "${BASELINE_TREEISH:-}" || fatal "BASELINE_TREEISH unset"
28-
29-
log "Fetching baseline: ${BASELINE_REPO_URL}#${BASELINE_TREEISH}..."
30-
git -C "${REPO_ROOT}" fetch "${BASELINE_REPO_URL}" "${BASELINE_TREEISH}"
31-
BASELINE_COMMIT=$(git -C "${REPO_ROOT}" rev-parse FETCH_HEAD)
32-
33-
log "Checking for API changes since ${BASELINE_REPO_URL}#${BASELINE_TREEISH} (${BASELINE_COMMIT})..."
34-
swift package --package-path "${REPO_ROOT}" diagnose-api-breaking-changes \
35-
"${BASELINE_COMMIT}" \
36-
&& RC=$? || RC=$?
37-
38-
if [ "${RC}" -ne 0 ]; then
39-
fatal "❌ Breaking API changes detected."
40-
exit "${RC}"
41-
fi
42-
log "✅ No breaking API changes detected."
16+
exit 0

scripts/check-for-broken-symlinks.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

scripts/check-for-docc-warnings.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

scripts/check-for-unacceptable-language.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

scripts/check-license-headers.sh

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)