Separate build and test jobs for CI

This commit is contained in:
cytopia
2022-03-27 20:58:01 +02:00
parent c17e49b849
commit b224ecfdd7
6 changed files with 546 additions and 9 deletions

View File

@@ -58,6 +58,23 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
base-test:
needs:
- params
- configure
- base
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }}
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: base
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (4/8) Build & Test mods
@@ -67,6 +84,7 @@ jobs:
- params
- configure
- base
- base-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -79,6 +97,25 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
mods-test:
needs:
- params
- configure
- base
- base-test
- mods
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }}
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: mods
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (5/8) Build & Test prod
@@ -88,7 +125,9 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -101,6 +140,27 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
prod-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }}
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: prod
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (6/8) Build & Test work
@@ -110,8 +170,11 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -124,6 +187,29 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
work-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }}
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: work
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (7/8) Push images
@@ -133,9 +219,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
uses: ./.github/workflows/zzz-reuse-deploy-images.yml
with:
enabled: true
@@ -156,9 +246,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
- push-image
uses: ./.github/workflows/zzz-reuse-deploy-manifests.yml
with:

View File

@@ -60,6 +60,23 @@ jobs:
dockerhub_username: ""
dockerhub_password: ""
base-test:
needs:
- params
- configure
- base
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: false
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: base
secrets:
dockerhub_username: ""
dockerhub_password: ""
# -----------------------------------------------------------------------------------------------
# (4/8) Build & Test mods
@@ -69,6 +86,7 @@ jobs:
- params
- configure
- base
- base-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -81,6 +99,25 @@ jobs:
dockerhub_username: ""
dockerhub_password: ""
mods-test:
needs:
- params
- configure
- base
- base-test
- mods
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: false
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: mods
secrets:
dockerhub_username: ""
dockerhub_password: ""
# -----------------------------------------------------------------------------------------------
# (5/8) Build & Test prod
@@ -90,7 +127,9 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -103,6 +142,27 @@ jobs:
dockerhub_username: ""
dockerhub_password: ""
prod-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: false
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: prod
secrets:
dockerhub_username: ""
dockerhub_password: ""
# -----------------------------------------------------------------------------------------------
# (6/8) Build & Test work
@@ -112,8 +172,11 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -126,6 +189,29 @@ jobs:
dockerhub_username: ""
dockerhub_password: ""
work-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: false
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: work
secrets:
dockerhub_username: ""
dockerhub_password: ""
# -----------------------------------------------------------------------------------------------
# (7/8) Push images
@@ -135,9 +221,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
uses: ./.github/workflows/zzz-reuse-deploy-images.yml
with:
enabled: true
@@ -158,9 +248,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
- push-image
uses: ./.github/workflows/zzz-reuse-deploy-manifests.yml
with:

View File

@@ -60,6 +60,23 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
base-test:
needs:
- params
- configure
- base
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: base
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (4/8) Build & Test mods
@@ -69,6 +86,7 @@ jobs:
- params
- configure
- base
- base-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -81,6 +99,25 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
mods-test:
needs:
- params
- configure
- base
- base-test
- mods
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: mods
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (5/8) Build & Test prod
@@ -90,7 +127,9 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -103,6 +142,27 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
prod-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: prod
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (6/8) Build & Test work
@@ -112,8 +172,11 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -126,6 +189,29 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
work-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: work
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (7/8) Push images
@@ -135,9 +221,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
uses: ./.github/workflows/zzz-reuse-deploy-images.yml
with:
enabled: true
@@ -158,9 +248,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
- push-image
uses: ./.github/workflows/zzz-reuse-deploy-manifests.yml
with:

View File

@@ -60,6 +60,23 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
base-test:
needs:
- params
- configure
- base
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: base
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (4/8) Build & Test mods
@@ -69,6 +86,7 @@ jobs:
- params
- configure
- base
- base-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -81,6 +99,25 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
mods-test:
needs:
- params
- configure
- base
- base-test
- mods
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: mods
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (5/8) Build & Test prod
@@ -90,7 +127,9 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -103,6 +142,27 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
prod-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: prod
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (6/8) Build & Test work
@@ -112,8 +172,11 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
uses: ./.github/workflows/zzz-reuse-build.yml
with:
enabled: true
@@ -126,6 +189,29 @@ jobs:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
work-test:
needs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
uses: ./.github/workflows/zzz-reuse-test.yml
with:
enabled: true
can_deploy: true
build_matrix: ${{ needs.configure.outputs.matrix_build }}
has_refs: ${{ needs.configure.outputs.has_refs }}
artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }}
flavour: work
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
# -----------------------------------------------------------------------------------------------
# (7/8) Push images
@@ -135,9 +221,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
uses: ./.github/workflows/zzz-reuse-deploy-images.yml
with:
enabled: true
@@ -158,9 +248,13 @@ jobs:
- params
- configure
- base
- base-test
- mods
- mods-test
- prod
- prod-test
- work
- work-test
- push-image
uses: ./.github/workflows/zzz-reuse-deploy-manifests.yml
with:

View File

@@ -169,15 +169,6 @@ jobs:
command: |
make build VERSION=${{ matrix.version }} FLAVOUR=${{ inputs.flavour }} ARCH=${{ matrix.arch }}
# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: Test
uses: cytopia/shell-command-retry-action@v0.1.2
with:
command: |
make test VERSION=${{ matrix.version }} FLAVOUR=${{ inputs.flavour }} ARCH=${{ matrix.arch }}
# ------------------------------------------------------------
# Artifact Expot (base)

170
.github/workflows/zzz-reuse-test.yml vendored Normal file
View File

@@ -0,0 +1,170 @@
---
name: Test multi-arch images
on:
workflow_call:
###
### Variables
###
inputs:
enabled:
description: 'Determines wheather this workflow is enabled at all (will run or skip).'
required: true
type: boolean
can_deploy:
description: 'Determines wheather this workflow will also deploy (login and push).'
required: true
type: boolean
build_matrix:
description: 'The build matrix'
required: true
type: string
has_refs:
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).'
required: true
type: string
artifact_prefix:
description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).'
required: true
type: string
flavour:
description: 'The flavour to build (base, mods, prod or work).'
required: true
type: string
###
### Secrets
###
secrets:
dockerhub_username:
description: 'The username for Dockerhub.'
required: false
dockerhub_password:
description: 'The password for Dockerhub.'
required: false
jobs:
# -----------------------------------------------------------------------------------------------
# JOB: BUILD
# -----------------------------------------------------------------------------------------------
test:
name: ${{ matrix.name }}-${{ matrix.version }}-${{ inputs.flavour }} (${{ matrix.arch }}) ${{ matrix.refs }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(inputs.build_matrix) }}
if: inputs.enabled
steps:
# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: "[SETUP] Checkout repository (current)"
uses: actions/checkout@v3
with:
fetch-depth: 0
if: inputs.has_refs == 0
- name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})"
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ matrix.refs }}
if: inputs.has_refs != 0
- name: "[SETUP] Setup QEMU environment"
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: "[SETUP] Set artifact names"
id: set-artifact-name
run: |
PRE_HASH="$( git rev-parse HEAD | head -c 10 )"
VERSION="${{ matrix.version }}"
ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )"
NAME_BASE="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-base"
NAME_MODS="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-mods"
NAME_PROD="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-prod"
NAME_WORK="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-work"
echo "::set-output name=base::${NAME_BASE}"
echo "::set-output name=mods::${NAME_MODS}"
echo "::set-output name=prod::${NAME_PROD}"
echo "::set-output name=work::${NAME_WORK}"
# ------------------------------------------------------------
# Artifact Import
# ------------------------------------------------------------
###
### Download and import base
###
- name: "[Artifact Load] Download base"
uses: Wandalen/wretry.action@v1.0.11
with:
action: actions/download-artifact@v3
with: |
name: ${{ steps.set-artifact-name.outputs.base }}
attempt_limit: 20
attempt_delay: 10000
if: ${{ inputs.flavour == 'mods' }}
- name: "[Artifact Load] Import base"
uses: cytopia/shell-command-retry-action@v0.1.2
with:
command: |
make load INFILE=${{ steps.set-artifact-name.outputs.base }}
if: ${{ inputs.flavour == 'mods' }}
###
### Download and import mods
###
- name: "[Artifact Load] Download mods"
uses: Wandalen/wretry.action@v1.0.11
with:
action: actions/download-artifact@v3
with: |
name: ${{ steps.set-artifact-name.outputs.mods }}
attempt_limit: 20
attempt_delay: 10000
if: ${{ inputs.flavour == 'prod' }}
- name: "[Artifact Load] Import mods"
uses: cytopia/shell-command-retry-action@v0.1.2
with:
command: |
make load INFILE=${{ steps.set-artifact-name.outputs.mods }}
if: ${{ inputs.flavour == 'prod' }}
###
### Download and import prod
###
- name: "[Artifact Load] Download prod"
uses: Wandalen/wretry.action@v1.0.11
with:
action: actions/download-artifact@v3
with: |
name: ${{ steps.set-artifact-name.outputs.prod }}
attempt_limit: 20
attempt_delay: 10000
if: ${{ inputs.flavour == 'work' }}
- name: "[Artifact Load] Import prod"
uses: cytopia/shell-command-retry-action@v0.1.2
with:
command: |
make load INFILE=${{ steps.set-artifact-name.outputs.prod }}
if: ${{ inputs.flavour == 'work' }}
# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: Test
uses: cytopia/shell-command-retry-action@v0.1.2
with:
command: |
make test VERSION=${{ matrix.version }} FLAVOUR=${{ inputs.flavour }} ARCH=${{ matrix.arch }}