Skip to content

feat: allow recording in fork with secrets#751

Merged
mjhenkes merged 2 commits into
cypress-io:masterfrom
MikeMcC399:feat/record-in-fork-rev2
Mar 7, 2023
Merged

feat: allow recording in fork with secrets#751
mjhenkes merged 2 commits into
cypress-io:masterfrom
MikeMcC399:feat/record-in-fork-rev2

Conversation

@MikeMcC399

@MikeMcC399 MikeMcC399 commented Jan 27, 2023

Copy link
Copy Markdown
Collaborator

This PR resolves the issue #693 "Workflows using Cypress Cloud fail in fork". It builds on the draft PR "Record to Cypress Cloud in fork" #694 implementing suggestions from that PR to cover additionally the default case where a fork user has no Cypress Cloud project defined.

Scenario Project ID Record Key Result
main repo from config file from GH secret recording runs
fork, no Cloud project from config file no GH secret recording skipped
fork, with Cloud project from GH secret from GH secret recording runs

By default, when a user creates a fork, actions are disabled. If the user enables actions and makes no other changes then previously the two recording workflows would fail:

This PR adds an extra job check-record-key to check for the existence of secrets.EXAMPLE_RECORDING_KEY. This allows recording jobs in the workflows to be skipped if the prerequisite Cypress Cloud recording key is not present. This logic is necessary because jobs.<job_id>.if does not recognise the secrets context (see GH Actions: Context).

A regular user has only read access to the Cypress.io organization's Cypress Cloud public project https://cloud.cypress.io/projects/3tb7jn/, so the workflows need a convenient way to provide an alternative project ID for recording in a fork.

This is achieved by allowing a user's individual Cypress Cloud project ID to be defined as a GH secret. In this way a user can override the main repo's Cloud project ID without requiring any modifications to files in the fork

@MikeMcC399

This comment was marked as outdated.

@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

Recording jobs are correctly skipped because a PR from a fork has no access to secrets, neither to its own, nor to the secrets of the parent repository. It's in "no-mans land"!

The logs show
Secret source: None

@jaffrepaul jaffrepaul added the type: enhancement New feature or request label Jan 30, 2023
@MikeMcC399 MikeMcC399 force-pushed the feat/record-in-fork-rev2 branch from 07c13ea to 012e103 Compare February 2, 2023 06:46
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

@jennifer-shehane

I took your comments from #694 (review) on board and reworked the PR. You are welcome to review it.

It is backwards compatible, prevents unwanted fork failures and allows users to incorporate their own Cypress Cloud project more easily into the examples without forcing anyone, such as a fix submitter, to do so.

@MikeMcC399 MikeMcC399 marked this pull request as ready for review February 2, 2023 06:54
@MikeMcC399 MikeMcC399 force-pushed the feat/record-in-fork-rev2 branch 2 times, most recently from cb4080a to a378caf Compare February 10, 2023 12:40
@MikeMcC399 MikeMcC399 force-pushed the feat/record-in-fork-rev2 branch from a378caf to 4129cda Compare February 14, 2023 12:46
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

@jaffrepaul / @jennifer-shehane

@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

@nagash77
Will you also add this PR to your process? I'm unsure if @jaffrepaul or @jennifer-shehane are still actively involved.

@mjhenkes mjhenkes self-assigned this Mar 2, 2023
@MikeMcC399 MikeMcC399 changed the title Record to Cypress Cloud in fork (Rev2) feat: allow recording in fork with secrets Mar 2, 2023
@MikeMcC399 MikeMcC399 force-pushed the feat/record-in-fork-rev2 branch from bb5782a to 26bf903 Compare March 3, 2023 20:40
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

squashed and rebased for clarity of commit history

@mjhenkes mjhenkes merged commit 7eaec0d into cypress-io:master Mar 7, 2023
@github-actions

github-actions Bot commented Mar 7, 2023

Copy link
Copy Markdown

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MikeMcC399 MikeMcC399 deleted the feat/record-in-fork-rev2 branch March 7, 2023 14:13
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

@mjhenkes / @jaffrepaul

Thanks for merging this PR!

Version 5.2.0 has been correctly published to https://www.npmjs.com/package/@cypress/github-action/v/5.2.0

The GitHub Marketplace https://github.com/marketplace/actions/cypress-io however still shows the previous version, 5.1.0. Publishing to the GitHub Marketplace is a manual process (see https://github.com/cypress-io/github-action/blob/master/DEVELOPMENT.md#updating-the-latest-version-in-github-marketplace). Will you follow up?

@mjhenkes

mjhenkes commented Mar 8, 2023

Copy link
Copy Markdown
Contributor

@MikeMcC399, updated, thanks for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants