Skip to content

Commit 54e7ba7

Browse files
authored
chore: Add a CircleCI parameter for target publish-binary branch (#32665)
* chore: migrate trigger publish binary script to bash, use parameterized value for branch - migrates trigger-publish-binary-pipeline.js to an inlined bash script to speed it up and simplify it - adds a pipeline parameter that can be set via CircleCI UI to determine which branch we use in the publish-binary pipeline, to reduce file churn and human error - updates the packages/electron/README.md to include the simplified steps * Update trigger-publish-binary-pipeline.yml * fix continuation json * conflicting parameters? * just need to have them named different * maybe without the params json?
1 parent b3b078b commit 54e7ba7

File tree

5 files changed

+88
-68
lines changed

5 files changed

+88
-68
lines changed

.circleci/config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ workflows:
1212
requires:
1313
- pack-workflows
1414

15+
parameters:
16+
publish-binary-branch:
17+
type: string
18+
default: main
19+
1520
commands:
1621
persist:
1722
steps:
@@ -154,7 +159,3 @@ jobs:
154159
fi
155160
- continuation/continue:
156161
configuration_path: .circleci/packed/pipeline.yml
157-
158-
159-
160-

.circleci/src/pipeline/@pipeline.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ base-internal-yarn-berry: &base-internal-yarn-berry cypress/base-internal:22.19.
1414
# See https://docs.cypress.io/app/get-started/install-cypress#Nodejs
1515
base-internal-minimum-node: &base-internal-minimum-node cypress/base-internal:20.15.0
1616

17+
parameters:
18+
publish-binary-branch:
19+
type: string
20+
default: main
21+
1722
orbs:
1823
browser-tools: circleci/[email protected]
1924

@@ -1364,19 +1369,6 @@ commands:
13641369
paths:
13651370
- cypress/cypress.zip
13661371

1367-
trigger-publish-binary-pipeline:
1368-
steps:
1369-
- run:
1370-
name: "Trigger publish-binary pipeline"
1371-
command: |
1372-
source ./scripts/ensure-node.sh
1373-
echo $SHOULD_PERSIST_ARTIFACTS
1374-
node ./scripts/binary/trigger-publish-binary-pipeline.js
1375-
- persist_to_workspace:
1376-
root: ~/
1377-
paths:
1378-
- triggered_pipeline.json
1379-
13801372
build-cypress-npm-package:
13811373
parameters:
13821374
executor:
@@ -2470,7 +2462,8 @@ jobs:
24702462
- restore_cached_workspace
24712463
- check-if-binary-exists
24722464
- setup_should_persist_artifacts
2473-
- trigger-publish-binary-pipeline
2465+
- trigger-publish-binary-pipeline:
2466+
target-repo-branch: << pipeline.parameters.publish-binary-branch >>
24742467

24752468
get-published-artifacts:
24762469
<<: *defaults
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
parameters:
2+
target-repo-branch:
3+
type: string
4+
default: main
5+
6+
steps:
7+
- run:
8+
name: Trigger publish-binary pipeline
9+
command: |
10+
if [[ -z "$CIRCLE_TOKEN" ]] || \
11+
[[ -z "$CIRCLE_SHA1" ]] || \
12+
[[ -z "$CIRCLE_JOB" ]] || \
13+
[[ -z "$CIRCLE_WORKFLOW_ID" ]] || \
14+
[[ -z "$CIRCLE_BUILD_URL" ]] || \
15+
[[ -z "$CIRCLE_BRANCH" ]]; then
16+
17+
echo "Missing required environment variables. Skipping pipeline trigger."
18+
exit 1
19+
fi
20+
if [[ -n "$SHOULD_PERSIST_ARTIFACTS" && "$SHOULD_PERSIST_ARTIFACTS" != "true" && "$SHOULD_PERSIST_ARTIFACTS" != "false" ]]; then
21+
echo "SHOULD_PERSIST_ARTIFACTS must be true, false, or undefined. Skipping pipeline trigger."
22+
exit 1
23+
fi
24+
if [[ -z $(which node) ]] || [[ -z $(which curl) ]] || [[ -z $(which jq) ]]; then
25+
echo "Missing required commands. Skipping pipeline trigger. Ensure jq, curl, and node are installed."
26+
exit 1
27+
fi
28+
echo "Determining next binary version..."
29+
export NEXT_VERSION=$(node ./scripts/get-next-version.js)
30+
if [[ $? != 0 ]]; then
31+
echo "Failed to determine next binary version. Skipping pipeline trigger."
32+
exit 1
33+
fi
34+
echo "Next binary version: $NEXT_VERSION"
35+
export BODY=$(cat \<<JSON_BODY_EOF
36+
{
37+
"branch": "<< parameters.target-repo-branch >>",
38+
"parameters": {
39+
"temp_dir": "${TMPDIR:-/tmp}",
40+
"sha": "$CIRCLE_SHA1",
41+
"job_name": "$CIRCLE_JOB",
42+
"triggered_workflow_id": "$CIRCLE_WORKFLOW_ID",
43+
"triggered_job_url": "$CIRCLE_BUILD_URL",
44+
"branch": "$CIRCLE_BRANCH",
45+
"should_persist_artifacts": ${SHOULD_PERSIST_ARTIFACTS:-false},
46+
"binary_version": "$NEXT_VERSION"
47+
}
48+
}
49+
JSON_BODY_EOF
50+
)
51+
if [[ $? != 0 ]]; then
52+
echo "Failed to compose the request body. Skipping pipeline trigger."
53+
exit 1
54+
fi
55+
56+
echo "Triggering new pipeline in cypress-publish-binary project on branch << parameters.target-repo-branch >>..."
57+
curl -X POST \
58+
-o ~/triggered_pipeline.json \
59+
-H "Circle-Token: $CIRCLE_TOKEN" \
60+
-H "Content-Type: application/json" \
61+
-d "$BODY" \
62+
https://circleci.com/api/v2/project/github/cypress-io/cypress-publish-binary/pipeline
63+
64+
if [[ $? != 0 ]]; then
65+
echo "Failed to trigger new pipeline. Skipping pipeline trigger."
66+
exit 1
67+
fi
68+
69+
echo "Pipeline saved to triggered_pipeline.json"
70+
echo "Triggered pipeline: https://app.circleci.com/pipelines/github/cypress-io/cypress-publish-binary/$(jq -r '.number' triggered_pipeline.json)"
71+
- persist_to_workspace:
72+
root: ~/
73+
paths:
74+
- triggered_pipeline.json

packages/electron/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ Upgrading `electron` involves more than just bumping this package's `package.jso
176176
- [ ] Update `electron` version in `package.json`
177177
- [ ] Update the target `electron` version in the circle configuration
178178
- [ ] Update the docker image to the new browsers-internal image made in the previous step
179-
- [ ] Temporarily update the circle configuration to allow `cypress` to run against the branch
180-
- [ ] Temporarily set target `cypress-publish-binary` branch as a `branch` property on the request body in [../../scripts/binary/trigger-publish-binary-pipeline.js](../../scripts/binary/trigger-publish-binary-pipeline.js) script, so that you can test against this branch from the electron upgrade branch. This property must be set both at the root of the body object, and on the `parameters` key. If it is not set at the root, the binary pipeline will continue to use the primary branch.
181-
179+
- [ ] Add your branch name to the `&full-workflow-filters` anchor in [`@pipeline.yml`](../../.circleci/src/pipeline/@pipeline.yml)
180+
- [ ] Trigger the pipeline in CircleCI's UI, and set the `publish-binary-branch` parameter to the branch you created in the `cypress-publish-binary` repository.
182181
183182
- [ ] **Manually smoke test `cypress open`.** Upgrading Electron can break the `desktop-gui` in unexpected ways. Since testing in this area is weak, double-check that things like launching `cypress open`, signing into Cypress Cloud, and launching Electron tests still work.
184183
- [ ] **Manually smoke test `cypress run` in record mode** Upgrading Electron can cause `better-sqlite3` to SIGSEGV the Electron process.

scripts/binary/trigger-publish-binary-pipeline.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)