Skip to content

Commit 737b896

Browse files
authored
Merge branch 'main' into macos-support
2 parents f31ba17 + 23b52b7 commit 737b896

File tree

6 files changed

+133
-10
lines changed

6 files changed

+133
-10
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Create automerge PR
2+
3+
# Merges `head_branch` into `base_branch` and opens a PR to incorporate that merge commit into `base_branch`.
4+
#
5+
# The typical use case for this is in the first period after Swift has cut release branches.
6+
# Some repositories want to include most changes from `main` also in the release branch. When this job is set up, it can automatically create PRs to merge `main` into the release branch.
7+
# Maintainers of the package can then inspect the changes to ensure that they are not too risky for the release branch.
8+
# We will also run the normal PR testing on these changes, ensuring that these modifications don't break the build.
9+
#
10+
# Example usage in a repository:
11+
#
12+
# name: Create PR to merge main into release branch
13+
#
14+
# # In the first period after branching the release branch, we typically want to include all changes from `main` also in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
15+
# # Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
16+
#
17+
# on:
18+
# schedule:
19+
# - cron: '0 9 * * MON'
20+
# workflow_dispatch:
21+
#
22+
# jobs:
23+
# create_merge_pr:
24+
# name: Create PR to merge main into release branch
25+
# uses: swiftlang/github-workflows/.github/workflows/create_autmerge_pr.yml@main
26+
# if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-format') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork
27+
# with:
28+
# base_branch: release/6.2
29+
30+
on:
31+
workflow_call:
32+
inputs:
33+
base_branch:
34+
type: string
35+
description: The branch into which head_branch should be merged
36+
required: true
37+
head_branch:
38+
type: string
39+
description: The branch that should be merged into base_branch
40+
default: main
41+
pr_message:
42+
type: string
43+
description: The message that should be included in the PR created by this job
44+
default: This PR was automatically opened by a GitHub action. Review the changes included in this PR and determine if they should be included in the release branch. If yes, merge the PR. Otherwise revert changes that should not be included on this branch.
45+
46+
jobs:
47+
create_merge_pr:
48+
name: Create PR to merge ${{ inputs.head_branch }} into ${{ inputs.base_branch }} branch
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
- name: Create merge commit
56+
id: create_merge_commit
57+
run: |
58+
# Without this, we can't perform git operations in GitHub actions.
59+
git config --global --add safe.directory "$(realpath .)"
60+
git config --local user.name 'swift-ci'
61+
git config --local user.email '[email protected]'
62+
63+
git checkout ${{ inputs.base_branch }}
64+
git merge ${{ inputs.head_branch }}
65+
66+
if [[ "$(git rev-parse HEAD)" = "$(git rev-parse ${{ inputs.head_branch }})" ]]; then
67+
echo "has_merged_commits=true" >> "$GITHUB_OUTPUT"
68+
else
69+
echo "has_merged_commits=false" >> "$GITHUB_OUTPUT"
70+
fi
71+
- name: Push branch and create PR
72+
id: push_branch
73+
if: ${{ steps.create_merge_commit.outputs.has_merged_commits == 'true' }}
74+
env:
75+
GH_TOKEN: ${{ github.token }}
76+
run: |
77+
PR_BRANCH="automerge/merge-main-$(date +%Y-%m-%d_%H-%M)"
78+
git checkout -b "$PR_BRANCH"
79+
git push --set-upstream origin "$PR_BRANCH"
80+
81+
gh pr create \
82+
--base "${{ inputs.base_branch }}" \
83+
--head "$PR_BRANCH" \
84+
--title 'Merge `${{ inputs.head_branch }}` into `${{ inputs.base_branch }}`' \
85+
--body '${{ inputs.pr_message }}'

.github/workflows/scripts/check-docs.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@ if [ -z "$package_files" ]; then
3131
fatal "Package.swift not found. Please ensure you are running this script from the root of a Swift package."
3232
fi
3333

34-
for package_file in $package_files; do
35-
log "Editing $package_file..."
36-
cat <<EOF >> "$package_file"
34+
# yq 3.1.0-3 doesn't have filter, otherwise we could replace the grep call with "filter(.identity == "swift-docc-plugin") | keys | .[]"
35+
hasDoccPlugin=$(swift package dump-package | yq -r '.dependencies[].sourceControl' | grep -e "\"identity\": \"swift-docc-plugin\"" || true)
36+
if [[ -n $hasDoccPlugin ]]
37+
then
38+
log "swift-docc-plugin already exists"
39+
else
40+
log "Appending swift-docc-plugin"
41+
for package_file in $package_files; do
42+
log "Editing $package_file..."
43+
cat <<EOF >> "$package_file"
3744
3845
package.dependencies.append(
3946
.package(url: "https://github.com/swiftlang/swift-docc-plugin", "1.0.0"..<"1.4.0")
4047
)
4148
EOF
42-
done
49+
done
50+
fi
4351

4452
log "Checking documentation targets..."
4553
for target in $(yq -r '.builder.configs[].documentation_targets[]' .spi.yml); do
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##===----------------------------------------------------------------------===##
2+
##
3+
## This source file is part of the Swift.org open source project
4+
##
5+
## Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
## Licensed under Apache License v2.0 with Runtime Library Exception
7+
##
8+
## See https://swift.org/LICENSE.txt for license information
9+
## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
##
11+
##===----------------------------------------------------------------------===##
12+
. $PSScriptRoot\install-swift.ps1
13+
14+
$SWIFT='https://download.swift.org/swift-6.1-release/windows10/swift-6.1-RELEASE/swift-6.1-RELEASE-windows10.exe'
15+
$SWIFT_SHA256='8C8AEF8B4A449EBEEFD74482AC767E269F8CBE7E520871C1D103C7079C5F4C6A'
16+
17+
Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256

.github/workflows/swift_package_test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Swift Matrix
33
on:
44
workflow_call:
55
inputs:
6+
macos_xcode_versions:
7+
type: string
8+
description: "Exclude Xcode version list (JSON)"
9+
default: "[\"15.4\", \"16.0\", \"16.1\", \"16.2\"]"
610
macos_exclude_xcode_versions:
711
type: string
812
description: "Exclude Xcode version list (JSON)"
@@ -15,6 +19,10 @@ on:
1519
type: string
1620
description: "macOS arch list (JSON)"
1721
default: "[\"ARM64\"]"
22+
linux_swift_versions:
23+
type: string
24+
description: "Include Linux Swift version list (JSON)"
25+
default: "[ \"5.9\", \"5.10\", \"6.0\", \"6.1\", \"nightly-main\", \"nightly-6.1\"]"
1826
linux_exclude_swift_versions:
1927
type: string
2028
description: "Exclude Linux Swift version list (JSON)"
@@ -23,6 +31,10 @@ on:
2331
type: string
2432
description: "Linux OS version list (JSON)"
2533
default: "[\"jammy\"]"
34+
windows_swift_versions:
35+
type: string
36+
description: "Include Windows Swift version list (JSON)"
37+
default: "[\"5.9\", \"6.0\", \"6.1\", \"nightly\", \"nightly-6.1\"]"
2638
windows_exclude_swift_versions:
2739
type: string
2840
description: "Exclude Windows Swift version list (JSON)"
@@ -100,7 +112,7 @@ jobs:
100112
strategy:
101113
fail-fast: false
102114
matrix:
103-
xcode_version: ['15.4', '16.0', '16.1', '16.2']
115+
xcode_version: ${{ fromJson(inputs.macos_xcode_versions) }}
104116
os_version: ${{ fromJson(inputs.macos_versions) }}
105117
arch: ${{ fromJson(inputs.macos_archs) }}
106118
exclude:
@@ -135,7 +147,7 @@ jobs:
135147
strategy:
136148
fail-fast: false
137149
matrix:
138-
swift_version: ['5.8', '5.9', '5.10', '6.0', 'nightly-main', 'nightly-6.1']
150+
swift_version: ${{ fromJson(inputs.linux_swift_versions) }}
139151
os_version: ${{ fromJson(inputs.linux_os_versions) }}
140152
exclude:
141153
- ${{ fromJson(inputs.linux_exclude_swift_versions) }}
@@ -169,7 +181,7 @@ jobs:
169181
strategy:
170182
fail-fast: false
171183
matrix:
172-
swift_version: ['5.9', '6.0', 'nightly', 'nightly-6.1']
184+
swift_version: ${{ fromJson(inputs.windows_swift_versions) }}
173185
exclude:
174186
- ${{ fromJson(inputs.windows_exclude_swift_versions) }}
175187
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
4141
### Testing
4242
43-
To enable pull request testing for all supported Swift versions (5.8, 5.9, 5.10,
44-
6.0, and nightly) on Linux and Windows, add the following code example in
43+
To enable pull request testing for all supported Swift versions (5.9, 5.10,
44+
6.0, 6.1, nightly, and nightly-6.1) on Linux and Windows, add the following code example in
4545
`.github/workflows/pull_request.yml`:
4646

4747
```yaml
@@ -61,7 +61,7 @@ If your package only supports newer compiler versions, you can exclude older
6161
versions by using the `*_exclude_swift_versions` workflow input:
6262

6363
```yaml
64-
linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}, {\"swift_version\": \"5.9\"}]"
64+
linux_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
6565
windows_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
6666
```
6767

0 commit comments

Comments
 (0)