How can an AWS CodeBuild job see which files have changed?

Viewed 344

I'm trying to set up an AWS CodeBuild project to run tests to validate PRs and commits on a GitHub repository.

Because of the nature of the repo (a monorepo combining several ML models):

  • I need to restrict down to only run tests associated with files changed in the PR/commit to keep time+cost under control, but
  • The tests will typically require reference to other un-changed files in the repo: So can't just only pull changed files through to the build container.

How can a running CodeBuild build triggered by a GitHub PR (as per the docs here) 'see' which files are changed by the PR to selectively execute tests?

1 Answers

In your buildspec file you can perform shell commands, I think you can use some git commands there and echo the result, so you can see them as logs during the build.

Related