Skip to content

Commit bae77b0

Browse files
workflow: close PRs with failing CI (#31810)
Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com>
1 parent 7ffd981 commit bae77b0

23 files changed

+669
-58
lines changed

.github/workflows/add-waiting-response-on-fail.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Add waiting-response on failures
33

44
on:
55
workflow_run:
6-
workflows: ['Check for new usages of deprecated functionality', 'GoLang Linting', 'Website Linting', 'Generation Check', 'Validate Examples', 'Unit Tests', 'Terraform Schema Linting', '32 Bit Build', 'Provider Tests', 'Vendor Dependencies Check']
6+
workflows: ['Check for new usages of deprecated functionality', 'GoLang Linting', 'Website Linting', 'Generation Check', 'Validate Examples', 'Unit Tests', 'Terraform Schema Linting', 'Provider Tests', 'Vendor Dependencies Check']
77
types: [completed]
88

99
permissions:

.github/workflows/breaking-change-detection.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ jobs:
2727
with:
2828
go-version-file: ./.go-version
2929
- run: bash ./scripts/run-breaking-change-detection.sh
30+
- name: Guidance on failure
31+
if: failure()
32+
run: |
33+
echo "::error::Breaking Schema Changes detected."
34+
echo ""
35+
echo "Your changes contain breaking schema changes (e.g. removing or renaming"
36+
echo "a property, changing a property type, or making an optional property required)."
37+
echo "Breaking changes must be gated behind the appropriate feature flag (e.g. features.FivePointOh())."
38+
echo "Please review the breaking changes guide: contributing/topics/guide-breaking-changes.md"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Close PRs With Failing CI'
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 6 * * MON,WED,FRI'
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
checks: read
11+
statuses: read
12+
13+
jobs:
14+
close-failing-ci-prs:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
- name: Process PRs with failing CI
19+
run: ./scripts/close-failing-ci-prs.sh -o "${{ github.repository_owner }}" -r "${{ github.event.repository.name }}" -t "${{ secrets.GITHUB_TOKEN }}" -l

.github/workflows/comment-failure.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,31 @@ jobs:
1919
with:
2020
result-encoding: string
2121
script: |
22+
const workflowName = '${{ github.workflow }}';
23+
24+
const guidance = {
25+
'Vendor Dependencies Check': 'Do not modify files in the `vendor/` directory directly. Instead, update dependencies in `go.mod` and run `go mod vendor` to sync the vendor directory. Then run `make depscheck` locally to verify.',
26+
'Website Linting': 'Run `make website-lint` and `make document-validate` locally to check your documentation files under `website/` for formatting or validation issues.',
27+
'Generation Check': 'Run `make generate` locally to regenerate any auto-generated code, then commit the resulting changes.',
28+
'GoLang Linting': 'Run the Go linter locally with `golangci-lint run -v ./internal/...` and fix any reported issues.',
29+
'Terraform Schema Linting': 'Run `make tflint` locally and fix any Terraform schema issues in your resource or data source definitions.',
30+
'Unit Tests': 'Run `make test` locally to reproduce and fix the failing unit tests.',
31+
'ShellCheck Scripts': 'Run `make shellcheck` locally to check shell scripts for issues and fix any warnings or errors.',
32+
'Validate Examples': 'Run `make validate-examples` locally to check that your example Terraform configurations under `examples/` are valid.',
33+
34+
};
35+
36+
let body = `<b>Build failure: ${workflowName}</b>\n\nThis pull request contains a build failure in the <b>${workflowName}</b> check which needs to be addressed [here](${{ env.gha_url }}).`;
37+
38+
if (guidance[workflowName]) {
39+
body += `\n\n<b>How to fix:</b> ${guidance[workflowName]}`;
40+
}
41+
42+
body += `\n\nFor more information, please refer to our [Contributing Guide](https://github.com/${{ github.repository }}/blob/main/contributing/README.md).`;
43+
2244
github.rest.issues.createComment({
23-
issue_number: ${{ github.event.number }},
24-
owner: context.repo.owner,
25-
repo: context.repo.repo,
26-
body: '<b>Build failure</b> \n\n This pull request contains a build failure which needs addressed [here](${{ env.gha_url}}) .'
27-
})
45+
issue_number: ${{ github.event.number }},
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: body
49+
})

.github/workflows/depscheck.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ jobs:
2323
go-version-file: ./.go-version
2424
- run: bash scripts/gogetcookie.sh
2525
- run: make depscheck
26+
- name: Guidance on failure
27+
if: failure()
28+
run: |
29+
echo "::error::Vendor Dependencies Check failed."
30+
echo ""
31+
echo "Do not modify files in the vendor/ directory directly."
32+
echo "Instead, update dependencies in go.mod and run 'go mod tidy && go mod vendor' to sync the vendor directory."
33+
echo "Then run 'make depscheck' locally to verify before pushing."
2634
save-artifacts-on-fail:
2735
needs: depscheck
2836
if: ${{ failure() }}

.github/workflows/gencheck.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ jobs:
2626
go-version-file: ./.go-version
2727
- run: bash scripts/gogetcookie.sh
2828
- run: make gencheck
29+
- name: Guidance on failure
30+
if: failure()
31+
run: |
32+
echo "::error::Generation Check failed."
33+
echo ""
34+
echo "Run 'make generate' locally to regenerate auto-generated code, then commit the changes."
35+
echo "This check ensures that generated files are up to date with their source definitions."
2936
save-artifacts-on-fail:
3037
needs: gencheck
3138
if: ${{ failure() }}

.github/workflows/golint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ jobs:
2929
with:
3030
version: 'v2.4.0'
3131
args: -v ./internal/...
32+
- name: Guidance on failure
33+
if: failure()
34+
run: |
35+
echo "::error::GoLang Linting failed."
36+
echo ""
37+
echo "Run the Go linter locally: golangci-lint run -v ./internal/..."
38+
echo "Fix any reported issues before pushing. Common issues include:"
39+
echo " - Unused variables or imports"
40+
echo " - Error return values not checked"
41+
echo " - Formatting issues (run 'gofmt -w .')"
3242
save-artifacts-on-fail:
3343
needs: golint
3444
if: ${{ failure() }}

.github/workflows/gradually-deprecated.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424
with:
2525
go-version-file: ./.go-version
2626
- run: bash ./scripts/run-gradually-deprecated.sh
27+
- name: Guidance on failure
28+
if: failure()
29+
run: |
30+
echo "::error::New usage of deprecated functionality detected."
31+
echo ""
32+
echo "Your changes introduce new usages of deprecated functions or patterns."
33+
echo "Please use the recommended replacement instead. Check the output above"
34+
echo "for details on which deprecated items were referenced."
2735
save-artifacts-on-fail:
2836
needs: test
2937
if: ${{ failure() }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Label CI Status on PRs'
2+
on:
3+
check_suite:
4+
types: [completed]
5+
6+
permissions:
7+
pull-requests: write
8+
9+
jobs:
10+
label-ci-status:
11+
runs-on: ubuntu-latest
12+
# Only run for PRs, not pushes to branches
13+
if: github.event.check_suite.pull_requests[0] != null
14+
steps:
15+
- name: Add or remove ci-failed label
16+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
17+
with:
18+
script: |
19+
const pullRequests = context.payload.check_suite.pull_requests;
20+
const conclusion = context.payload.check_suite.conclusion;
21+
const label = 'ci-failed';
22+
23+
for (const pr of pullRequests) {
24+
const prNumber = pr.number;
25+
26+
// Get current labels
27+
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
issue_number: prNumber,
31+
});
32+
const hasLabel = currentLabels.some(l => l.name === label);
33+
34+
if (conclusion === 'failure' && !hasLabel) {
35+
console.log(`PR #${prNumber}: CI failed → adding '${label}' label`);
36+
await github.rest.issues.addLabels({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
issue_number: prNumber,
40+
labels: [label],
41+
});
42+
} else if (conclusion === 'success' && hasLabel) {
43+
console.log(`PR #${prNumber}: CI passed → removing '${label}' label`);
44+
await github.rest.issues.removeLabel({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
issue_number: prNumber,
48+
name: label,
49+
});
50+
} else {
51+
console.log(`PR #${prNumber}: conclusion=${conclusion}, hasLabel=${hasLabel} → no action`);
52+
}
53+
}

.github/workflows/preview-api-version-linter.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ jobs:
2222
with:
2323
go-version-file: ./.go-version
2424
- run: go run internal/tools/preview-api-version-linter/main.go
25+
- name: Guidance on failure
26+
if: failure()
27+
run: |
28+
echo "::error::Preview API Version Linter failed."
29+
echo ""
30+
echo "Your changes reference Azure ARM API versions that are in preview."
31+
echo "Preview API versions should not be used unless explicitly required and approved."
32+
echo "Please update the API version references to use GA (stable) versions."
2533
comment-on-fail:
2634
needs: preview-api-version-linter
2735
if: ${{ failure() }}

0 commit comments

Comments
 (0)