refactor: always rebuild dev-generic
The `dev-generic` job was originally optimized to only build once per workflow run. Subsequent re-runs skipped the build steps. This unfortunately made it difficult to analyze dev-generic cache problems after merging. This change removes this optimization. The cache key has a timestamp suffix so that the cache is always built anew. This provides more integrity, traceability and flexibility at the cost of increased cache turnover across the repository. PR: zmkfirmware/zmk-docker#74
This commit is contained in:
parent
406388461c
commit
67075dfb7b
18
.github/workflows/containers.yml
vendored
18
.github/workflows/containers.yml
vendored
@ -88,6 +88,7 @@ jobs:
|
|||||||
echo ::set-output name=major-minor-branch::${MAJOR_MINOR_BRANCH}
|
echo ::set-output name=major-minor-branch::${MAJOR_MINOR_BRANCH}
|
||||||
dev-generic:
|
dev-generic:
|
||||||
needs:
|
needs:
|
||||||
|
- timestamp
|
||||||
- tags
|
- tags
|
||||||
if: ${{ !startsWith(github.ref, 'refs/tags') }}
|
if: ${{ !startsWith(github.ref, 'refs/tags') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -133,18 +134,14 @@ jobs:
|
|||||||
cache-name: dev-generic
|
cache-name: dev-generic
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.paths.outputs.local }}
|
path: ${{ steps.paths.outputs.local }}
|
||||||
key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}
|
key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}/${{ needs.timestamp.outputs.timestamp }}
|
||||||
- name: Rebuild cache?
|
restore-keys: |
|
||||||
id: should-rebuild
|
${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}
|
||||||
run: echo ::set-output name=value::${{ steps.cache.outputs.cache-hit != 'true' || env.no-cache == 'true' }}
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
if: ${{ steps.should-rebuild.outputs.value == 'true' }}
|
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
if: ${{ steps.should-rebuild.outputs.value == 'true' }}
|
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
- name: Build to local cache
|
- name: Build to local cache
|
||||||
if: ${{ steps.should-rebuild.outputs.value == 'true' }}
|
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
target: dev-generic
|
target: dev-generic
|
||||||
@ -152,6 +149,7 @@ jobs:
|
|||||||
ZEPHYR_VERSION=${{ env.zephyr-version }}
|
ZEPHYR_VERSION=${{ env.zephyr-version }}
|
||||||
no-cache: ${{ env.no-cache == 'true' }}
|
no-cache: ${{ env.no-cache == 'true' }}
|
||||||
cache-from: |
|
cache-from: |
|
||||||
|
type=local,src=${{ steps.paths.outputs.local }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.branch }}
|
type=registry,ref=${{ steps.paths.outputs.branch }}
|
||||||
${{ (steps.paths.outputs.base != '') && format('type=registry,ref={0}', steps.paths.outputs.base) || '' }}
|
${{ (steps.paths.outputs.base != '') && format('type=registry,ref={0}', steps.paths.outputs.base) || '' }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.major-minor-branch }}
|
type=registry,ref=${{ steps.paths.outputs.major-minor-branch }}
|
||||||
@ -159,7 +157,7 @@ jobs:
|
|||||||
type=registry,ref=${{ steps.paths.outputs.major-minor-branch-upstream }}
|
type=registry,ref=${{ steps.paths.outputs.major-minor-branch-upstream }}
|
||||||
cache-to: type=local,dest=${{ steps.paths.outputs.local-new }},mode=max
|
cache-to: type=local,dest=${{ steps.paths.outputs.local-new }},mode=max
|
||||||
- name: Push to registry cache
|
- name: Push to registry cache
|
||||||
if: ${{ (steps.should-rebuild.outputs.value == 'true') && (env.docker-hub-credentials == 'true') }}
|
if: ${{ env.docker-hub-credentials == 'true' }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
target: dev-generic
|
target: dev-generic
|
||||||
@ -174,12 +172,12 @@ jobs:
|
|||||||
# https://github.com/docker/build-push-action/issues/252
|
# https://github.com/docker/build-push-action/issues/252
|
||||||
# https://github.com/moby/buildkit/issues/1896
|
# https://github.com/moby/buildkit/issues/1896
|
||||||
- name: Switch local cache
|
- name: Switch local cache
|
||||||
if: ${{ steps.should-rebuild.outputs.value == 'true' }}
|
|
||||||
run: |
|
run: |
|
||||||
rm -rf ${{ steps.paths.outputs.local }}
|
rm -rf ${{ steps.paths.outputs.local }}
|
||||||
mv ${{ steps.paths.outputs.local-new }} ${{ steps.paths.outputs.local }}
|
mv ${{ steps.paths.outputs.local-new }} ${{ steps.paths.outputs.local }}
|
||||||
candidates:
|
candidates:
|
||||||
needs:
|
needs:
|
||||||
|
- timestamp
|
||||||
- architectures
|
- architectures
|
||||||
- tags
|
- tags
|
||||||
- dev-generic
|
- dev-generic
|
||||||
@ -286,7 +284,7 @@ jobs:
|
|||||||
cache-name: dev-generic
|
cache-name: dev-generic
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.paths.outputs.dev-generic }}
|
path: ${{ steps.paths.outputs.dev-generic }}
|
||||||
key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}
|
key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}/${{ needs.timestamp.outputs.timestamp }}
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
Loading…
Reference in New Issue
Block a user