diff --git a/.github/workflows/proposal_validation.yml b/.github/workflows/proposal_validation.yml new file mode 100644 index 00000000..174db4e1 --- /dev/null +++ b/.github/workflows/proposal_validation.yml @@ -0,0 +1,60 @@ +name: Proposal Validation + +on: + workflow_call: + inputs: + project: + type: string + description: "Name of project supported by swift-evolution-metadata-extractor tool" + default: swift + workflow_test_enabled: + type: boolean + description: "Flag to test this workflow within the github-workflows repository" + default: false + +jobs: + run-swift-evolution-metadata-extractor: + name: Validate proposals with swift-evolution-metadata-extractor + runs-on: ubuntu-latest + container: + image: "swift:6.2-noble" + timeout-minutes: 10 + env: + RESOLVED_PR_NUMBER: ${{ case(inputs.workflow_test_enabled, '3331', github.event.number) }} + steps: + - name: Checkout swiftlang/swift-evolution-metadata-extractor (main) + uses: actions/checkout@v6 + with: + repository: swiftlang/swift-evolution-metadata-extractor + ref: main + path: seme + + - name: Create cache key + id: cache-key + run: echo "key=seme-$(git -C seme rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Restore cache + uses: actions/cache/restore@v5 + id: restore-cache + with: + path: ${{ github.workspace }}/swift-evolution-metadata-extractor + key: ${{ steps.cache-key.outputs.key }} + + - name: Build swift-evolution-metadata-extractor (release) + if: steps.restore-cache.outputs.cache-hit != 'true' + run: | + swift --version + swift build -c release --very-verbose + cp .build/release/swift-evolution-metadata-extractor $GITHUB_WORKSPACE/swift-evolution-metadata-extractor + working-directory: seme + + - name: Save to cache + if: steps.restore-cache.outputs.cache-hit != 'true' + id: save-to-cache + uses: actions/cache/save@v5 + with: + path: ${{ github.workspace }}/swift-evolution-metadata-extractor + key: ${{ steps.cache-key.outputs.key }} + + - name: Validate proposals + run: $GITHUB_WORKSPACE/swift-evolution-metadata-extractor validate --pull-request $RESOLVED_PR_NUMBER diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ca1fb654..99d2e0a0 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -97,6 +97,13 @@ jobs: api_breakage_check_enabled: false license_header_check_project_name: "Swift.org" + proposal_validation: + name: Proposal Validation + uses: ./.github/workflows/proposal_validation.yml + with: + project: "swift" + workflow_test_enabled: true + soundness-docs: name: "Soundness - Docs (override_target_name: ${{ matrix.override_target_name }} ; post command: ${{ matrix.post_command }})" strategy: diff --git a/README.md b/README.md index 2bb75bc2..de2f40de 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,38 @@ Linked PR: swiftlang/swift-syntax#2859 Enabling cross-PR testing will add about 10s to PR testing time. +### Evolution Proposal Validation + +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. + +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. + +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. + +> [!NOTE] +> 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. + +An example workflow for Swift Testing which uses a subfolder in the swift-evolution repository: + +```yaml +name: Validate proposals with swift-evolution-metadata-extractor + +on: + pull_request: + types: [opened, reopened, synchronize] + branches: + - 'main' + paths: + - 'proposals/testing/*' + +jobs: + validate: + name: Validate Proposals + uses: swiftlang/github-workflows/.github/workflows/proposal_validation.yml@main + with: + project: "testing" +``` + ## Running workflows locally You can run the Github Actions workflows locally using