diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5eaaf1df..2f028266 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,16 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Need full history for voom like versions + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker Build/Push + run: | + export ${{ matrix.IMPL }} + ./ci.sh docker-build-push ${IMPL} - name: Build run: | export ${{ matrix.IMPL }} diff --git a/Makefile b/Makefile index acad2220..ff1cd7a6 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ STEP_TEST_FILES = $(strip $(wildcard \ # DOCKERIZE utility functions lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) -impl_to_image = kanaka/mal-test-$(call lc,$(1)):$(shell ./voom-like-version.sh impls/$(1)/Dockerfile) +impl_to_image = ghcr.io/kanaka/mal-test-$(call lc,$(1)):$(shell ./voom-like-version.sh impls/$(1)/Dockerfile) actual_impl = $(if $(filter mal,$(1)),$(patsubst %-mal,%,$(MAL_IMPL)),$(1)) diff --git a/ci.sh b/ci.sh index 5885ae67..ff096ed0 100755 --- a/ci.sh +++ b/ci.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex @@ -24,11 +24,23 @@ mode_var=${raw_mode_var/-/__} mode_var=${mode_var/./__} mode_val=${!mode_var} -MAKE="make ${mode_val:+${mode_var}=${mode_val}}" - log_prefix="${ACTION}${REGRESS:+-regress}-${IMPL}${mode_val:+-${mode_val}}${MAL_IMPL:+-${MAL_IMPL}}" TEST_OPTS="${TEST_OPTS} --debug-file ../../${log_prefix}.debug" +img_base="${MAL_IMPL:-${IMPL}}" +img_impl="${img_base%%-mal}" +img_name="mal-test-${img_impl,,}" +img_ver=$(./voom-like-version.sh impls/${img_impl}/Dockerfile) +IMAGE="ghcr.io/kanaka/${img_name}:${img_ver}" + +# If NO_DOCKER is blank then run make in a docker image +MAKE="make ${mode_val:+${mode_var}=${mode_val}}" +if [ -z "${NO_DOCKER}" ]; then + # We could just use make DOCKERIZE=1 instead but that does add + # non-trivial startup overhead for each step. + MAKE="docker run -i -u $(id -u) -v `pwd`:/mal ${IMAGE} ${MAKE}" +fi + # Log everything below this point: exec &> >(tee ./${log_prefix}.log) @@ -47,18 +59,18 @@ echo "IMPL: ${IMPL}" echo "BUILD_IMPL: ${BUILD_IMPL}" echo "MAL_IMPL: ${MAL_IMPL}" echo "TEST_OPTS: ${TEST_OPTS}" - -# If NO_DOCKER is blank then launch use a docker image, otherwise use -# the Travis/Github Actions image/tools directly. -if [ -z "${NO_DOCKER}" ]; then - img_impl=$(echo "${MAL_IMPL:-${IMPL}}" | tr '[:upper:]' '[:lower:]') - img_ver=$(./voom-like-version.sh impls/${img_impl}/Dockerfile) - # We could just use make DOCKERIZE=1 instead but that does add - # non-trivial startup overhead for each step. - MAKE="docker run -i -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl%%-mal}:${img_ver} ${MAKE}" -fi +echo "IMAGE: ${IMAGE}" +echo "MAKE: ${MAKE}" case "${ACTION}" in +docker-build-push) + if ! docker pull ${IMAGE}; then + make "docker-build^${MAL_IMPL:-${IMPL}}" + if [ "${GITHUB_REF}" = "refs/heads/main" ]; then + docker push ${IMAGE} + fi + fi + ;; build) # rpython often fails on step9 in compute_vars_longevity # so build step9, then continue with the full build