From 784454d65fafcc7df0d1bb11d4b74e3febcc87fd Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Wed, 27 Sep 2023 15:08:47 +0100 Subject: [PATCH] chore: port tests to just --- .github/workflows/build_and_publish.yaml | 5 +++-- .github/workflows/tests.yaml | 5 +++-- Justfile | 26 ++++++++++++++++++++++++ Makefile | 20 ------------------ 4 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 Justfile diff --git a/.github/workflows/build_and_publish.yaml b/.github/workflows/build_and_publish.yaml index 36c8a62..2a61a5b 100644 --- a/.github/workflows/build_and_publish.yaml +++ b/.github/workflows/build_and_publish.yaml @@ -18,10 +18,11 @@ jobs: uses: actions/checkout@master - name: Build image run: make build + - uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d - name: Run tests - run: make test + run: just test - name: Run lint - run: make lint + run: just lint - name: Log into GitHub Container Registry run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin - name: Push image to GitHub Container Registry diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a8c68fd..b76093d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,7 +11,8 @@ jobs: uses: actions/checkout@master - name: Build image run: make build + - uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d - name: Run tests - run: make test + run: just test - name: Run lint - run: make lint + run: just lint diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..dd051bd --- /dev/null +++ b/Justfile @@ -0,0 +1,26 @@ +export ACTION_IMAGE_NAME := env_var_or_default('ACTION_IMAGE_NAME', "base-action") + +_default: + @just --list + +build: + make build + +# hadolint the Dockerfile +lint: + @docker pull hadolint/hadolint + @docker run --rm -i hadolint/hadolint < Dockerfile + +test: build + #!/bin/bash + set -euxo pipefail + + if test -t 0 + then + export RUN_ARGS=-it + else + export RUN_ARGS= + fi + docker run $RUN_ARGS --rm -v {{justfile_directory()}}:/tests -w /tests $ACTION_IMAGE_NAME:20.04 ./tests.sh + docker run $RUN_ARGS --rm -v {{justfile_directory()}}:/tests -w /tests $ACTION_IMAGE_NAME:22.04 ./tests.sh + ./check.sh diff --git a/Makefile b/Makefile index f7b8c7a..c092b9c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,4 @@ BASE_IMAGE_NAME ?= base-docker -ACTION_IMAGE_NAME ?= base-action -INTERACTIVE:=$(shell [ -t 0 ] && echo 1) - export DOCKER_BUILDKIT=1 export BASE_BUILD_DATE=$(shell date +'%y-%m-%dT%H:%M:%S.%3NZ') @@ -13,20 +10,3 @@ build: clean-build: ARGS=--no-cache clean-build: build - - -.PHONY: test -ifdef INTERACTIVE -test: RUN_ARGS=-it -else -test: RUN_ARGS= -endif -test: - docker run $(RUN_ARGS) --rm -v $(PWD):/tests -w /tests $(ACTION_IMAGE_NAME):20.04 ./tests.sh - docker run $(RUN_ARGS) --rm -v $(PWD):/tests -w /tests $(ACTION_IMAGE_NAME):22.04 ./tests.sh - ./check.sh - -.PHONY: lint -lint: - @docker pull hadolint/hadolint - @docker run --rm -i hadolint/hadolint < Dockerfile