Skip to content

Commit 4f8786a

Browse files
feat(circleci)!: add a pr-close workflow
BREAKING CHANGE: this workflow requires a repo to be using the Github Apps integration since it references the `pipeline.event` values, which will fail CircleCI config validation if using the OAuth integration
1 parent 9c79de6 commit 4f8786a

File tree

10 files changed

+1624
-6
lines changed

10 files changed

+1624
-6
lines changed

core/cli/test/__snapshots__/config.test.ts.snap

Lines changed: 1544 additions & 4 deletions
Large diffs are not rendered by default.

plugins/circleci-deploy/.toolkitrc.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ options:
1515
command: 'test:staging'
1616
- name: deploy-production
1717
command: 'deploy:production'
18+
- name: teardown-review
19+
command: 'teardown:review'
20+
workspace:
21+
persist: false
22+
custom:
23+
environment:
24+
CIRCLE_BRANCH: << pipeline.event.github.pull_request.head.ref >>
1825
workflows:
1926
- name: 'tool-kit'
2027
jobs:
@@ -85,6 +92,13 @@ options:
8592
!toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId':
8693
aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId'
8794
system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode'
95+
- name: 'pr-close'
96+
jobs:
97+
- name: 'teardown-review'
98+
requires:
99+
- 'setup'
100+
splitIntoMatrix: false
101+
runOnRelease: false
88102
!toolkit/if-defined '@dotcom-tool-kit/circleci.cypressImage':
89103
executors:
90104
- name: cypress

plugins/circleci-deploy/test/__snapshots__/circleci-deploy.test.ts.snap

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ jobs:
1616
- checkout
1717
- tool-kit/persist-workspace:
1818
path: .
19+
teardown-review:
20+
executor: node
21+
steps:
22+
- tool-kit/attach-workspace
23+
- run:
24+
name: teardown-review
25+
command: npx dotcom-tool-kit teardown:review
26+
environment:
27+
CIRCLE_BRANCH: << pipeline.event.github.pull_request.head.ref >>
1928
workflows:
2029
tool-kit:
2130
when:
@@ -116,5 +125,21 @@ workflows:
116125
filters:
117126
branches:
118127
ignore: main
128+
pr-close:
129+
jobs:
130+
- checkout:
131+
requires: []
132+
- tool-kit/setup:
133+
executor: node
134+
requires:
135+
- checkout
136+
- teardown-review:
137+
requires:
138+
- tool-kit/setup
139+
when: >
140+
pipeline.trigger_source != "scheduled_pipeline" and
141+
142+
(pipeline.event.name == "pull_request" and pipeline.event.action ==
143+
"closed")
119144
"
120145
`;

plugins/circleci-deploy/test/circleci-deploy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const logger = winston as unknown as Logger
1010
describe('circleci-deploy', () => {
1111
describe('config integration test', () => {
1212
it('should generate a .circleci/config.yml with the base config from circleci-deploy/.toolkitrc.yml', async () => {
13-
const config = await loadConfig(logger, { root: path.resolve(__dirname, '..') })
13+
const config = await loadConfig(logger, { root: path.resolve(__dirname, 'files', 'configs', 'base') })
1414
const hookInstallationsPromise = loadHookInstallations(logger, config).then((validated) =>
1515
validated.unwrap('hooks were invalid')
1616
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
plugins:
2+
- @dotcom-tool-kit/circleci-deploy

plugins/circleci-npm/test/__snapshots__/circleci-npm.test.ts.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,18 @@ workflows:
8282
executor: node
8383
requires:
8484
- tool-kit/build
85+
pr-close:
86+
jobs:
87+
- checkout:
88+
requires: []
89+
- tool-kit/setup:
90+
executor: node
91+
requires:
92+
- checkout
93+
when: >
94+
pipeline.trigger_source != "scheduled_pipeline" and
95+
96+
(pipeline.event.name == "pull_request" and pipeline.event.action ==
97+
"closed")
8598
"
8699
`;

plugins/circleci/.toolkitrc.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ options:
3232
- name: test
3333
requires:
3434
- 'build'
35+
- name: 'pr-close'
36+
custom:
37+
when: |
38+
pipeline.trigger_source != "scheduled_pipeline" and
39+
(pipeline.event.name == "pull_request" and pipeline.event.action == "closed")
40+
jobs:
41+
- name: 'checkout'
42+
- name: 'setup'
43+
requires:
44+
- 'checkout'
45+
3546

3647
init:
3748
- './lib/init-env-vars'

plugins/circleci/test/__snapshots__/circleci-config.test.ts.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,18 @@ workflows:
7272
executor: node
7373
requires:
7474
- tool-kit/build
75+
pr-close:
76+
jobs:
77+
- checkout:
78+
requires: []
79+
- tool-kit/setup:
80+
executor: node
81+
requires:
82+
- checkout
83+
when: >
84+
pipeline.trigger_source != "scheduled_pipeline" and
85+
86+
(pipeline.event.name == "pull_request" and pipeline.event.action ==
87+
"closed")
7588
"
7689
`;

plugins/circleci/test/circleci-config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ describe('CircleCI config hook', () => {
622622
it('should generate a .circleci/config.yml with the base config from circleci/.toolkitrc.yml', async () => {
623623
// uses a fixture toolkitrc that loads the circleci plugin instead of the circleci toolkitrc
624624
// because option parsing doesn't work if loading the circleci toolkitrc directly
625-
const config = await loadConfig(logger, { root: path.resolve(__dirname, 'files') })
625+
const config = await loadConfig(logger, { root: path.resolve(__dirname, 'files', 'configs', 'base') })
626626

627627
const hookInstallationsPromise = loadHookInstallations(logger, config).then((validated) =>
628628
validated.unwrap('hooks were invalid')

0 commit comments

Comments
 (0)