From 80445420441e878e455abc8737d2bb787cf65c1e Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sat, 31 Dec 2022 10:53:37 +0100 Subject: [PATCH] feat(ci): add test task --- .concourse/branch-validate.yml | 4 ++++ .concourse/tasks/lint.yml | 31 ++++++++++++------------- .concourse/tasks/test.yml | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 .concourse/tasks/test.yml diff --git a/.concourse/branch-validate.yml b/.concourse/branch-validate.yml index 78ff93f..58ec4d1 100644 --- a/.concourse/branch-validate.yml +++ b/.concourse/branch-validate.yml @@ -14,4 +14,8 @@ jobs: trigger: true - task: lint file: nurse.git/.concourse/tasks/lint.yml + input_mapping: {repo: nurse.git} + - task: test + file: nurse.git/.concourse/tasks/test.yml + privileged: true input_mapping: {repo: nurse.git} \ No newline at end of file diff --git a/.concourse/tasks/lint.yml b/.concourse/tasks/lint.yml index 06d5be0..b5cac09 100644 --- a/.concourse/tasks/lint.yml +++ b/.concourse/tasks/lint.yml @@ -2,26 +2,23 @@ platform: linux image_resource: - type: registry-image - source: - repository: docker.io/golang:1.19-bullseye - tag: latest + type: registry-image + source: + repository: docker.io/golangci/golangci-lint + tag: latest inputs: - - name: repo - path: . + - name: repo + path: . params: - GO111MODULE: "on" - CGO_ENABLED: "0" - GITEA_TOKEN: ((gitea-credentials.token)) - DOCKER_HOST: tcp://127.0.0.1:2375 + GO111MODULE: "on" + CGO_ENABLED: "0" + GITEA_TOKEN: ((gitea-credentials.token)) run: - path: sh - args: - - -ce - - | - apk add -U --no-cache curl - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin - go run github.com/magefile/mage lint + path: bash + args: + - -ce + - | + go run github.com/magefile/mage lint diff --git a/.concourse/tasks/test.yml b/.concourse/tasks/test.yml new file mode 100644 index 0000000..2c59eb7 --- /dev/null +++ b/.concourse/tasks/test.yml @@ -0,0 +1,41 @@ +--- +platform: linux + +image_resource: + type: registry-image + source: + repository: code.icb4dc0.de/prskr/pipelines/dind-go + tag: latest + username: ((gitea-credentials.user)) + password: ((gitea-credentials.token)) + +inputs: + - name: repo + path: . + +params: + GO111MODULE: "on" + CGO_ENABLED: "1" + DOCKER_HOST: tcp://127.0.0.1:2375 + GITEA_TOKEN: ((gitea-credentials.token)) + +run: + path: bash + args: + - -ce + - | + dockerd -H $DOCKER_HOST >/tmp/docker.log 2>&1 & + echo $! > /tmp/docker.pid + + go install gotest.tools/gotestsum@latest + + echo waiting for docker to come up... + until docker info >/dev/null 2>&1; do + sleep 1 + if ! kill -0 "$(cat /tmp/docker.pid)" 2>/dev/null; then + cat /tmp/docker.log + return 1 + fi + done + + gotestsum -f pkgname-and-test-fails -- -race -shuffle=on ./...