Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

How to configure tests stage in the pipeline to use BatchBuild from Codebuild and create multiple instances #76

Open
s1mrankaur opened this issue Dec 6, 2021 · 1 comment

Comments

@s1mrankaur
Copy link

I am trying to run cypress tests in parallel. I stumbled on a buildspec yml file https://github.com/cypress-io/cypress-realworld-app/blob/develop/buildspec.yml that configures code build to spring multiple coordinated instances however I am lost as to how to translate this to CDK.

Is there an example I can follow?

@s1mrankaur
Copy link
Author

Commenting to bump @srijitm @gmansilla @hyandell @richardhu2013

I added:

const TestsAction = new codepipelineactions.CodeBuildAction({
      actionName: 'Run-Tests',
      outputs: [TestsArtifact],
      input: repoType === 'backend' ? testsDownloadArtifact : buildOutputArtifact,
      project: endToEndTestsProject,
      executeBatchBuild: true,
      combineBatchBuildArtifacts: true
    });

In Pipeline project,



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',
        batch: {
          'fast-fail': false,
          'build-list': [
            {
              'identifier': 'build_1'
            },
            {
              'identifier': 'build_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'
            ],
          },
        },
        artifacts: {
          files: '**/*'
        },
      })
    });
  }
}

Is there anything additional I need to se


[Container] 2022/09/20 00:17:08 Waiting for agent ping
--
2 | [Container] 2022/09/20 00:17:09 Waiting for DOWNLOAD_SOURCE
3 | [Container] 2022/09/20 00:19:23 Phase is DOWNLOAD_SOURCE
4 | [Container] 2022/09/20 00:19:24 CODEBUILD_SRC_DIR=/codebuild/output/src235984233/src
5 | [Container] 2022/09/20 00:19:24 YAML location is /codebuild/readonly/buildspec.yml
6 | [Container] 2022/09/20 00:19:26 Phase complete: DOWNLOAD_SOURCE State: FAILED
7 | [Container] 2022/09/20 00:19:26 Phase context status code: YAML_FILE_ERROR Message: yaml: unmarshal errors:
8 | line 2: cannot unmarshal !!str `0.2` into float64

at DOWNLOAD_SOURCE phase

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant