Skip to content

Commit 7ddc7bc

Browse files
authored
chore: create Issue when Angular bump fails (#121)
Configure Renovate to create PRs bumping Angular packages in test fixtures, and add a CI workflow to automatically create an Issue when one of these PRs fails. Separately, we'll configure an integration from GitHub Issues to our triage inbox. This allows us to find out proactively when new or upcoming releases may cause regressions, before users are affected. See netlify/remix-compute#355 and netlify/remix-compute#365.
1 parent 51672a2 commit 7ddc7bc

File tree

2 files changed

+129
-9
lines changed

2 files changed

+129
-9
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# We've configured Renovate to open bump PRs for Angular dependencies within our
2+
# test fixtures. This workflow sends notifications when one of these PRs fails.
3+
4+
name: Notify on Angular bump failures
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, labeled, unlabeled]
9+
jobs:
10+
waitForWorkflows:
11+
name: Wait for workflows
12+
runs-on: ubuntu-latest
13+
if: always()
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
20+
- name: Wait for workflows
21+
id: wait
22+
uses: smartcontractkit/chainlink-github-actions/utils/wait-for-workflows@b49a9d04744b0237908831730f8553f26d73a94b
23+
with:
24+
max-timeout: '900'
25+
polling-interval: '30'
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
notify-on-failure:
28+
name: Notify on failure
29+
needs: [waitForWorkflows]
30+
# Note that this doesn't imply success of the workflows themselves, just the waiting.
31+
if: needs.waitForWorkflows.result == 'success'
32+
runs-on: ubuntu-latest
33+
permissions:
34+
issues: write
35+
steps:
36+
- name: Check out the repository
37+
uses: actions/checkout@v4
38+
- name: Check conditions for failure notification
39+
id: check_label
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const { owner, repo } = context.repo;
44+
const sha = context.payload.pull_request.head.sha;
45+
const prNumber = context.payload.pull_request.number;
46+
47+
// Get PR status, which is now settled
48+
const { data: {check_suites: checkSuites} } = await github.rest.checks.listSuitesForRef({
49+
owner,
50+
repo,
51+
ref: sha
52+
});
53+
54+
// Get current PR state and labels
55+
const { data: pullRequest } = await github.rest.pulls.get({
56+
owner,
57+
repo,
58+
pull_number: prNumber,
59+
// Don't filter on `state` here so we can gracefuly handle an "expected" race
60+
// condition (PR closed between trigger and query) but still throw on unexpected errors.
61+
});
62+
if (pullRequest == null) {
63+
core.setFailed("Aborting - cannot find PR corresponding to event trigger");
64+
return;
65+
}
66+
67+
const prIsOpen = pullRequest.state === "open";
68+
// NOTE: Technically, we should query both Check Suites and Commit Statuses.
69+
// We're assuming here that this repo exclusively uses the Checks API.
70+
const prDidFail = checkSuites.some(({conclusion}) =>
71+
conclusion === "failure" || conclusion === "timed_out"
72+
);
73+
// See `renovate.json5` at project root.
74+
const REQUIRED_LABEL = "bump-framework-in-fixtures";
75+
const prHasRequiredLabel = pullRequest.labels.some(label => label.name === REQUIRED_LABEL);
76+
const shouldSendNotification = prIsOpen && prDidFail && prHasRequiredLabel;
77+
core.setOutput("should_send_notif", shouldSendNotification ? "true" : "false");
78+
- name: Create issue on failure
79+
if: ${{ steps.check_label.outputs.should_send_notif == 'true' }}
80+
uses: actions/github-script@v7
81+
with:
82+
script: |
83+
const ISSUE_LABEL = "framework-bump-failure";
84+
const { owner, repo } = context.repo;
85+
const {data: issues} = await github.rest.issues.listForRepo({
86+
owner,
87+
repo,
88+
state: "open",
89+
labels: [ISSUE_LABEL]
90+
});
91+
if (issues.length > 0) {
92+
console.log(`Open issue already exists: ${issues[0].html_url}`);
93+
return;
94+
}
95+
const prUrl = context.payload.pull_request.html_url;
96+
const {data: issue} = await github.rest.issues.create({
97+
owner,
98+
repo,
99+
title: "Possible regression with new framework release",
100+
labels: [ISSUE_LABEL],
101+
body: `A framework release bump in test fixtures has failed. Check ${prUrl}.`
102+
});
103+
console.log(`Created issue: ${issue.html_url}`);

renovate.json5

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
{
2+
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
23
extends: ['github>netlify/renovate-config:default'],
34
ignorePresets: [':prHourlyLimit2'],
45
semanticCommits: true,
5-
dependencyDashboard: true,
6-
automerge: true,
6+
// The config we're extending ignores test dirs, but we want to bump some fixture deps
7+
ignorePaths: ['**/node_modules/**'],
78
packageRules: [
9+
// Since we've enabled Renovate (see above) for fixture sites, adjust the config for these.
810
{
9-
packageNames: [
10-
// Those cannot be upgraded to requiring ES modules
11-
'strip-ansi',
12-
],
13-
major: {
14-
enabled: false,
15-
},
11+
matchFileNames: ['tests/**/fixtures/**/package.json'],
12+
// If a fixture requires a specific framework version, never bump it.
13+
updatePinnedDependencies: false,
14+
// Always use `chore:` (since these are test fixtures), to avoid no-op releases.
15+
extends: [':semanticCommitTypeAll(chore)'],
16+
},
17+
{
18+
description: 'Stable & unstable Angular bumps in test fixtures',
19+
matchFileNames: ['tests/**/fixtures/**/package.json'],
20+
// See https://docs.renovatebot.com/presets-monorepo/#monorepoangular.
21+
matchSourceUrls: ['https://github.com/angular/angular'],
22+
// Override the schedule to get immediate PRs.
23+
schedule: null,
24+
// Apply a unique label so we can trigger additional workflows for these PRs.
25+
addLabels: ['bump-framework-in-fixtures'],
26+
// Bump even if the release isn't tagged as `latest`.
27+
respectLatest: false,
28+
// Bump even if it's a pre-release (e.g. 1.2.3-beta.8).
29+
ignoreUnstable: false,
30+
// Ideally we'd like to disable automerge only for unstable bumps, but this is
31+
// difficult (or impossible) to implement so we just disable it entirely.
32+
automerge: false,
1633
},
1734
],
1835
}

0 commit comments

Comments
 (0)