diff --git a/.circleci/config.yml b/.circleci/config.yml index 44ef265d63f..6fee338656d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,11 @@ orbs: setup: true version: 2.1 +parameters: + publish-binary-branch: + type: string + default: main + workflows: setup-workflow: jobs: @@ -152,7 +157,8 @@ jobs: exit 1 fi - continuation/continue: - configuration_path: .circleci/packed/pipeline.yml + configuration_path: .circleci/packed/pipeline.yml + parameters: '{ "publish-binary-branch": "<< pipeline.parameters.publish-binary-branch >>" }' diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index 1351649f260..08ffb5d2f1e 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -16,6 +16,11 @@ base-internal-minimum-node: &base-internal-minimum-node cypress/base-internal:20 ubuntu-2004-current: &ubuntu-2004-current ubuntu-2004:2024.11.1 ubuntu-2004-older: &ubuntu-2004-older ubuntu-2004:2024.05.1 +parameters: + publish-binary-branch: + type: string + default: main + orbs: browser-tools: circleci/browser-tools@2.3.1 @@ -1366,19 +1371,6 @@ commands: paths: - cypress/cypress.zip - trigger-publish-binary-pipeline: - steps: - - run: - name: "Trigger publish-binary pipeline" - command: | - source ./scripts/ensure-node.sh - echo $SHOULD_PERSIST_ARTIFACTS - node ./scripts/binary/trigger-publish-binary-pipeline.js - - persist_to_workspace: - root: ~/ - paths: - - triggered_pipeline.json - build-cypress-npm-package: parameters: executor: @@ -2474,7 +2466,8 @@ jobs: - restore_cached_workspace - check-if-binary-exists - setup_should_persist_artifacts - - trigger-publish-binary-pipeline + - trigger-publish-binary-pipeline: + target-repo-branch: << pipeline.parameters.publish-binary-branch >> get-published-artifacts: <<: *defaults diff --git a/.circleci/src/pipeline/commands/trigger-publish-binary-pipeline.yml b/.circleci/src/pipeline/commands/trigger-publish-binary-pipeline.yml new file mode 100644 index 00000000000..d0ffffd91a5 --- /dev/null +++ b/.circleci/src/pipeline/commands/trigger-publish-binary-pipeline.yml @@ -0,0 +1,74 @@ +parameters: + target-repo-branch: + type: string + default: main + +steps: + - run: + name: Trigger publish-binary pipeline + command: | + if [[ -z "$CIRCLE_TOKEN" ]] || \ + [[ -z "$CIRCLE_SHA1" ]] || \ + [[ -z "$CIRCLE_JOB" ]] || \ + [[ -z "$CIRCLE_WORKFLOW_ID" ]] || \ + [[ -z "$CIRCLE_BUILD_URL" ]] || \ + [[ -z "$CIRCLE_BRANCH" ]]; then + + echo "Missing required environment variables. Skipping pipeline trigger." + exit 1 + fi + if [[ -n "$SHOULD_PERSIST_ARTIFACTS" && "$SHOULD_PERSIST_ARTIFACTS" != "true" && "$SHOULD_PERSIST_ARTIFACTS" != "false" ]]; then + echo "SHOULD_PERSIST_ARTIFACTS must be true, false, or undefined. Skipping pipeline trigger." + exit 1 + fi + if [[ -z $(which node) ]] || [[ -z $(which curl) ]] || [[ -z $(which jq) ]]; then + echo "Missing required commands. Skipping pipeline trigger. Ensure jq, curl, and node are installed." + exit 1 + fi + echo "Determining next binary version..." + export NEXT_VERSION=$(node ./scripts/get-next-version.js) + if [[ $? != 0 ]]; then + echo "Failed to determine next binary version. Skipping pipeline trigger." + exit 1 + fi + echo "Next binary version: $NEXT_VERSION" + export BODY=$(cat \<>", + "parameters": { + "temp_dir": "${TMPDIR:-/tmp}", + "sha": "$CIRCLE_SHA1", + "job_name": "$CIRCLE_JOB", + "triggered_workflow_id": "$CIRCLE_WORKFLOW_ID", + "triggered_job_url": "$CIRCLE_BUILD_URL", + "branch": "$CIRCLE_BRANCH", + "should_persist_artifacts": ${SHOULD_PERSIST_ARTIFACTS:-false}, + "binary_version": "$NEXT_VERSION" + } + } + JSON_BODY_EOF + ) + if [[ $? != 0 ]]; then + echo "Failed to compose the request body. Skipping pipeline trigger." + exit 1 + fi + + echo "Triggering new pipeline in cypress-publish-binary project on branch << parameters.target-repo-branch >>..." + curl -X POST \ + -o ~/triggered_pipeline.json \ + -H "Circle-Token: $CIRCLE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$BODY" \ + https://circleci.com/api/v2/project/github/cypress-io/cypress-publish-binary/pipeline + + if [[ $? != 0 ]]; then + echo "Failed to trigger new pipeline. Skipping pipeline trigger." + exit 1 + fi + + echo "Pipeline saved to triggered_pipeline.json" + echo "Triggered pipeline: https://app.circleci.com/pipelines/github/cypress-io/cypress-publish-binary/$(jq -r '.number' triggered_pipeline.json)" + - persist_to_workspace: + root: ~/ + paths: + - triggered_pipeline.json diff --git a/packages/electron/README.md b/packages/electron/README.md index 207c291f05b..b8f7ea332b1 100644 --- a/packages/electron/README.md +++ b/packages/electron/README.md @@ -176,9 +176,8 @@ Upgrading `electron` involves more than just bumping this package's `package.jso - [ ] Update `electron` version in `package.json` - [ ] Update the target `electron` version in the circle configuration - [ ] Update the docker image to the new browsers-internal image made in the previous step - - [ ] Temporarily update the circle configuration to allow `cypress` to run against the branch - - [ ] 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. - + - [ ] Add your branch name to the `&full-workflow-filters` anchor in [`@pipeline.yml`](../../.circleci/src/pipeline/@pipeline.yml) + - [ ] 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. - [ ] **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. - [ ] **Manually smoke test `cypress run` in record mode** Upgrading Electron can cause `better-sqlite3` to SIGSEGV the Electron process. diff --git a/scripts/binary/trigger-publish-binary-pipeline.js b/scripts/binary/trigger-publish-binary-pipeline.js deleted file mode 100644 index 05908c2c6d9..00000000000 --- a/scripts/binary/trigger-publish-binary-pipeline.js +++ /dev/null @@ -1,47 +0,0 @@ -const fs = require('fs-extra') -const os = require('os') -const path = require('path') -const fetch = require('node-fetch') -const { getNextVersionForBinary } = require('../get-next-version') - -;(async () => { - const pipelineInfoFilePath = path.join(os.homedir(), 'triggered_pipeline.json') - - const { nextVersion } = await getNextVersionForBinary() - - const body = JSON.stringify({ - // This branch is the branch of the `cypress-publish-binary` repository - // branch: 'main', - parameters: { - temp_dir: os.tmpdir(), - sha: process.env.CIRCLE_SHA1, - job_name: process.env.CIRCLE_JOB, - triggered_workflow_id: process.env.CIRCLE_WORKFLOW_ID, - triggered_job_url: process.env.CIRCLE_BUILD_URL, - // This branch is the branch of the `cypress` repository (which is what `process.env.CIRCLE_BRANCH` returns when running in CircleCI) - branch: process.env.CIRCLE_BRANCH, - should_persist_artifacts: Boolean(process.env.SHOULD_PERSIST_ARTIFACTS), - binary_version: nextVersion, - }, - }) - - try { - console.log('Triggering new pipeline in cypress-publish-binary project...') - const response = await fetch('https://circleci.com/api/v2/project/github/cypress-io/cypress-publish-binary/pipeline', { method: 'POST', headers: { 'Circle-Token': process.env.CIRCLE_TOKEN, 'content-type': 'application/json' }, body }) - const pipeline = await response.json() - - console.log(pipeline) - - console.log(`Triggered pipeline: https://app.circleci.com/pipelines/github/cypress-io/cypress-publish-binary/${pipeline.number}`) - - try { - console.log(`Saving pipeline info in ${pipelineInfoFilePath} ...`) - - await fs.writeFile(path.resolve(pipelineInfoFilePath), JSON.stringify(pipeline)) - } catch (error) { - throw new Error(`error writing triggered pipeline info ${error}`) - } - } catch (error) { - throw new Error(`error triggering new pipeline ${error}`) - } -})()