0

I am trying to have cypress tests run in parallel in codepipeline/codebuild as documented here: https://docs.cypress.io/guides/continuous-integration/aws-codebuild#Parallelizing-the-build I am reading aws docs here: https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list

This is what I have got so far:

import * as cdk from '@aws-cdk/core';
import * as codebuild from '@aws-cdk/aws-codebuild';
import * as iam from '@aws-cdk/aws-iam';

import { defaultEnvironment, NODE_JS_VERSION } from './environments/base-environment';
import { projectEnvironmentVars } from './environments/e2e-tests-project-environment';
// import { createReportGroupJsonObject } from '../../utils/utils';
// import {  Duration } from '@aws-cdk/core'

interface RunTestsProjectProps {
  testsBucketName: string,
  testsBucketArn: string,
  targetEnv: string,
  repoType: string,
  role: iam.Role,
  codeCovTokenArn: string,
}

export class RunTestsProject extends codebuild.PipelineProject {
  constructor(scope: cdk.Construct, id: string, props: RunTestsProjectProps) {
    const { testsBucketName, testsBucketArn, targetEnv, repoType, codeCovTokenArn } = props
    super(scope, id, {
      projectName: id,
      role: props.role,
      environment: defaultEnvironment,
      environmentVariables: projectEnvironmentVars({ testsBucketName, testsBucketArn, targetEnv, repoType, codeCovTokenArn }),
      timeout: cdk.Duration.hours(3),
      buildSpec: codebuild.BuildSpec.fromObject({
        version: '0.2',
        phases: {
          install: {
            'runtime-versions': {
              nodejs: NODE_JS_VERSION
            }
          },
          build: {
            commands: [
              'if [ ! -f "${CODEBUILD_SRC_DIR}/scripts/assume-cross-account-role.env" ]; then echo "assume-cross-account-this.role.env not found in repo" && aws s3 cp s3://${ARTIFACTS_BUCKET_NAME}/admin/cross-account/assume-cross-account-role.env ${CODEBUILD_SRC_DIR}/scripts/; else echo "Overriding assume-cross-account-role.env from repo"; fi',
              '. ${CODEBUILD_SRC_DIR}/scripts/assume-cross-account-role.env',
              'bash ${CODEBUILD_SRC_DIR}/scripts/final-tests.sh'
            ],
            batch: {
              'fail-fast': false,
              'build-list': []
            }
          },
        },
        artifacts: {
          files: '**/*'
        },
      })
    });
  }
}
  1. what should I add in the build-list part to have multiple builds running I tried 'build-list': { identifier: 'build1', identifier: 'build2' }

but this looks like incorrect syntax.

  1. The number of builds should ideally be based on the cypress grouping. Can it be dynamic or has to be defined statically?
systemdebt
  • 4,589
  • 10
  • 55
  • 116

0 Answers0