Skip to content

ci: build docker image on PRs / tags#2353

Merged
tac0turtle merged 2 commits into
mainfrom
cian/add-workflow-to-build-docker-image
Jun 9, 2025
Merged

ci: build docker image on PRs / tags#2353
tac0turtle merged 2 commits into
mainfrom
cian/add-workflow-to-build-docker-image

Conversation

@chatton

@chatton chatton commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR adds a workflow which will build the rollkit image on each PR, in a follow up we can use this image to perform upgrade tests.

If it's on a PR, it will be tagged like pr-1234, if it's a tag or main it will be tagged with the format v1.0.0 or main.

Summary by CodeRabbit

  • Chores
    • Updated continuous integration workflows to support dynamic Docker image tagging for test jobs.
    • Added automated building and publishing of Docker images during testing.
    • Introduced a placeholder for future upgrade tests.
    • Removed the separate Docker build and publish workflow to streamline processes.

@coderabbitai

coderabbitai Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The CI workflows were updated by adding a dynamic image-tag parameter to the test job, extending the test workflow with Docker build and upgrade test jobs, and removing the Docker build and publish workflow. These changes centralize Docker image building and tagging within the test workflow and deprecate the separate Docker publish workflow.

Changes

File(s) Change Summary
.github/workflows/ci_release.yml Modified the test job to include a dynamic image-tag input parameter based on event context.
.github/workflows/test.yml Added required image-tag input, new build-docker-image job for Docker build/push, and upgrade-tests job.
.github/workflows/docker-build-publish.yml Deleted the workflow for Docker build and publish.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant build-docker-image
    participant GHCR
    participant upgrade-tests

    GitHub Actions->>build-docker-image: Start job with image-tag input
    build-docker-image->>GHCR: Login and push Docker image (tagged with image-tag)
    build-docker-image-->>upgrade-tests: On success, trigger upgrade-tests
    upgrade-tests->>upgrade-tests: Run placeholder step (TODO: add upgrade tests)
Loading

Suggested reviewers

  • tzdybal

Poem

A bunny hops through YAML fields,
Where Docker builds and testing yields.
Old workflows gone, new tags in tow,
Images pushed where carrots grow.
Upgrade dreams are yet to bloom—
CI hops forward, making room!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJun 9, 2025, 11:22 AM

Comment thread .github/workflows/test.yml Fixed
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow

Unpinned 3rd party Action 'Tests / Code Coverage' step [Uses Step](1) uses 'docker/setup-buildx-action' with ref 'v3', not a pinned commit hash
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow

Unpinned 3rd party Action 'Tests / Code Coverage' step [Uses Step](1) uses 'docker/login-action' with ref 'v3', not a pinned commit hash
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image with PR tag
uses: docker/build-push-action@v5

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow

Unpinned 3rd party Action 'Tests / Code Coverage' step [Uses Step](1) uses 'docker/build-push-action' with ref 'v5', not a pinned commit hash
@chatton chatton self-assigned this Jun 9, 2025
@codecov

codecov Bot commented Jun 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.91%. Comparing base (60403ae) to head (3b24ece).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2353   +/-   ##
=======================================
  Coverage   65.91%   65.91%           
=======================================
  Files          66       66           
  Lines        6140     6140           
=======================================
  Hits         4047     4047           
  Misses       1724     1724           
  Partials      369      369           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatton chatton changed the title [WIP] build docker image on PRs / tags ci: build docker image on PRs / tags Jun 9, 2025
Comment on lines +13 to +36
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image with PR tag
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/rollkit:${{ inputs.image-tag }}

upgrade-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

Copilot Autofix

AI about 1 year ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the least privileges required for the workflow to function correctly. Based on the steps in the workflow:

  • The docker/login-action step requires contents: read to authenticate using the GITHUB_TOKEN.
  • Other steps in the workflow do not appear to require additional permissions.

The permissions block should be added at the root level of the workflow to apply to all jobs, as none of the jobs require write permissions.

Suggested changeset 1
.github/workflows/test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -3,2 +3,4 @@
 name: Tests / Code Coverage
+permissions:
+  contents: read
 on:
EOF
@@ -3,2 +3,4 @@
name: Tests / Code Coverage
permissions:
contents: read
on:
Copilot is powered by AI and may make mistakes. Always verify output.
@chatton
chatton requested a review from tac0turtle June 9, 2025 11:25
@chatton
chatton marked this pull request as ready for review June 9, 2025 11:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/test.yml (2)

19-31: Pin GitHub Action versions for immutability
To ensure reproducible and secure runs, pin third-party actions to specific commit SHAs instead of floating version tags (@v3, @v5).

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 20-20: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/setup-buildx-action' with ref 'v3', not a pinned commit hash


[warning] 23-23: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/login-action' with ref 'v3', not a pinned commit hash


[warning] 30-30: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/build-push-action' with ref 'v5', not a pinned commit hash


37-41: Implement the upgrade-tests placeholder
The upgrade-tests job currently exits immediately. Add real upgrade-test steps or remove the placeholder if not needed, and consider opening an issue to track this enhancement.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 37-42: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60403ae and 3b24ece.

📒 Files selected for processing (3)
  • .github/workflows/ci_release.yml (1 hunks)
  • .github/workflows/docker-build-publish.yml (0 hunks)
  • .github/workflows/test.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/docker-build-publish.yml
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/test.yml

[warning] 13-36: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}


[warning] 20-20: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/setup-buildx-action' with ref 'v3', not a pinned commit hash


[warning] 23-23: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/login-action' with ref 'v3', not a pinned commit hash


[warning] 30-30: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/build-push-action' with ref 'v5', not a pinned commit hash

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (2)
.github/workflows/ci_release.yml (1)

32-35: Approve dynamic image-tag derivation
The expression correctly falls back to pr-<number> for pull requests and uses the branch or tag name otherwise.

.github/workflows/test.yml (1)

6-10: Well-defined image-tag input parameter
The required string input image-tag for workflow_call is clearly specified and correctly typed.

Comment on lines +13 to +36
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image with PR tag
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/rollkit:${{ inputs.image-tag }}

upgrade-tests:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add explicit permissions block for least-privilege
This workflow currently inherits default token permissions, which may be overly permissive. Define a top-level permissions: block (e.g., contents: read, packages: write) to restrict GITHUB_TOKEN to only the scopes needed for build and push operations.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 13-36: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}


[warning] 20-20: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/setup-buildx-action' with ref 'v3', not a pinned commit hash


[warning] 23-23: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/login-action' with ref 'v3', not a pinned commit hash


[warning] 30-30: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'docker/build-push-action' with ref 'v5', not a pinned commit hash

🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 13 to 36, the workflow lacks an
explicit permissions block, causing the GITHUB_TOKEN to have default,
potentially excessive permissions. Add a top-level permissions section
specifying only the necessary scopes, such as 'contents: read' and 'packages:
write', to enforce least-privilege access for the build and push steps.

@tac0turtle
tac0turtle added this pull request to the merge queue Jun 9, 2025
Merged via the queue into main with commit ca0d7d7 Jun 9, 2025
@tac0turtle
tac0turtle deleted the cian/add-workflow-to-build-docker-image branch June 9, 2025 11:41
@github-project-automation github-project-automation Bot moved this to Done in Evolve Jun 9, 2025
Manav-Aggarwal pushed a commit that referenced this pull request Jun 10, 2025
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.

NOTE: PR titles should follow semantic commits:
https://www.conventionalcommits.org/en/v1.0.0/
-->

## Overview

This PR adds a workflow which will build the rollkit image on each PR,
in a follow up we can use this image to perform upgrade tests.

If it's on a PR, it will be tagged like `pr-1234`, if it's a tag or main
it will be tagged with the format `v1.0.0` or `main`.

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 

Ex: Closes #<issue number>
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated continuous integration workflows to support dynamic Docker
image tagging for test jobs.
- Added automated building and publishing of Docker images during
testing.
  - Introduced a placeholder for future upgrade tests.
- Removed the separate Docker build and publish workflow to streamline
processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Manav-Aggarwal pushed a commit that referenced this pull request Jun 10, 2025
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.

NOTE: PR titles should follow semantic commits:
https://www.conventionalcommits.org/en/v1.0.0/
-->

## Overview

This PR adds a workflow which will build the rollkit image on each PR,
in a follow up we can use this image to perform upgrade tests.

If it's on a PR, it will be tagged like `pr-1234`, if it's a tag or main
it will be tagged with the format `v1.0.0` or `main`.

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 

Ex: Closes #<issue number>
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated continuous integration workflows to support dynamic Docker
image tagging for test jobs.
- Added automated building and publishing of Docker images during
testing.
  - Introduced a placeholder for future upgrade tests.
- Removed the separate Docker build and publish workflow to streamline
processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@tac0turtle tac0turtle removed this from Evolve Aug 25, 2025
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.

3 participants