Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pr_target privileged run label check for Cypress Actions #1557

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions .github/workflows/cypress-e2e-chrome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,12 @@ on:
branches:
- main
pull_request:
pull_request_target:
types:
- labeled
jobs:
label_check:
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.label_check.outputs.authorized }}
steps:
- name: Check if authorized label is present
id: label_check
run: |
LABEL_NAME="CI Approved"
PR_LABELS=$(jq '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ')
if [[ ${PR_LABELS} =~ ${LABEL_NAME} ]]; then
echo "Authorized label found."
echo "::set-output name=authorized::true"
else
echo "Authorized label not found."
echo "::set-output name=authorized::false"
fi

cypress-e2e-chrome:
name: Cypress E2E Chrome
runs-on: ubuntu-20.04
# Don't run the e2e tests for dependabot prs or if the PR is not labeled as 'safe to test'.
if: |
${{ github.event.pull_request.user.login == 'dependabot[bot]' &&
needs.label_check.outputs.authorized == 'true' }}

# Only run the e2e tests if a maintainer has labeled the PR as 'safe to test'.
needs: [label_check]
runs-on: ubuntu-latest
# Don't run the e2e tests for dependabot prs.
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
timeout-minutes: 15
strategy:
# when one test fails, DO NOT cancel the other
Expand Down
30 changes: 2 additions & 28 deletions .github/workflows/cypress-e2e-firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,12 @@ on:
branches:
- main
pull_request:
pull_request_target:
types:
- labeled
jobs:
label_check:
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.label_check.outputs.authorized }}
steps:
- name: Check if authorized label is present
id: label_check
run: |
LABEL_NAME="CI Approved"
PR_LABELS=$(jq '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ')
if [[ ${PR_LABELS} =~ ${LABEL_NAME} ]]; then
echo "Authorized label found."
echo "::set-output name=authorized::true"
else
echo "Authorized label not found."
echo "::set-output name=authorized::false"
fi

cypress-e2e-firefox:
name: Cypress E2E Firefox
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# Don't run the e2e tests for dependabot prs or if the PR is not labeled as 'safe to test'.
if: |
${{ github.event.pull_request.user.login == 'dependabot[bot]' &&
needs.label_check.outputs.authorized == 'true' }}

# Only run the e2e tests if a maintainer has labeled the PR as 'safe to test'.
needs: [label_check]
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
timeout-minutes: 15
strategy:
# when one test fails, DO NOT cancel the other
Expand Down
7 changes: 7 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export default defineConfig({
return launchOptions;
}

if (browser.name === 'chrome' && browser.isHeadless) {
const headlessIndex = launchOptions.args.indexOf('--headless');
if (headlessIndex > -1) {
launchOptions.args[headlessIndex] = '--headless=new';
}
}

// whatever you return here becomes the launchOptions
return launchOptions;
});
Expand Down
Loading