This repository contains reusable GitHub Actions workflows and a collection of Bash scripts designed to streamline quality checks, documentation, formatting, and maintenance tasks in Swift projects.
The workflows build on the official swiftlang/github-workflows and extend them with additional soundness, documentation, and tooling checks.
These workflows and scripts are designed to be used within GitHub Actions. A basic working knowledge of GitHub Actions is required to configure workflows, understand job execution, and troubleshoot CI failures.
If you are not familiar with GitHub Actions, refer to the official documentation before using or customizing these workflows: GitHub Actions documentation
No installation required.
All scripts are executed directly via curl | bash or through the provided Makefile.
This section details the reusable workflows provided by the repository.
This workflow provides configurable, robust checks and testing:
- Optional Local Swift Dependency Checks: Checks for accidental
.package(path:)usage. - Optional Swift Headers Check: Validates Swift source file headers using a strict 5-line format and respects
.swiftheaderignore. - Optional DocC Warnings Check: Runs DocC analysis with
--warnings-as-errorsand fails on warnings. - Optional Swift Test Execution: Runs tests using
.buildcaching for efficiency. - Multi-Version Support: Tests across multiple Swift versions, configurable via input (defaulting to
["6.0", "6.1"]). - SSH Support: Includes steps to set up SSH credentials (via the
SSH_PRIVATE_KEYsecret) for projects relying on private Git dependencies.
| Input | Description | Default |
|---|---|---|
local_swift_dependencies_check_enabled |
Enables local Swift dependency check | false |
headers_check_enabled |
Enables Swift headers validation | false |
docc_warnings_check_enabled |
Enables DocC warnings check | false |
run_tests_with_cache_enabled |
Enables Swift tests with .build cache |
false |
run_tests_swift_versions |
Swift versions to test | ["6.1","6.2"] |
jobs:
soundness:
uses: BinaryBirds/github-workflows/.github/workflows/extra_soundness.yml@main
with:
local_swift_dependencies_check_enabled: true
headers_check_enabled: true
docc_warnings_check_enabled: true
run_tests_with_cache_enabled: true
run_tests_swift_versions: '["6.1","6.2"]'This workflow handles the generation and deployment of DocC documentation:
- Builds DocC Documentation: Uses a Swift 6.2 Docker image to build the documentation.
- Deploys to GitHub Pages: Uses
actions/deploy-pages@v4to publish the results. - Target Configuration: Respects
.docctargetlistif present.
Example Usage (Caller Repository):
jobs:
create-docc-and-deploy:
uses: BinaryBirds/github-workflows/.github/workflows/docc_deploy.yml@main
permissions:
contents: read
pages: write
id-token: writeA Makefile is included to simplify the execution of all automation tasks by converting long curl | bash commands into short, memorable make targets.
Some Makefile targets group multiple related checks into a single command.
These combined commands run several scripts in sequence to provide a quick, consistent way to verify overall project quality. For a concrete reference, see the make check target in the Makefile, which combines several core checks into one command.
- Standardizes script usage and ensures consistent options.
- Shortens long commands into memorable tasks.
- Supports composite commands and reduces human error.
The Makefile uses the variable baseUrl which points to the source of all scripts:
https://raw.githubusercontent.com/BinaryBirds/github-workflows/refs/heads/main/scripts
Detects source- and binary-level API breaking changes in Swift packages to prevent unintended public API regressions.
- Uses
swift package diagnose-api-breaking-changes - Pull requests: compares against the PR base branch
- Other contexts: compares against the latest Git tag
- If no tags exist, exits successfully with a warning
- Fails when breaking changes are detected
None
None
curl -s $(baseUrl)/check-api-breakage.sh | bashEnsures all git-tracked symbolic links resolve to valid targets.
- Inspects only symbolic links
- Ignores regular missing files
- Reports each broken symlink explicitly
- Exits non-zero if any broken symlink is found
None
None
curl -s $(baseUrl)/check-broken-symlinks.sh | bashRuns DocC documentation analysis in strict mode, treating warnings as errors.
- Uses
.docctargetlistwhen present, otherwise auto-detects targets - Temporarily injects
swift-docc-pluginif missing - Requires a clean git working tree locally
- Restores git state after execution
None
.docctargetlist– explicitly defines documented targets
curl -s $(baseUrl)/check-docc-warnings.sh | bashPrevents accidental usage of local Swift package dependencies.
- Scans all tracked
Package.swiftfiles - Detects
.package(path:) - Fails immediately on detection
None
None
curl -s $(baseUrl)/check-local-swift-dependencies.sh | bashRuns a security scan of an OpenAPI specification using OWASP ZAP.
- Executes inside Docker
- Skips execution if
openapi/directory does not exist
None
None
curl -s $(baseUrl)/check-openapi-security.sh | bashValidates an OpenAPI specification for schema correctness.
- Runs the OpenAPI validator in Docker
- Skips execution if
openapi/directory does not exist
None
None
curl -s $(baseUrl)/check-openapi-validation.sh | bashEnsures Swift source files contain a consistent, standardized header.
- Enforces a strict 5-line header format
- Can optionally insert or update headers in-place
- Processes only git-tracked Swift files
--fix– insert or update headers automatically--author <name>– override default author name
.swiftheaderignore– excludes paths from header validation
Raw curl examples
Check only:
curl -s $(baseUrl)/check-swift-headers.sh | bashFix headers with custom author:
curl -s $(baseUrl)/check-swift-headers.sh | bash -s -- --fix --author "John Doe"Detects discouraged or outdated terminology to promote inclusive language.
- Case-insensitive, whole-word matching
- Scans git-tracked files only
None
.unacceptablelanguageignore– excludes paths from scanning
curl -s $(baseUrl)/check-unacceptable-language.sh | bashGenerates a CONTRIBUTORS.txt file from git commit history.
- Uses
git shortlog - Respects
.mailmap - Overwrites the file deterministically
None
None
curl -s $(baseUrl)/generate-contributors-list.sh | bashGenerates DocC documentation into the docs/ directory.
- Supports multiple Swift targets
- Enables combined documentation automatically
- Can transform output for static hosting
--local– disable static hosting transform--name <value>– set hosting base path
.docctargetlist– explicitly defines documented targets
Raw curl examples
GitHub Pages output:
curl -s $(baseUrl)/generate-docc.sh | bash -s -- --name MyRepoLocal preview:
curl -s $(baseUrl)/generate-docc.sh | bash -s -- --localInstalls the swift-format binary.
- Builds from source
- Installs into
/usr/local/bin
None
None
curl -s $(baseUrl)/install-swift-format.sh | bashInstalls the Swift OpenAPI Generator CLI tool.
- Builds from source
- Supports version pinning
-v <version>– install a specific version
None
Raw curl examples
Latest version:
curl -s $(baseUrl)/install-swift-openapi-generator.sh | bashSpecific version:
curl -s $(baseUrl)/install-swift-openapi-generator.sh | bash -s -- -v 1.2.2Removes generated build artifacts and temporary files.
- Deletes
.build,.swiftpm, and generated files - Intended for local development use
None
None
curl -s $(baseUrl)/run-clean.sh | bashServes generated DocC documentation locally using Docker.
- Runs Nginx in the foreground
- Exposes documentation over HTTP
-n <name>– container name-p <host:container>– port mapping
None
curl -s $(baseUrl)/run-docc-docker.sh | bash -s -- -p 8800:80Serves OpenAPI documentation locally using Docker.
- Runs Nginx in the foreground
- Exposes documentation over HTTP
-n <name>– container name-p <host:container>– port mapping
None
curl -s $(baseUrl)/run-openapi-docker.sh | bash -s -- -n openapi-previewRuns swift-format to lint or format Swift source files.
- Downloads default configuration if missing
- Respects ignore rules
- Supports parallel execution
--fix– format files in-place
.swiftformatignore– excludes files from formatting
Lint only:
curl -s $(baseUrl)/run-swift-format.sh | bashFix formatting:
curl -s $(baseUrl)/run-swift-format.sh | bash -s -- --fix