Skip to content

Commit d65527a

Browse files
Add proposal validation workflow and documentation (#288)
* Add proposal validation workflow and documentation * Add flag to proposal validation workflow to enable testing * Add proposal validation workflow to pull_request workflow for testing * Fix indentation in pull_request.yml --------- Co-authored-by: Mishal Shah <mishal_shah@apple.com>
1 parent b080ab5 commit d65527a

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Proposal Validation
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
project:
7+
type: string
8+
description: "Name of project supported by swift-evolution-metadata-extractor tool"
9+
default: swift
10+
workflow_test_enabled:
11+
type: boolean
12+
description: "Flag to test this workflow within the github-workflows repository"
13+
default: false
14+
15+
jobs:
16+
run-swift-evolution-metadata-extractor:
17+
name: Validate proposals with swift-evolution-metadata-extractor
18+
runs-on: ubuntu-latest
19+
container:
20+
image: "swift:6.2-noble"
21+
timeout-minutes: 10
22+
env:
23+
RESOLVED_PR_NUMBER: ${{ case(inputs.workflow_test_enabled, '3331', github.event.number) }}
24+
steps:
25+
- name: Checkout swiftlang/swift-evolution-metadata-extractor (main)
26+
uses: actions/checkout@v6
27+
with:
28+
repository: swiftlang/swift-evolution-metadata-extractor
29+
ref: main
30+
path: seme
31+
32+
- name: Create cache key
33+
id: cache-key
34+
run: echo "key=seme-$(git -C seme rev-parse HEAD)" >> $GITHUB_OUTPUT
35+
36+
- name: Restore cache
37+
uses: actions/cache/restore@v5
38+
id: restore-cache
39+
with:
40+
path: ${{ github.workspace }}/swift-evolution-metadata-extractor
41+
key: ${{ steps.cache-key.outputs.key }}
42+
43+
- name: Build swift-evolution-metadata-extractor (release)
44+
if: steps.restore-cache.outputs.cache-hit != 'true'
45+
run: |
46+
swift --version
47+
swift build -c release --very-verbose
48+
cp .build/release/swift-evolution-metadata-extractor $GITHUB_WORKSPACE/swift-evolution-metadata-extractor
49+
working-directory: seme
50+
51+
- name: Save to cache
52+
if: steps.restore-cache.outputs.cache-hit != 'true'
53+
id: save-to-cache
54+
uses: actions/cache/save@v5
55+
with:
56+
path: ${{ github.workspace }}/swift-evolution-metadata-extractor
57+
key: ${{ steps.cache-key.outputs.key }}
58+
59+
- name: Validate proposals
60+
run: $GITHUB_WORKSPACE/swift-evolution-metadata-extractor validate --pull-request $RESOLVED_PR_NUMBER

‎.github/workflows/pull_request.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797
api_breakage_check_enabled: false
9898
license_header_check_project_name: "Swift.org"
9999

100+
proposal_validation:
101+
name: Proposal Validation
102+
uses: ./.github/workflows/proposal_validation.yml
103+
with:
104+
project: "swift"
105+
workflow_test_enabled: true
106+
100107
soundness-docs:
101108
name: "Soundness - Docs (override_target_name: ${{ matrix.override_target_name }} ; post command: ${{ matrix.post_command }})"
102109
strategy:

‎README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,38 @@ Linked PR: swiftlang/swift-syntax#2859
9494

9595
Enabling cross-PR testing will add about 10s to PR testing time.
9696

97+
### Evolution Proposal Validation
98+
99+
The proposal validation workflow validates added and changed proposals in a pull request to check for formatting and content errors that will cause metadata extraction to fail or be incomplete.
100+
101+
To accomplish this, the workflow builds the [swift-evolution-metadata-extractor](https://github.com/swiftlang/swift-evolution-metadata-extractor) tool and runs its `validate` command. To minimize validation times, the built tool is cached and only rebuilt when the tool has changed.
102+
103+
To use the proposal validation workflow, add a workflow to the repository that contains the directory of proposals. The calling workflow specifies project-specific details such as the directory where the proposals are located. It is only run if a pull request contains changes in the specified directory.
104+
105+
> [!NOTE]
106+
> The extraction tool currently only supports the evolution proposals of the Swift project at swiftlang/swift-evolution/proposals. The tool and workflow has been designed to be extended to support additional projects in the future.
107+
108+
An example workflow for Swift Testing which uses a subfolder in the swift-evolution repository:
109+
110+
```yaml
111+
name: Validate proposals with swift-evolution-metadata-extractor
112+
113+
on:
114+
pull_request:
115+
types: [opened, reopened, synchronize]
116+
branches:
117+
- 'main'
118+
paths:
119+
- 'proposals/testing/*'
120+
121+
jobs:
122+
validate:
123+
name: Validate Proposals
124+
uses: swiftlang/github-workflows/.github/workflows/proposal_validation.yml@main
125+
with:
126+
project: "testing"
127+
```
128+
97129
## Running workflows locally
98130

99131
You can run the Github Actions workflows locally using

0 commit comments

Comments
 (0)