mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 17:44:49 +02:00
ci: improve GitHub Action CI with re-usable workflows (#2753)
Mew re-usable workflows are introduced to handle building, testing and publishing the container image in a uniform and easy way. Now, the `scheduled_builds`, `default_on_push` and a part of the `test_merge_requests` workflow can use the same code for building, testing and publishing the container images. This is DRY. Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
parent
8bc8fc873c
commit
f8e1bb0f42
6 changed files with 303 additions and 308 deletions
54
.github/workflows/generic_test.yml
vendored
Normal file
54
.github/workflows/generic_test.yml
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
name: 'Test the DMS Container Image'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
cache-key:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run-tests:
|
||||
name: 'Test'
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# Required to retrieve bats (core + extras):
|
||||
submodules: recursive
|
||||
|
||||
# Get the cached build layers from the build job:
|
||||
# This should always be a cache-hit, thus `restore-keys` fallback is not used.
|
||||
# No new cache uploads should ever happen for this job.
|
||||
- name: 'Retrieve image built from build cache'
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: cache-buildx-${{ inputs.cache-key }}
|
||||
|
||||
# Importing from the cache should create the image within approx 30 seconds:
|
||||
# Earlier `buildx` + `qemu` steps are not needed as no cache is exported,
|
||||
# and only a single platform (AMD64) is loaded:
|
||||
- name: 'Build AMD64 image from cache'
|
||||
uses: docker/build-push-action@v3.1.1
|
||||
with:
|
||||
context: .
|
||||
build-args: |
|
||||
VCS_REF=${{ github.sha }}
|
||||
VCS_VER=${{ github.ref }}
|
||||
tags: mailserver-testing:ci
|
||||
# Export the built image to the Docker host for use with BATS:
|
||||
load: true
|
||||
# Rebuilds the AMD64 image from the cache:
|
||||
platforms: linux/amd64
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
|
||||
- name: 'Run tests'
|
||||
run: make generate-accounts tests
|
||||
env:
|
||||
CI: true
|
||||
NAME: mailserver-testing:ci
|
Loading…
Add table
Add a link
Reference in a new issue