refactor: combine build
and dev
jobs
Bringing `build` and `dev` into the same job lets `dev` use `build` as a cache-from source without requiring registry credentials. PR: #60
This commit is contained in:
parent
910fcf7a8a
commit
27b9ac19f3
105
.github/workflows/containers.yml
vendored
105
.github/workflows/containers.yml
vendored
@ -82,9 +82,6 @@ jobs:
|
|||||||
max-parallel: 1 # takes advantage of caching between jobs
|
max-parallel: 1 # takes advantage of caching between jobs
|
||||||
matrix:
|
matrix:
|
||||||
architecture: ${{ fromJSON(needs.architectures.outputs.json) }}
|
architecture: ${{ fromJSON(needs.architectures.outputs.json) }}
|
||||||
target: # ordered from smallest to biggest to take advantage of the inline cache
|
|
||||||
- build
|
|
||||||
- dev
|
|
||||||
include:
|
include:
|
||||||
- architecture: arm
|
- architecture: arm
|
||||||
board: nice_nano
|
board: nice_nano
|
||||||
@ -111,49 +108,86 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo ::set-output name=build::zmk-build-${{ matrix.architecture }}
|
echo ::set-output name=build::zmk-build-${{ matrix.architecture }}
|
||||||
echo ::set-output name=dev::zmk-dev-${{ matrix.architecture }}
|
echo ::set-output name=dev::zmk-dev-${{ matrix.architecture }}
|
||||||
echo ::set-output name=target::zmk-${{ matrix.target }}-${{ matrix.architecture }}
|
|
||||||
- name: Define paths
|
- name: Define paths
|
||||||
id: paths
|
id: paths
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
NS: ${{ env.docker-hub-namespace }}
|
NS: ${{ env.docker-hub-namespace }}
|
||||||
TARGET: ${{ steps.repositories.outputs.target }}
|
|
||||||
BUILD: ${{ steps.repositories.outputs.build }}
|
BUILD: ${{ steps.repositories.outputs.build }}
|
||||||
DEV: ${{ steps.repositories.outputs.dev }}
|
DEV: ${{ steps.repositories.outputs.dev }}
|
||||||
CANDIDATE: ${{ needs.tags.outputs.candidate }}
|
CANDIDATE: ${{ needs.tags.outputs.candidate }}
|
||||||
BRANCH: ${{ needs.tags.outputs.branch }}
|
BRANCH: ${{ needs.tags.outputs.branch }}
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=target-candidate::docker.io/${NS}/${TARGET}:${CANDIDATE}
|
echo ::set-output name=build-candidate::docker.io/${NS}/${BUILD}:${CANDIDATE}
|
||||||
echo ::set-output name=target-branch::docker.io/${NS}/${TARGET}:${BRANCH}
|
|
||||||
echo ::set-output name=build-branch::docker.io/${NS}/${BUILD}:${BRANCH}
|
echo ::set-output name=build-branch::docker.io/${NS}/${BUILD}:${BRANCH}
|
||||||
|
echo ::set-output name=dev-candidate::docker.io/${NS}/${DEV}:${CANDIDATE}
|
||||||
echo ::set-output name=dev-branch::docker.io/${NS}/${DEV}:${BRANCH}
|
echo ::set-output name=dev-branch::docker.io/${NS}/${DEV}:${BRANCH}
|
||||||
|
- name: Define build-args
|
||||||
|
id: build-args
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
LIST="
|
||||||
|
ZEPHYR_VERSION=${{ env.zephyr-version }}
|
||||||
|
ARCHITECTURE=${{ matrix.architecture }}
|
||||||
|
ZEPHYR_SDK_VERSION=${{ env.zephyr-sdk-version }}
|
||||||
|
"
|
||||||
|
# Escapes %, \n and \r
|
||||||
|
# See: https://github.community/t/set-output-truncates-multiline-strings/16852
|
||||||
|
LIST="${LIST//'%'/'%25'}"
|
||||||
|
LIST="${LIST//$'\n'/'%0A'}"
|
||||||
|
LIST="${LIST//$'\r'/'%0D'}"
|
||||||
|
echo ::set-output name=list::${LIST}
|
||||||
|
- name: Define labels
|
||||||
|
id: labels
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
LIST="
|
||||||
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
||||||
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
|
"
|
||||||
|
# Escapes %, \n and \r
|
||||||
|
# See: https://github.community/t/set-output-truncates-multiline-strings/16852
|
||||||
|
LIST="${LIST//'%'/'%25'}"
|
||||||
|
LIST="${LIST//$'\n'/'%0A'}"
|
||||||
|
LIST="${LIST//$'\r'/'%0D'}"
|
||||||
|
echo ::set-output name=list::${LIST}
|
||||||
- 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
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
- name: Build and load candidate image
|
- name: Build and load 'build' candidate image
|
||||||
id: build-push
|
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: build
|
||||||
build-args: |
|
build-args: |
|
||||||
ZEPHYR_VERSION=${{ env.zephyr-version }}
|
${{ steps.build-args.outputs.list }}
|
||||||
ARCHITECTURE=${{ matrix.architecture }}
|
|
||||||
ZEPHYR_SDK_VERSION=${{ env.zephyr-sdk-version }}
|
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
${{ steps.labels.outputs.list }}
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
|
||||||
tags: |
|
tags: |
|
||||||
${{ steps.paths.outputs.target-candidate }}
|
${{ steps.paths.outputs.build-candidate }}
|
||||||
${{ steps.paths.outputs.target-branch }}
|
${{ steps.paths.outputs.build-branch }}
|
||||||
cache-from: |
|
cache-from: |
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.build-candidate }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.build-branch }}
|
type=registry,ref=${{ steps.paths.outputs.build-branch }}
|
||||||
|
cache-to: type=inline
|
||||||
|
load: true
|
||||||
|
- name: Build and load 'dev' candidate image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
target: dev
|
||||||
|
build-args: |
|
||||||
|
${{ steps.build-args.outputs.list }}
|
||||||
|
labels: |
|
||||||
|
${{ steps.labels.outputs.list }}
|
||||||
|
tags: |
|
||||||
|
${{ steps.paths.outputs.dev-candidate }}
|
||||||
|
${{ steps.paths.outputs.dev-branch }}
|
||||||
|
cache-from: |
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.build-candidate }}
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.dev-candidate }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.dev-branch }}
|
type=registry,ref=${{ steps.paths.outputs.dev-branch }}
|
||||||
cache-to: type=inline
|
cache-to: type=inline
|
||||||
load: true
|
load: true
|
||||||
- name: Create and run container from candidate image
|
|
||||||
shell: bash
|
|
||||||
run: docker run -d -it --name candidate ${{ env.docker-args }} ${{ steps.paths.outputs.target-candidate }}
|
|
||||||
- name: Checkout ZMK
|
- name: Checkout ZMK
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@ -172,6 +206,9 @@ jobs:
|
|||||||
key: ${{ runner.os }}/${{ env.cache-name }}/${{ hashFiles('app/west.yml') }}
|
key: ${{ runner.os }}/${{ env.cache-name }}/${{ hashFiles('app/west.yml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}/${{ env.cache-name }}/
|
${{ runner.os }}/${{ env.cache-name }}/
|
||||||
|
- name: Create and run container from 'build' candidate image
|
||||||
|
shell: bash
|
||||||
|
run: docker run -d -it --name candidate ${{ env.docker-args }} ${{ steps.paths.outputs.build-candidate }}
|
||||||
- name: Test diff
|
- name: Test diff
|
||||||
run: diff --version
|
run: diff --version
|
||||||
- name: Test west init
|
- name: Test west init
|
||||||
@ -194,54 +231,48 @@ jobs:
|
|||||||
run: west test
|
run: west test
|
||||||
- name: Test clean (west build)
|
- name: Test clean (west build)
|
||||||
run: west build -t clean
|
run: west build -t clean
|
||||||
|
- name: Stop container
|
||||||
|
shell: bash
|
||||||
|
run: docker stop candidate
|
||||||
|
- name: Create and run container from 'dev' candidate image
|
||||||
|
shell: bash
|
||||||
|
run: docker run -d -it --name candidate ${{ env.docker-args }} ${{ steps.paths.outputs.dev-candidate }}
|
||||||
- name: Test clang-format
|
- name: Test clang-format
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: clang-format --version
|
run: clang-format --version
|
||||||
- name: Test node
|
- name: Test node
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: node --version
|
run: node --version
|
||||||
- name: Test docs ci
|
- name: Test docs ci
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && npm ci
|
run: cd docs && npm ci
|
||||||
- name: Test docs lint
|
- name: Test docs lint
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && npm run lint
|
run: cd docs && npm run lint
|
||||||
- name: Test docs prettier check
|
- name: Test docs prettier check
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && npm run prettier:check
|
run: cd docs && npm run prettier:check
|
||||||
- name: Test docs start (webpack-dev-server)
|
- name: Test docs start (webpack-dev-server)
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && timeout -s SIGINT 20 npm run start &
|
run: cd docs && timeout -s SIGINT 20 npm run start &
|
||||||
- run: sleep 15
|
- run: sleep 15
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
- name: Test docs wget (webpack-dev-server)
|
- name: Test docs wget (webpack-dev-server)
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: wget http://localhost:3000
|
run: wget http://localhost:3000
|
||||||
- run: sleep 10
|
- run: sleep 10
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
- name: Test docs build (webpack)
|
- name: Test docs build (webpack)
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && npm run build
|
run: cd docs && npm run build
|
||||||
- name: Test docs serve (webpack)
|
- name: Test docs serve (webpack)
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: cd docs && timeout -s SIGINT 10 npm run serve &
|
run: cd docs && timeout -s SIGINT 10 npm run serve &
|
||||||
- run: sleep 5
|
- run: sleep 5
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
- name: Test docs wget (webpack)
|
- name: Test docs wget (webpack)
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: wget http://localhost:3000
|
run: wget http://localhost:3000
|
||||||
- name: Test ssh
|
- name: Test ssh
|
||||||
if: ${{ matrix.target == 'dev' }}
|
|
||||||
run: ssh -V
|
run: ssh -V
|
||||||
- name: Stop container
|
- name: Stop container
|
||||||
shell: bash
|
shell: bash
|
||||||
run: docker stop candidate
|
run: docker stop candidate
|
||||||
- name: Push candidate image to the registry
|
- name: Push candidate images to the registry
|
||||||
if: ${{ steps.docker-hub-login.outcome == 'success' }}
|
if: ${{ steps.docker-hub-login.outcome == 'success' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
docker image push ${{ steps.paths.outputs.target-candidate }}
|
docker image push ${{ steps.paths.outputs.build-candidate }}
|
||||||
docker image push ${{ steps.paths.outputs.target-branch }}
|
docker image push ${{ steps.paths.outputs.build-branch }}
|
||||||
|
docker image push ${{ steps.paths.outputs.dev-candidate }}
|
||||||
|
docker image push ${{ steps.paths.outputs.dev-branch }}
|
||||||
releases:
|
releases:
|
||||||
needs:
|
needs:
|
||||||
- architectures
|
- architectures
|
||||||
|
Loading…
Reference in New Issue
Block a user