Skip to content

Commit aebbed3

Browse files
authored
feat: add Swift macOS CI workflow (#207)
1 parent 794b2b5 commit aebbed3

5 files changed

Lines changed: 99 additions & 3 deletions

File tree

.github/workflows/ci_swift.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: template-ci-swift
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
checkout-ref:
7+
description: "checkout ref (leave empty to use the event's natural ref)"
8+
required: false
9+
type: string
10+
default: ""
11+
project:
12+
description: "Path to the Xcode project"
13+
required: false
14+
type: string
15+
default: "Glossa.xcodeproj"
16+
scheme:
17+
description: "Xcode scheme to build and test"
18+
required: false
19+
type: string
20+
default: "Glossa"
21+
configuration:
22+
description: "Xcode build configuration"
23+
required: false
24+
type: string
25+
default: "Debug"
26+
derived-data-path:
27+
description: "DerivedData output path"
28+
required: false
29+
type: string
30+
default: ".build/DerivedData"
31+
run-tests:
32+
description: "Whether to run xcodebuild test"
33+
required: false
34+
type: boolean
35+
default: true
36+
runner:
37+
description: "Runner label for macOS/Xcode builds"
38+
required: false
39+
type: string
40+
default: ""
41+
42+
jobs:
43+
build-and-test:
44+
runs-on: ${{ inputs.runner || fromJSON(vars.RUNNER_PROFILES)[vars.RUNNER_PROFILE].macos }}
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v6
48+
with:
49+
ref: ${{ inputs.checkout-ref }}
50+
51+
- name: Show Xcode version
52+
run: xcodebuild -version
53+
54+
- name: Build
55+
run: >
56+
xcodebuild
57+
-project "${{ inputs.project }}"
58+
-scheme "${{ inputs.scheme }}"
59+
-configuration "${{ inputs.configuration }}"
60+
-derivedDataPath "${{ inputs.derived-data-path }}"
61+
CODE_SIGNING_ALLOWED=NO
62+
CODE_SIGNING_REQUIRED=NO
63+
build
64+
65+
- name: Test
66+
if: inputs.run-tests
67+
run: >
68+
xcodebuild
69+
-project "${{ inputs.project }}"
70+
-scheme "${{ inputs.scheme }}"
71+
-configuration "${{ inputs.configuration }}"
72+
-derivedDataPath "${{ inputs.derived-data-path }}"
73+
CODE_SIGNING_ALLOWED=NO
74+
CODE_SIGNING_REQUIRED=NO
75+
test

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Current groups:
5252
| `node-bench` | node-bench | repo has a Node/pnpm benchmark workflow and wants the shared manual benchmark caller |
5353
| `npm-package` | publish-npm-package | repo publishes a Node package to npmjs.com on release (needs `secrets.NPMJS_API_TOKEN`) |
5454
| `go` | ci-go | repo has `go.mod` |
55+
| `swift` | ci-swift | repo is a native Swift/Xcode app, including macOS app development |
5556
| `docker` | build-docker-image | repo publishes a docker image to ghcr.io |
5657
| `quarto-docs` | publish-quarto-docs | repo publishes a Quarto site from `docs` to `gh-pages` |
5758
| `helm-chart` | build-helm-chart | repo publishes a Helm chart (needs `vars.HELM_CHART_REPO` + `secrets.CHARTS_WRITE_TOKEN`) |
@@ -91,11 +92,11 @@ The canonical caller workflows encode invariants that are easy to break by hand
9192

9293
- **Top-level `permissions:`** — only the caller's *top-level* permissions cascade into reusable workflows. Job-level permissions on the caller are silently ignored when the caller invokes a reusable. Missing this on `build_docker_image.yaml` was the keymint v1.0.0 silent build failure.
9394
- **Secret name match** — the reusable declares a secret name; the caller must pass it under exactly that name. `app_private_key` vs `INTEGRATION_APP_PRIVATE_KEY` is a one-character bug that fails the run at startup.
94-
- **Runner forwarding** — every reusable that runs jobs takes a `runner:` input parameterised via `vars.RUNNER_PROFILES[vars.RUNNER_PROFILE].default`. Hard-coded `ubuntu-latest` is forbidden.
95+
- **Runner forwarding** — every reusable that runs jobs takes a `runner:` input parameterised via `vars.RUNNER_PROFILES[vars.RUNNER_PROFILE].<role>`. Linux CI generally uses `default`; native Swift/Xcode macOS app CI uses `macos`. Hard-coded labels such as `ubuntu-latest` or `macos-latest` are forbidden.
9596

9697
## Tests: unit vs integration
9798

98-
The canonical `ci-python` / `ci-go` / `ci-node` callers run **lint + unit tests only**. Integration tests — anything that needs external infrastructure (database, message bus, S3, etc.) — stay **bespoke per repo** in a separate `integration-tests.yaml` workflow that owns its own service setup, fixtures, and secrets.
99+
The canonical `ci-python` / `ci-go` / `ci-node` / `ci-swift` callers run **lint/build + unit tests only**. For native Swift/Xcode macOS app development, `ci-swift` builds and tests the app scheme on a macOS runner with code signing disabled. Integration tests — anything that needs external infrastructure (database, message bus, S3, etc.) — stay **bespoke per repo** in a separate `integration-tests.yaml` workflow that owns its own service setup, fixtures, and secrets.
99100

100101
Why: each repo's external deps are different, so there's no canonical infra setup that fits every consumer. Pushing infra into the canonical CI would either reintroduce per-repo substitution (rejected — see "How a consuming repo uses this" above) or impose a one-size-fits-none stack on every Python/Go/Node repo.
101102

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# github-action-templates
22

3-
Reusable GitHub Actions workflows + canonical caller workflows shared across consumer orgs.
3+
Reusable GitHub Actions workflows + canonical caller workflows shared across consumer orgs, including native Swift/Xcode macOS app CI.
44

55
## Two halves
66

consumers/groups/swift.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Swift/macOS app source group. Pulls in Xcode build + test on a macOS runner.
2+
includes:
3+
- ci-swift

consumers/workflows/ci-swift.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# GENERATED/SHARED WORKFLOW: copied into consuming repos by sync-shared.
2+
# Do not edit in consuming repos; change jr200-labs/github-action-templates and sync.
3+
name: ci-swift
4+
5+
on:
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
13+
jobs:
14+
ci:
15+
uses: jr200-labs/github-action-templates/.github/workflows/ci_swift.yaml@master
16+
with:
17+
runner: ${{ fromJSON(vars.RUNNER_PROFILES)[vars.RUNNER_PROFILE].macos }}

0 commit comments

Comments
 (0)