mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-18 21:33:07 +02:00

The previous refactor traded build step caching for smaller image size, which in turn made fast caching of built images possible, and allowed us to speed up CI builds. But almost any change in Dockerfile required full rebuild of everything (vim & taskwarrior), so changes to the Dockerfile became more painful. This commit refactors the Dockerfile to use multi-stage builds, which brings build caching back: vim & taskwarrior are built in separate stages, which are cached step by step, and then the build artifacts are copied into the main tests image and runtime dependencies are installed. There's a catch, of course: --cache-from doesn't work with multi-stage images unless the experimental BuildKit backend and its inline cache export are enabled. This requires docker 19.03, which shouldn't be hard to obtain but isn't installed by default on Travis CI.
75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
name: tests
|
|
on: [push, pull_request]
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- _defaults: # see Dockerfile for variable defaults
|
|
- TASK_VERSION: v2.4.4
|
|
- TASK_VERSION: 2.5.2
|
|
continue-on-error: true
|
|
- TASK_VERSION: 2.6.0
|
|
- VIM_VERSION: v7.4.1546
|
|
- VIM_VERSION: v8.0.0027
|
|
- VIM_VERSION: v8.1.0519
|
|
- VIMWIKI_VERSION: dev
|
|
- PYTHON_VERSION: 3.5
|
|
- PYTHON_VERSION: 3.6
|
|
- PYTHON_VERSION: 3.7
|
|
continue-on-error: ${{ matrix.continue-on-error == true }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Prepare docker image
|
|
run: |
|
|
set -ex -o pipefail
|
|
shopt -s lastpipe
|
|
(
|
|
echo ALPINE_VERSION="$ALPINE_VERSION"
|
|
echo PYTHON_VERSION="$PYTHON_VERSION"
|
|
echo TASK_VERSION="$TASK_VERSION"
|
|
echo VIM_VERSION="$VIM_VERSION"
|
|
echo VIMWIKI_VERSION="$VIMWIKI_VERSION"
|
|
cat Dockerfile
|
|
) | sha256sum | read -r tag _
|
|
docker login "$DOCKER_REGISTRY" -u "$GITHUB_USER" -p "$GITHUB_TOKEN" || :
|
|
docker pull "$DOCKER_CACHE_IMAGE":"$tag" || :
|
|
DOCKER_BUILDKIT=1 docker build \
|
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
|
--cache-from "$DOCKER_CACHE_IMAGE":"$tag" \
|
|
${ALPINE_VERSION:+--build-arg ALPINE_VERSION="$ALPINE_VERSION"} \
|
|
${PYTHON_VERSION:+--build-arg PYTHON_VERSION="$PYTHON_VERSION"} \
|
|
${TASK_VERSION:+--build-arg TASK_VERSION="$TASK_VERSION"} \
|
|
${VIM_VERSION:+--build-arg VIM_VERSION="$VIM_VERSION"} \
|
|
${VIMWIKI_VERSION:+--build-arg VIMWIKI_VERSION="$VIMWIKI_VERSION"} \
|
|
-t taskwiki_tests \
|
|
.
|
|
docker tag taskwiki_tests "$DOCKER_CACHE_IMAGE":"$tag"
|
|
docker push "$DOCKER_CACHE_IMAGE":"$tag" || :
|
|
env:
|
|
ALPINE_VERSION: ${{ matrix.ALPINE_VERSION }}
|
|
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
|
|
TASK_VERSION: ${{ matrix.TASK_VERSION }}
|
|
VIM_VERSION: ${{ matrix.VIM_VERSION }}
|
|
VIMWIKI_VERSION: ${{ matrix.VIMWIKI_VERSION }}
|
|
DOCKER_REGISTRY: docker.pkg.github.com
|
|
DOCKER_CACHE_IMAGE: docker.pkg.github.com/${{ github.repository }}/taskwiki_tests
|
|
GITHUB_USER: ${{ github.actor }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Test
|
|
run: make test PYTEST_FLAGS="-n8"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
COVERALLS_PARALLEL: true
|
|
|
|
coveralls-finished:
|
|
needs: tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Finished
|
|
uses: coverallsapp/github-action@v1.1.1
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
parallel-finished: true
|