aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-02-02 18:23:17 +0100
committerEgor Tensin <Egor.Tensin@gmail.com>2023-02-02 18:25:34 +0100
commit7cca99fd7ad119c27665488e28ceb86800afd574 (patch)
tree64f573301933e0a4ad279c2710adb51d82a22534
parentaccomodate older bash-es (diff)
downloadconfig-links-7cca99fd7ad119c27665488e28ceb86800afd574.tar.gz
config-links-7cca99fd7ad119c27665488e28ceb86800afd574.zip
add Docker tests for older bash-es
Diffstat (limited to '')
-rw-r--r--.github/workflows/ci.yml18
-rw-r--r--Makefile45
-rw-r--r--test/docker-compose.yml7
-rwxr-xr-xtest/test.sh3
4 files changed, 70 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f4954c4..2bfb964 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,7 +6,7 @@ on:
workflow_dispatch:
jobs:
- test:
+ test_local:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
@@ -26,4 +26,18 @@ jobs:
# with ancient utilities that come with the actual macOS.
- name: Test
- run: ./test/test.sh
+ run: make test
+
+ test_docker:
+ strategy:
+ matrix:
+ # Keep in sync with those in Makefile:
+ distro: [xenial, focal]
+ runs-on: ubuntu-latest
+ name: 'Test / Docker / ${{ matrix.distro }}'
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Test
+ run: make 'test/docker/${{ matrix.distro }}'
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..cf78947
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+MAKEFLAGS += --no-builtin-rules --no-builtin-variables --warn-undefined-variables
+unexport MAKEFLAGS
+.DEFAULT_GOAL := all
+.DELETE_ON_ERROR:
+.SUFFIXES:
+SHELL := bash
+.SHELLFLAGS := -eu -o pipefail -c
+
+escape = $(subst ','\'',$(1))
+
+define noexpand
+ifeq ($$(origin $(1)),environment)
+ $(1) := $$(value $(1))
+endif
+ifeq ($$(origin $(1)),environment override)
+ $(1) := $$(value $(1))
+endif
+ifeq ($$(origin $(1)),command line)
+ override $(1) := $$(value $(1))
+endif
+endef
+
+.PHONY: DO
+DO:
+
+.PHONY: all
+all: test
+
+.PHONY: test
+test: test/local
+
+.PHONY: test/all
+test/all: test/local test/docker
+
+.PHONY: test/local
+test/local:
+ ./test/test.sh
+
+test/docker/%: DO
+ cd test && \
+ DISTRO='$*' docker-compose run --rm test && \
+ docker-compose down -v
+
+.PHONY: test/docker
+test/docker: test/docker/xenial test/docker/focal
diff --git a/test/docker-compose.yml b/test/docker-compose.yml
new file mode 100644
index 0000000..2d7f094
--- /dev/null
+++ b/test/docker-compose.yml
@@ -0,0 +1,7 @@
+version: '3'
+services:
+ test:
+ image: "ubuntu:${DISTRO:-xenial}"
+ volumes:
+ - ../:/src
+ command: /src/test/test.sh
diff --git a/test/test.sh b/test/test.sh
index 05c5d65..e28f112 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
-shopt -s inherit_errexit lastpipe
+shopt -s inherit_errexit 2> /dev/null || true
+shopt -s lastpipe
script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
script_dir="$( cd -- "$script_dir" && pwd )"