-
Notifications
You must be signed in to change notification settings - Fork 8
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
[#429] add docker cache to build workflow #440
Conversation
30b7622
to
ee12ab3
Compare
- name: Load m2 repository cache # Manually caching .m2 repo as the setup-java caching isn't falling back to older caches | ||
id: cached-m2-repo | ||
uses: actions/cache@v4 | ||
uses: actions/cache/restore@v4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: By using the restore
granular action, we prevent the automated cache-save logic that doesn't meet our needs of saving even when the build fails. (Prior to this change we were basically always saving these caches twice.)
@@ -123,19 +103,24 @@ jobs: | |||
- name: Run Archetype Tests | |||
run: | | |||
./mvnw -B clean install -Parchetype-test -pl :foundation-archetype | |||
#NB: The following two explicit cache saves are necessary to ensure caches are saved on build failure, | |||
# until https://github.com/actions/cache/issues/1315 is resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: This issue is unlikely to be resolved any time soon as there are underlying restrictions that prevent it. Instead, we follow the guidance of the action maintainers.
Saves the docker cache configured in the `cacheTo` and `cacheFrom` options of the Fabric8 `docker-maven-plugin` to GH caches to speed image rebuilds. Also uses the `install-dependencies` custom action to de-duplicate the required build tool installation logic.
ee12ab3
to
2b2eb73
Compare
- name: Poetry cache | ||
id: cached-poetry | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pypoetry | ||
key: poetry-cache-${{ hashFiles('**/pom.xml') }} | ||
key: poetry-cache-${{ hashFiles('**/pyproject.toml') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: Use pyproject.toml so the cache is updated when the python dependencies change, even if the POMs have not changed.
uses: actions/cache/restore@v4 | ||
with: | ||
path: ~/.docker/cache | ||
key: docker-cache-${{ hashFiles('**/Dockerfile') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: This has some limitations, as it doesn't also include the files that are copied into the docker images (e.g. our python modules) but this should be close enough to the ideal case without a ton of complexity. Alternatively, since our caches are cumulative anyway, we could just use a timestamp everywhere instead of file hashes.
Saves the docker cache configured in the
cacheTo
andcacheFrom
options of the Fabric8docker-maven-plugin
to GH caches to speed image rebuilds. Also uses theinstall-dependencies
custom action to de-duplicate the required build tool installation logic.