Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K9VULN-2634] ci: test that the Docker container can actually be built and run #609

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

amaanq
Copy link
Collaborator

@amaanq amaanq commented Jan 15, 2025

What problem are you trying to solve?

This is a follow-up PR to #600, where we noticed that our Docker container could be failing to build, and CI would not let us know of this failure. Currently, the only time we build the Docker container is when we trigger a release workflow, and not during any commit push or PR, which is not ideal. This should be tested in CI

What is your solution?

I've added a workflow that runs on commit pushes and PRs that builds the Docker container, and verifies the binaries can be executed. The workflow is simple, and involves four steps:

  • Check out the repository code
  • Set up Rust
  • Build the Docker container with the tag "test-image"
  • Run this container 3 times one for each of our binaries (datadog-static-analyzer, datadog-static-analyzer-server, and datadog-static-analyzer-git-hook)

Additionally, our release process could run into a situation where our GH release works just fine, but the GHCR workflow fails, thus leading to our release version and container version being out of sync. As such, I've made the docker workflow a pre-requisite for the release job in the release workflow.

A successful run of the workflow can be found here.

A successful run of the release workflow, with the docker build workflow being a required step, can be found here

Alternatives considered

What the reviewer should know

Note that Docker is a preinstalled software in GitHub actions, and we don't need any additional functionality that a specialized action might provide for us, as all we're looking to do is build and run a local container.

If the Docker invocation of the binary fails, then the job does indeed fail, as seen here (this failed because I hadn't passed in --help).

@amaanq amaanq requested a review from a team as a code owner January 15, 2025 17:40
@amaanq amaanq requested review from dastrong and jasonforal and removed request for dastrong January 15, 2025 17:40
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Jan 15, 2025
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Jan 15, 2025
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Jan 15, 2025
@amaanq amaanq changed the title ci: test that the Docker container can actually be built and run [K9VULN-2634] ci: test that the Docker container can actually be built and run Jan 15, 2025
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Jan 15, 2025
@DataDog DataDog deleted a comment from datadog-datadog-prod-us1 bot Jan 15, 2025
@amaanq amaanq requested a review from jasonforal January 15, 2025 20:59
Copy link
Collaborator

@jasonforal jasonforal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please test the release.yml workflow in its entirety and link the result just so we have confidence nothing else was missed during review? Thanks!

.github/workflows/release.yml Outdated Show resolved Hide resolved
@amaanq
Copy link
Collaborator Author

amaanq commented Jan 17, 2025

squashing & merging

@amaanq amaanq force-pushed the amaan.qureshi/K9VULN-2634-2 branch from 5fbc17c to f9010a0 Compare January 17, 2025 16:24
@amaanq amaanq merged commit f01505d into main Jan 17, 2025
74 checks passed
@amaanq amaanq deleted the amaan.qureshi/K9VULN-2634-2 branch January 17, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants