0

I'm trying to configure Parralel testing on AWS with Cypress. I have read the documentation from here and here, but nothing seems to work.

In my Buildspec I have the following:

## buildspec.yml
version: 0.2

env:
  variables:
    S3_BUCKET: {...}
    SLACK_WEBHOOK: {...}
  parameter-store:
    CYPRESS_EMAIL: {...}
    CYPRESS_LOGINURL: {...}
    CYPRESS_MYPWD: {...}

## AWS CodeBuild Batch configuration
## https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html
batch:
  fast-fail: false
  build-list:
    - identifier: {...}
      env:
        variables:
          IMAGE: public.ecr.aws/cypress-io/cypress/browsers:node14.17.0-chrome88-ff89
  build-matrix:
    static:
      ignore-failure: false
      env:
        type: LINUX_CONTAINER
        privileged-mode: true
        compute-type: BUILD_GENERAL1_MEDIUM
    dynamic:
      env:
        compute-type:
          - BUILD_GENERAL1_MEDIUM
        image:
          - public.ecr.aws/cypress-io/cypress/browsers:node14.17.0-chrome88-ff89
        variables:
          CY_GROUP_SPEC:
            - "Machine 1|chrome|cypress/e2e/account-access/*"
            - "Machine 2|chrome|cypress/e2e/settings/*"
            - "Machine 3|chrome|cypress/tests/mail-accounts/*"
          WORKERS:
            - 1
            - 2
            - 3
phases:
  install:
    runtime-versions:
      nodejs: latest
    commands:
      - echo $CY_GROUP_SPEC
      - CY_GROUP=$(echo $CY_GROUP_SPEC | cut -d'|' -f1)
      - CY_BROWSER=$(echo $CY_GROUP_SPEC | cut -d'|' -f2)
      - CY_SPEC=$(echo $CY_GROUP_SPEC | cut -d'|' -f3)
      - npm i
  pre_build:
    commands:
      - TIME=$(date +"%Y%m%d_%H%M%S")
      - sudo apt-get update -y && apt-get install jq -y
  build:
    on-failure: CONTINUE
    commands:
      - curl -X POST --data-urlencode "payload={\"channel\":\"#qa-notifications\",\"username\":\"mailshake-qa\",\"text\":\"Cypress tests starting...\",\"icon_emoji\":\":star:\"}" ${SLACK_WEBHOOK}
      - npx cypress run --record --key {...} --parallel --browser "$CY_BROWSER" --ci-build-id $CODEBUILD_INITIATOR --group "$CY_GROUP" --spec "$CY_SPEC"

  post_build:
    commands:
{...}

When I run cypress on AWS it seems CY_GROUP_SPEC: is being ignore, and I get in return empty strings. enter image description here

Any help?

  • I checked the indentation, and it looks good
  • I checked into this AWS documentation about having multiple buildspec

1 Answers1

0

My solution to this was the following:

On AWS CodeBuild, do the following:

  • Navigate to the CodeBuild console
  • Select the project
  • Click "Edit" -- > "Batch Configuration"
  • Create "New service Role" -- enter the name
  • Leave everything optional
  • Click "Update batch configuration"
  • Start the Build

Then, do the following:

  • Navigate to the Pipeline
  • Select my Cypress Pipeline
  • Click "Edit"
  • Click on "Edit" button for my "Build" stage
  • Click on "Edit" button for my specific build {In this case, I only have one build stage}
  • And then set Build type to "Batch build" and turn on the checkbox "Combine all artifacts from batch into a single location"

You will have to update the WORKER in your YML by leaving only - 1 not multiple WORKERS as is indicated in Cypress documentation, otherwise, the same test will run multiple times. More info here