You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For cloud recordings, the app uses data from the execution environment to supplement data it collects from git directly to decorate the recorded run. For the case of GitHub Actions, one of the environment variables we read to determine the current branch name (GITHUB_REF) provides unexpected values. See the following table, which contains environment data for a branch named gha-testing triggered for different event types:
GITHUB_EVENT_NAME
GITHUB_REF
GITHUB_REF_NAME
GITHUB_HEAD_REF
push
refs/heads/gha-testing
gha-testing
N/A (unset for push)
pull_request
refs/pull/13/merge
13/merge
gha-testing
Notice that the GITHUB_REF value, regardless of the triggering event, is always a refs/* value that doesn't accurately represent the branch as labeled (gha-testing).
Desired behavior
The app should utilize other variables available to it to record the true branch name, whenever possible.
To accomplish this, I propose the app should read the following environment variables, in order of precedence:
GH_BRANCH - This is the current prioritized value. It is conditionally set by the Cypress github-action. When it is set, the value is correct, so I don't see a reason to remove/reorder its position in our logic for anyone else that may be utilizing it as an override.
GITHUB_HEAD_REF - This env is set for pull_request-related workflow events. In these cases, it holds the desired HEAD branch value. It is otherwise unset.
GITHUB_REF_NAME - This env is set for all branch-related workflows, but is most relevant for non-pull_request-related workflows. In these cases, the value is the true HEAD branch value. This value can also be used as the last check, as there is no other environment variable that could provide us with more accurate data at this time.
In summary, we should update the logic here to be:
See some sample output from the commit-info package at recording time for a pull_request triggered workflow. You'll notice the null branch value in the collected data, which causes the fallback logic described above to come into play.
We have also had some discussion related to normalizing the environment's raw git data and environment variables within the recording service directly, essentially offloading the offending logic here into the cloud. This would give Cypress a better avenue to respond to changes in the various CI environments in the future without requiring a specific app release. A spike has been logged internally to investigate that option and any potential tradeoffs. The proposal described above seems like a quick enough win to get the correct data recorded in the meantime.
The text was updated successfully, but these errors were encountered:
Current behavior
For cloud recordings, the app uses data from the execution environment to supplement data it collects from git directly to decorate the recorded run. For the case of GitHub Actions, one of the environment variables we read to determine the current branch name (
GITHUB_REF
) provides unexpected values. See the following table, which contains environment data for a branch namedgha-testing
triggered for different event types:push
push
)pull_request
Notice that the
GITHUB_REF
value, regardless of the triggering event, is always arefs/*
value that doesn't accurately represent the branch as labeled (gha-testing
).Desired behavior
The app should utilize other variables available to it to record the true branch name, whenever possible.
To accomplish this, I propose the app should read the following environment variables, in order of precedence:
GH_BRANCH
- This is the current prioritized value. It is conditionally set by the Cypress github-action. When it is set, the value is correct, so I don't see a reason to remove/reorder its position in our logic for anyone else that may be utilizing it as an override.GITHUB_HEAD_REF
- This env is set for pull_request-related workflow events. In these cases, it holds the desired HEAD branch value. It is otherwise unset.GITHUB_REF_NAME
- This env is set for all branch-related workflows, but is most relevant for non-pull_request-related workflows. In these cases, the value is the true HEAD branch value. This value can also be used as the last check, as there is no other environment variable that could provide us with more accurate data at this time.In summary, we should update the logic here to be:
Test code to reproduce
See the environment output from my repository's workflow executions:
pull_request
event - https://github.com/tbiethman/cypress-test-tiny/actions/runs/5649844024/job/15305027983#step:8:16push
event - https://github.com/tbiethman/cypress-test-tiny/actions/runs/5649843632/job/15305026829#step:8:16Cypress Version
Current (all way back to v2.2.4)
Node version
v16.16.0
Operating System
Ubuntu 22.04.2 (in a GitHub Action workflow)
Debug Logs
See some sample output from the
commit-info
package at recording time for apull_request
triggered workflow. You'll notice thenull
branch value in the collected data, which causes the fallback logic described above to come into play.Other
We have also had some discussion related to normalizing the environment's raw git data and environment variables within the recording service directly, essentially offloading the offending logic here into the cloud. This would give Cypress a better avenue to respond to changes in the various CI environments in the future without requiring a specific app release. A spike has been logged internally to investigate that option and any potential tradeoffs. The proposal described above seems like a quick enough win to get the correct data recorded in the meantime.
The text was updated successfully, but these errors were encountered: