Fix open release pr for CORE after tests #5617
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E | |
on: | |
pull_request: | |
types: [edited, labeled] | |
jobs: | |
get-selected-tags-and-containers: | |
if: ${{ contains(github.event.pull_request.labels.*.name, 'run e2e') }} | |
runs-on: ubuntu-latest | |
outputs: | |
tags: ${{steps.get_tags.outputs.result}} | |
containers: ${{ steps.get_containers.outputs.result}} | |
steps: | |
- name: Get tags | |
id: get_tags | |
uses: actions/github-script@v6 | |
env: | |
pullRequestBody: ${{ github.event.pull_request.body }} | |
with: | |
result-encoding: string | |
script: | | |
const { pullRequestBody } = process.env | |
const tags = ["@critical"]; | |
try{ | |
const removedPullRequestBodyBeforeTests = pullRequestBody.split(`### Do you want to run more stable tests?`); | |
const removedPullRequestBodyAfterTests = removedPullRequestBodyBeforeTests[1].split(`CONTAINERS`); | |
let tagsInString = removedPullRequestBodyAfterTests[0]; | |
tagsInString = tagsInString.split('\n'); | |
tagsInString.forEach(line => { | |
if (line.includes('[x]')) tags.push(line.replace(/[0-9]+\. \[x\] /, "@stable+@")) | |
}); | |
const tagsToReturn = tags.join(",").toString(); | |
return tagsToReturn.replace(/\r/g, '') | |
}catch{ | |
return '@critical' | |
} | |
- name: get-containers | |
id: get_containers | |
uses: actions/github-script@v6 | |
env: | |
pullRequestBody: ${{ github.event.pull_request.body }} | |
with: | |
script: | | |
const { pullRequestBody } = process.env | |
const containers = []; | |
const numberOfContainersRegex = /CONTAINERS=(\d*)/ | |
const numberOfContainers = pullRequestBody.match(numberOfContainersRegex); | |
for(let i=1; i<=numberOfContainers[1]; i++){ | |
containers.push(i) | |
} | |
return {"containers": containers} | |
install-cypress: | |
needs: get-selected-tags-and-containers | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Wait for Deploy and tests | |
uses: lewagon/[email protected] | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
running-workflow-name: e2e | |
check-name: deploy | |
wait-interval: 10 | |
- name: Cypress install | |
uses: cypress-io/github-action@v4 | |
with: | |
# Disable running of tests within install job | |
runTests: false | |
run-tests-in-parallel-on-label: | |
needs: [get-selected-tags-and-containers, install-cypress] | |
runs-on: ubuntu-latest | |
env: | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
container: cypress/browsers:node18.12.0-chrome106-ff106 | |
strategy: | |
fail-fast: false | |
max-parallel: 10 | |
matrix: | |
${{ fromJson(needs.get-selected-tags-and-containers.outputs.containers) }} | |
# run copies of the current job in parallel | |
steps: | |
- uses: rlespinasse/[email protected] | |
- name: Set domain | |
id: set-domain | |
run: | | |
echo "domain=${{ env.GITHUB_HEAD_REF_SLUG_URL }}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT | |
## backward compatibility for older versions | |
- name: Get API_URI | |
id: api_uri | |
# Search for API_URI in PR description and use default if not defined | |
env: | |
pull_request_body: ${{ github.event.pull_request.body }} | |
prefix: API_URI= | |
pattern: (http|https)://[a-zA-Z0-9.-]+/graphql/? | |
fallback_uri: ${{ secrets.CYPRESS_API_URI }} | |
run: | | |
echo "custom_api_uri=$(echo "$pull_request_body" | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1 | { read custom_uri; if [ -z "$custom_uri" ]; then echo "$fallback_uri"; else echo "$custom_uri"; fi })" >> $GITHUB_OUTPUT | |
- name: Get API_URL | |
id: api_url | |
env: | |
pull_request_body: ${{ github.event.pull_request.body }} | |
prefix: API_URL= | |
pattern: (http|https)://[a-zA-Z0-9.-]+/graphql/? | |
fallback_uri: ${{ secrets.CYPRESS_API_URL }} | |
run: | | |
echo "custom_api_url=$(echo "$pull_request_body" | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1 | { read custom_url; if [ -z "$custom_url" ]; then echo "$fallback_url"; else echo "$custom_url"; fi })" >> $GITHUB_OUTPUT | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Cypress run | |
uses: cypress-io/github-action@v4 | |
env: | |
## backward compatibility for older versions | |
API_URI: ${{ steps.api_uri.outputs.custom_api_uri }} | |
API_URL: ${{ steps.api_url.outputs.custom_api_url }} | |
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} | |
BASE_URL: https://${{ steps.set-domain.outputs.domain }}/ | |
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} | |
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} | |
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} | |
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }} | |
COMMIT_INFO_MESSAGE: ${{ needs.get-selected-tags-and-containers.outputs.tags }} tests triggered on PR - https://github.com/${{ github.repository }}/pull/${{ github.ref_name }} | |
CYPRESS_grepTags: ${{ needs.get-selected-tags-and-containers.outputs.tags }} | |
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }} | |
with: | |
parallel: true | |
group: "UI - Chrome" | |
record: true | |
tag: e2eTestsOnPR |