author | Alberto Bertogli
<albertito@blitiri.com.ar> 2021-03-10 10:56:13 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2021-03-10 11:33:56 UTC |
parent | 27d6e66e934c17b99cf2e87b8e332d3dd4e5b775 |
.gitlab-ci.yml | +55 | -0 |
.travis.yml | +0 | -32 |
README.md | +1 | -1 |
tests/Dockerfile | +39 | -0 |
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..acdec83 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,55 @@ +# Configuration for the GitLab CI. + +stages: + - test + +# Go tests, on various Go versions. +.golang_template: &golang + stage: test + script: + - go test ./... + - go test -race ./... + +golang_1.13: + <<: *golang + image: golang:1.13 # Oldest supported version (for now). + +golang_latest: + <<: *golang + image: golang:latest + + +# Integration test, using the module versions from the repository. +integration_stable: + stage: test + image: docker:stable + services: + - docker:dind + script: + - docker build -t dnss-test -f tests/Dockerfile . + - docker run --name test1 dnss-test + after_script: + - docker cp test1:/go/src/blitiri.com.ar/go/dnss docker-out/ + artifacts: + when: always + expire_in: 1 hour + paths: + - docker-out/ + + +# Integration test, using the latest module versions. +integration_latest: + stage: test + image: docker:stable + services: + - docker:dind + script: + - docker build -t dnss-test --build-arg GO_GET_ARGS="-u=patch" -f tests/Dockerfile . + - docker run --name test1 dnss-test + after_script: + - docker cp test1:/go/src/blitiri.com.ar/go/dnss docker-out/ + artifacts: + when: always + expire_in: 1 hour + paths: + - docker-out/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8688fb8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Configuration for https://travis-ci.org/ - -language: go -go_import_path: blitiri.com.ar/go/dnss -dist: bionic - -jobs: - include: - - name: "go 1.11 (debian stable)" - go: 1.11.x - # Enable Go modules explicitly on Go 1.11. - # Some packages update in backwards-incompatible ways assuming Go - # modules are in use, which can break the build unexpectedly. - env: GO111MODULE=on - - name: "go stable" - go: stable - - name: "go tip" - go: master - allow_failures: - # There is a bug in the Travis environment where it can't reach certain - # hosts that host Go package dependencies. - # This manifests only in Go 1.11, since subsequent versions use the public - # proxy which has no problems. - # Make the build optional until the issue is fixed. - - go: 1.11.x - - -script: - - go test ./... - - go test -bench . ./... - - go test -race -bench . ./... - diff --git a/README.md b/README.md index 8472465..9118ee1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ on laptops and small/home networks. It can also act as a DoH server, in case you want end to end control. -[![Build Status](https://travis-ci.org/albertito/dnss.svg?branch=master)](https://travis-ci.org/albertito/dnss) +[![Build Status](https://gitlab.com/albertito/dnss/badges/master/pipeline.svg)](https://gitlab.com/albertito/dnss/-/pipelines) [![Go Report Card](https://goreportcard.com/badge/github.com/albertito/dnss)](https://goreportcard.com/report/github.com/albertito/dnss) diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000..d4b52ce --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,39 @@ +# Docker file for creating a docker container that can run the tests. +# +# Create the image: +# docker build -t dnss-test -f tests/Dockerfile . +# +# Run the tests: +# docker run --rm dnss-test +# +# Get a shell inside the image (for debugging): +# docker run -it --entrypoint=/bin/bash dnss-test + +FROM golang:latest + +WORKDIR /go/src/blitiri.com.ar/go/dnss + +# Make debconf/frontend non-interactive, to avoid distracting output about the +# lack of $TERM. +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -q + +# Install the required packages for the integration tests. +RUN apt-get install -y -q knot-dnsutils systemd + +# Copy into the container. Everything below this line will not be cached. +COPY . . + +# Update dependencies to the latest versions, and fetch them to the cache. +# Fetch dependencies to the cache, because we might not have external network +# access once we are running. +# $GO_GET_ARGS allows to create a variant that updates the dependencies to the +# latest versions, for testing. +RUN go get -d -v ${GO_GET_ARGS} ./... && go mod download + +# Install dnss, to make sure it is ready to be tested. +RUN go get -d -v . && go install -v . + +# Run all the tests. +CMD tests/all.sh