mirror of
https://git.yoctoproject.org/meta-raspberrypi
synced 2026-10-22 05:58:11 +00:00
ci: reuse docker images across jobs
We were rebuilding Docker images from scratch with --no-cache, tagged by PR number. With this, we were building multiple images per PR for the same context. This change tags the images by the git tree hash of the build context and only build if the tag is missing. This naturally covers rebuilding on build context changes. Finally, this change handles refreshing images every 7 days (for example to refresh OS packages) and prune by CI label after 14 days. The gap ensures an image a running job just picked up isn't pruned under it. Signed-off-by: Andrei Gherzan <andrei@gherzan.com>
This commit is contained in:
6 files changed
+63
-55
No files matched your search
@@ -17,22 +17,20 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Build a temporary DCO image
|
||||
- name: Build the DCO image
|
||||
id: docker
|
||||
uses: ./.github/actions/docker-build
|
||||
with:
|
||||
docker_image: dco-check
|
||||
id: ${{ github.event.number }}
|
||||
- name: Do DCO check
|
||||
run: |
|
||||
docker run --rm --security-opt apparmor=unconfined \
|
||||
--security-opt seccomp=unconfined \
|
||||
-v "$GITHUB_WORKSPACE:/work:ro" \
|
||||
--env "BASE_REF=$GITHUB_BASE_REF" \
|
||||
"dco-check-${{ github.event.number }}"
|
||||
- name: Cleanup temporary docker image
|
||||
uses: ./.github/actions/docker-clean-image
|
||||
with:
|
||||
docker_image: dco-check-${{ github.event.number }}
|
||||
"${{ steps.docker.outputs.image }}"
|
||||
- name: Prune old CI docker images
|
||||
uses: ./.github/actions/docker-prune-images
|
||||
if: always()
|
||||
- name: Cleanup dangling docker images
|
||||
uses: ./.github/actions/docker-clean-dangling
|
||||
|
||||
@@ -39,11 +39,11 @@ jobs:
|
||||
- name: Check for Yocto relevant changes
|
||||
id: changed-files-specific
|
||||
uses: ./.github/actions/changed-files
|
||||
- name: Build a temporary yocto-builder image
|
||||
- name: Build the yocto-builder image
|
||||
id: docker
|
||||
uses: ./.github/actions/docker-build
|
||||
with:
|
||||
docker_image: yocto-builder
|
||||
id: ${{ github.event.number }}
|
||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||
- name: Build the image
|
||||
run: |
|
||||
@@ -59,13 +59,11 @@ jobs:
|
||||
--env "DL_DIR=$DL_DIR" \
|
||||
--env "SSTATE_DIR=$SSTATE_DIR" \
|
||||
--ulimit "nofile=1024:1048576" \
|
||||
"yocto-builder-${{ github.event.number }}" \
|
||||
"${{ steps.docker.outputs.image }}" \
|
||||
/entrypoint-build.sh
|
||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||
- name: Cleanup temporary docker image
|
||||
uses: ./.github/actions/docker-clean-image
|
||||
with:
|
||||
docker_image: yocto-builder-${{ github.event.number }}
|
||||
- name: Prune old CI docker images
|
||||
uses: ./.github/actions/docker-prune-images
|
||||
if: always()
|
||||
- name: Cleanup dangling docker images
|
||||
uses: ./.github/actions/docker-clean-dangling
|
||||
|
||||
@@ -22,24 +22,22 @@ jobs:
|
||||
- name: Check for Yocto relevant changes
|
||||
id: changed-files-specific
|
||||
uses: ./.github/actions/changed-files
|
||||
- name: Build a temporary yocto-builder image
|
||||
- name: Build the yocto-builder image
|
||||
id: docker
|
||||
uses: ./.github/actions/docker-build
|
||||
with:
|
||||
docker_image: yocto-builder
|
||||
id: ${{ github.event.number }}
|
||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||
- name: Run yocto-check-layer
|
||||
run: |
|
||||
docker run --rm --security-opt apparmor=unconfined \
|
||||
-v "$GITHUB_WORKSPACE:/work:ro" \
|
||||
--env "BASE_REF=$GITHUB_BASE_REF" \
|
||||
"yocto-builder-${{ github.event.number }}" \
|
||||
"${{ steps.docker.outputs.image }}" \
|
||||
/entrypoint-yocto-check-layer.sh
|
||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||
- name: Cleanup temporary docker image
|
||||
uses: ./.github/actions/docker-clean-image
|
||||
with:
|
||||
docker_image: yocto-builder-${{ github.event.number }}
|
||||
- name: Prune old CI docker images
|
||||
uses: ./.github/actions/docker-prune-images
|
||||
if: always()
|
||||
- name: Cleanup dangling docker images
|
||||
uses: ./.github/actions/docker-clean-dangling
|
||||
|
||||
Reference in new issue
Block a user