Skip to content

Add caching of RecordLinker image to smoke tests#261

Merged
m-goggins merged 8 commits into
mainfrom
bug/224-fix-cache-rl-image-for-smoke-tests
Mar 24, 2025
Merged

Add caching of RecordLinker image to smoke tests#261
m-goggins merged 8 commits into
mainfrom
bug/224-fix-cache-rl-image-for-smoke-tests

Conversation

@m-goggins

@m-goggins m-goggins commented Mar 21, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR addresses half of the caching issue outlined in ticket 224: ensuring that we use the cached the RecordLinker image when we run smoke tests to avoid hitting the limit on requests to DockerHub.

After much tinkering, I added a build-push-run step to our smoke tests so now when you run them you should see that we use the image from ghcr for each smoke test instead of hitting docker.io/library/python:3.12-slim to build the service in each run.

Related Issues

Fixes #224

Additional Notes

Getting the services to run from images in the GHCR has proven to be much more difficult, which is why I opted to split up the work on #244. At least we will have cut down the number of requests for RecordLinker by the 4/1 deadline.

<--------------------- REMOVE THE LINES BELOW BEFORE MERGING --------------------->

Checklist

Please review and complete the following checklist before submitting your pull request:

  • I have ensured that the pull request is of a manageable size, allowing it to be reviewed within a single session.
  • I have reviewed my changes to ensure they are clear, concise, and well-documented.
  • I have updated the documentation, if applicable.
  • I have added or updated test cases to cover my changes, if applicable.
  • I have minimized the number of reviewers to include only those essential for the review.

Checklist for Reviewers

Please review and complete the following checklist during the review process:

  • The code follows best practices and conventions.
  • The changes implement the desired functionality or fix the reported issue.
  • The tests cover the new changes and pass successfully.
  • Any potential edge cases or error scenarios have been considered.

@codecov

codecov Bot commented Mar 21, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.82%. Comparing base (c8a38fd) to head (bfa6a31).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #261   +/-   ##
=======================================
  Coverage   97.82%   97.82%           
=======================================
  Files          33       33           
  Lines        1748     1748           
=======================================
  Hits         1710     1710           
  Misses         38       38           

☔ 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.

@m-goggins m-goggins marked this pull request as ready for review March 21, 2025 22:00

@bamader bamader left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks super painful despite being so short 😞 . Thanks for working through these difficulties. Looking at the draft of the other work, splitting definitely seems like the right call to me.

@m-goggins m-goggins merged commit 0971c41 into main Mar 24, 2025
@m-goggins m-goggins deleted the bug/224-fix-cache-rl-image-for-smoke-tests branch March 24, 2025 17:20
with:
push: true
tags: |
ghcr.io/${{ env.REPO }}/rl-service:latest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think there is a potential for a conflict here if we have more than one open PR. If both PR's are building, the last one win's out.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ericbuckley I was thinking of changing the image name to be based on the pr like rl-service:pr-$PR_NUMBER, but want to make sure the image gets removed after the PR is merged. I could do it through a workflow or let a retention policy take care of it, but I don't know what our retention policy is and but don't seem to have the right permissions to do so. Do we have a retention policy set or should I remove the image with a workflow?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will make any updates in the other PR to address this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To my knowledge we don't have a retention policy set. I'm not even sure how to do that on a ghcr.io repo, but I'm sure there is a way. One thing that might be worth considering is using docker layer caching for this rather than an ghcr.io repo. Take a look at this article https://medium.com/@depot.dev/how-to-use-docker-layer-caching-in-github-actions-bee1f7b19093

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Author of ☝️ (co-founder of Depot, former PDX native), you can find a less annoying & updated version (Medium can be meh) of that post here: https://depot.dev/blog/docker-layer-caching-in-github-actions

Also, if you want to skip pushing to GHCR to use as the cache, you can specify load: true, and that should just get the image back to you in its tagged form to then do a docker run on it. You could then do the docker push after your tests to put it in GHCR.

If you also want an open source sponsorship of Depot to swap docker/build-push-action for depot/build-push-action, also happy to set that up.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @kylegalbraith I appreciate the guidance.

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.

increase docker caching in workflows

4 participants