-
Notifications
You must be signed in to change notification settings - Fork 9
ci: add smart PR workflow automation #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndycode
wants to merge
38
commits into
main
Choose a base branch
from
ci/pr-workflow-automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
caee20e
ci: add smart PR workflow automation
ndycode d4ca444
ci: split required PR validation lanes
ndycode ed57187
ci: address PR review edge cases
ndycode 4d90271
ci: harden docs-check markdown parsing
ndycode 76b4d7f
test: cover docs-check link validation
ndycode b3dce2c
fix: tighten docs-check and advisory PR lanes
ndycode 18ec2e3
fix: bound workflow gates and test temp roots
ndycode 0d2c612
fix: harden PR governance and docs checks
ndycode 3c1de9f
fix: tighten docs-check root boundaries
ndycode 44e2b19
fix: add workflow timeout guards
ndycode 08226fb
fix: scope workflow badge checks
ndycode f1a8dfc
fix: address docs check review follow-ups
ndycode 4f2df69
fix: ignore html comment links in docs check
ndycode ec4e852
Add CI timeout and clarify advisory/test intent
ndycode f3338da
Run docs-sanity when CI scripts change
ndycode b949784
Harden docs-check link validation contract
ndycode df1bc68
Add Windows advisory compat lane
ndycode 38fe3c3
Harden PR governance verification gating
ndycode e4e16fd
Cover docs-check discovery paths and clear stale live labels
ndycode effb3a0
Pin pr governance action and decode docs links
ndycode 98d09be
Tighten stale live label cleanup
ndycode 3b726f4
Pin workflow action tags and cover empty docs run
ndycode 70247a9
Pin advisory artifact action and cover docs failures
ndycode 45f2bb2
Harden docs-check portability and CI routing
ndycode 66bf42c
Tighten CI review follow-ups
ndycode e02bb4b
chore: tighten workflow review edge cases
ndycode c16622f
chore: isolate governance event concurrency
ndycode 8288daf
ci: harden PR review follow-ups
ndycode 85895c4
ci: summarize advisory compat failures
ndycode 1e96992
ci: harden governance body parsing
ndycode f305221
ci: harden governance body parsing
ndycode d16b767
test: cover shortcut docs references
ndycode 64afc50
test: tighten shortcut reference parsing
ndycode 2681483
ci: serialize PR governance runs
ndycode 4d1be96
ci: harden governance fence parsing
ndycode 19dabaf
ci: fix governance and docs-check edge cases
ndycode 3a967e1
fix: harden governance summary and docs-check retries
ndycode d4974b5
Harden docs-check fence parsing
ndycode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,335 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| merge_group: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| CI: true | ||
| HUSKY: 0 | ||
|
|
||
| jobs: | ||
| changes: | ||
| name: Detect changes | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| outputs: | ||
| code_changed: ${{ steps.detect.outputs.code_changed }} | ||
| docs_changed: ${{ steps.detect.outputs.docs_changed }} | ||
| workflow_changed: ${{ steps.detect.outputs.workflow_changed }} | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Classify changed files | ||
| id: detect | ||
| shell: bash | ||
| env: | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| BASE_REF: ${{ github.base_ref }} | ||
| BEFORE_SHA: ${{ github.event.before }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| docs_changed=false | ||
| code_changed=false | ||
| workflow_changed=false | ||
| files=() | ||
|
|
||
| collect_changed_files() { | ||
| local range="$1" | ||
|
|
||
| while IFS=$'\t' read -r status first_path second_path; do | ||
| [[ -z "${status}" ]] && continue | ||
|
|
||
| case "${status}" in | ||
| R*|C*) | ||
| [[ -n "${first_path}" ]] && files+=("${first_path}") | ||
| [[ -n "${second_path}" ]] && files+=("${second_path}") | ||
| ;; | ||
| *) | ||
| [[ -n "${first_path}" ]] && files+=("${first_path}") | ||
| ;; | ||
| esac | ||
| done < <(git diff --find-renames --name-status "${range}") | ||
| } | ||
|
|
||
| if [[ "${EVENT_NAME}" == "pull_request" ]]; then | ||
| git fetch --no-tags --depth=1 origin "${BASE_REF}" | ||
| collect_changed_files "origin/${BASE_REF}...HEAD" | ||
| elif [[ "${EVENT_NAME}" == "push" && -n "${BEFORE_SHA}" && "${BEFORE_SHA}" != "0000000000000000000000000000000000000000" ]]; then | ||
| collect_changed_files "${BEFORE_SHA}...HEAD" | ||
| else | ||
| # No reliable diff range is available on this event. docs_changed and | ||
| # code_changed are forced below, and workflow_changed intentionally | ||
| # stays false unless an actual diff classified workflow files. | ||
| : | ||
| fi | ||
|
|
||
| for file in "${files[@]}"; do | ||
| [[ -z "${file}" ]] && continue | ||
| is_docs_markdown=false | ||
|
|
||
| if [[ "${file}" =~ ^(README\.md|CONTRIBUTING\.md|CHANGELOG\.md|SECURITY\.md)$ ]] || [[ "${file}" =~ ^(\.github|config|docs|test)/.+\.(md|markdown)$ ]]; then | ||
| docs_changed=true | ||
| is_docs_markdown=true | ||
| fi | ||
|
|
||
| case "${file}" in | ||
| scripts/ci/*) | ||
| docs_changed=true | ||
| code_changed=true | ||
| ;; | ||
| .github/workflows/*) | ||
| workflow_changed=true | ||
| code_changed=true | ||
| ;; | ||
| *) | ||
| if [[ "${is_docs_markdown}" != "true" ]]; then | ||
| code_changed=true | ||
| fi | ||
| ;; | ||
| esac | ||
| done | ||
greptile-apps[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if [[ "${EVENT_NAME}" != "pull_request" ]]; then | ||
| # Run full docs/code lanes on non-PR events, but keep workflow_changed | ||
| # diff-based so actionlint only runs when workflow files actually change. | ||
| docs_changed=true | ||
| code_changed=true | ||
| fi | ||
ndycode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| { | ||
| echo "docs_changed=${docs_changed}" | ||
| echo "code_changed=${code_changed}" | ||
| echo "workflow_changed=${workflow_changed}" | ||
| } >> "${GITHUB_OUTPUT}" | ||
|
|
||
| lint: | ||
| name: lint | ||
| needs: changes | ||
| if: needs.changes.outputs.code_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Lint | ||
| run: npm run lint | ||
|
|
||
| typecheck: | ||
| name: typecheck | ||
| needs: changes | ||
| if: needs.changes.outputs.code_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Type check | ||
| run: npm run typecheck | ||
|
|
||
| build: | ||
| name: build | ||
| needs: changes | ||
| if: needs.changes.outputs.code_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| unit-linux: | ||
| name: unit (linux) | ||
| needs: changes | ||
| if: needs.changes.outputs.code_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run tests | ||
| run: npm test | ||
|
|
||
| unit-windows: | ||
| name: unit (windows) | ||
| needs: changes | ||
| if: needs.changes.outputs.code_changed == 'true' | ||
| runs-on: windows-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run tests | ||
| run: npm test -- --reporter=verbose | ||
|
|
||
| docs-sanity: | ||
| name: docs-sanity | ||
| needs: changes | ||
| if: needs.changes.outputs.docs_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
|
|
||
| # docs-check.js is intentionally limited to Node built-ins, so this lane can skip npm ci. | ||
| - name: Verify markdown links and CI badge targets | ||
| run: npm run docs:check | ||
ndycode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| actionlint: | ||
| name: actionlint | ||
| needs: changes | ||
| if: needs.changes.outputs.workflow_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Lint GitHub Actions workflows | ||
| uses: docker://rhysd/actionlint@sha256:5457037ba91acd225478edac3d4b32e45cf6c10291e0dabbfd2491c63129afe1 # rhysd/actionlint:1.7.11 linux/amd64 | ||
| with: | ||
| args: -color | ||
|
|
||
| required-pr: | ||
| name: required-pr | ||
| needs: | ||
| - changes | ||
| - lint | ||
| - typecheck | ||
| - build | ||
| - unit-linux | ||
| - unit-windows | ||
| - docs-sanity | ||
| - actionlint | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Evaluate required checks | ||
| shell: bash | ||
| env: | ||
| CHANGES_RESULT: ${{ needs.changes.result }} | ||
| CODE_CHANGED: ${{ needs.changes.outputs.code_changed }} | ||
| DOCS_CHANGED: ${{ needs.changes.outputs.docs_changed }} | ||
| WORKFLOW_CHANGED: ${{ needs.changes.outputs.workflow_changed }} | ||
| LINT_RESULT: ${{ needs.lint.result }} | ||
| TYPECHECK_RESULT: ${{ needs.typecheck.result }} | ||
| BUILD_RESULT: ${{ needs.build.result }} | ||
| UNIT_LINUX_RESULT: ${{ needs.unit-linux.result }} | ||
| UNIT_WINDOWS_RESULT: ${{ needs.unit-windows.result }} | ||
| DOCS_RESULT: ${{ needs.docs-sanity.result }} | ||
| ACTIONLINT_RESULT: ${{ needs.actionlint.result }} | ||
| run: | | ||
| set -euo pipefail | ||
| failures=() | ||
|
|
||
| if [[ "${CHANGES_RESULT}" != "success" ]]; then | ||
| echo "Changes detection job did not succeed (result: ${CHANGES_RESULT}). Failing gate." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${CODE_CHANGED}" == "true" && "${LINT_RESULT}" != "success" ]]; then | ||
| failures+=("lint") | ||
| fi | ||
|
|
||
| if [[ "${CODE_CHANGED}" == "true" && "${TYPECHECK_RESULT}" != "success" ]]; then | ||
| failures+=("typecheck") | ||
| fi | ||
|
|
||
| if [[ "${CODE_CHANGED}" == "true" && "${BUILD_RESULT}" != "success" ]]; then | ||
| failures+=("build") | ||
| fi | ||
|
|
||
| if [[ "${CODE_CHANGED}" == "true" && "${UNIT_LINUX_RESULT}" != "success" ]]; then | ||
| failures+=("unit-linux") | ||
| fi | ||
|
|
||
| if [[ "${CODE_CHANGED}" == "true" && "${UNIT_WINDOWS_RESULT}" != "success" ]]; then | ||
| failures+=("unit-windows") | ||
| fi | ||
|
|
||
| if [[ "${DOCS_CHANGED}" == "true" && "${DOCS_RESULT}" != "success" ]]; then | ||
| failures+=("docs-sanity") | ||
| fi | ||
|
|
||
| if [[ "${WORKFLOW_CHANGED}" == "true" && "${ACTIONLINT_RESULT}" != "success" ]]; then | ||
| failures+=("actionlint") | ||
| fi | ||
|
|
||
| if [[ ${#failures[@]} -gt 0 ]]; then | ||
| echo "Required checks failed: ${failures[*]}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "All required PR checks passed." | ||
greptile-apps[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.