From 9df65941a05ea8e16004302817e03a0a6051a110 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 16 Oct 2021 08:44:51 +0200 Subject: [PATCH] Switch from Travis to GitHub Actions --- .github/workflows/go.yml | 31 +++++++++++++++++++++++++++++++ .travis.yml | 22 ---------------------- 2 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..28cf256 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Ensure all files were formatted as per gofmt + run: | + [ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ] + + - name: install binaries + run: go install github.com/google/dnsmasq_exporter + + - name: build tests + run: go test -c + + - name: docker build + run: docker build --pull --no-cache --rm -t=dns -f travis/Dockerfile . + + - name: run tests in docker + run: docker run -v $PWD:/usr/src:ro dns /bin/sh -c './dnsmasq_exporter.test -test.v' + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a6c8310..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Use the (faster) container-based infrastructure, see also -# http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -sudo: false -dist: trusty -services: - - docker - -language: go -go: - - "1.17" -go_import_path: github.com/stapelberg/dnsmasq_exporter - - -script: - # Check whether files are syntactically correct. - - "gofmt -l $(find . -name '*.go' | tr '\\n' ' ') >/dev/null" - # Check whether files were not gofmt'ed. - - "gosrc=$(find . -name '*.go' | tr '\\n' ' '); [ $(gofmt -l $gosrc 2>&- | wc -l) -eq 0 ] || (echo 'gofmt was not run on these files:'; gofmt -l $gosrc 2>&-; false)" - - go vet . - - go test -c - - docker build --pull --no-cache --rm -t=dns -f travis/Dockerfile . - - docker run -v $PWD:/usr/src:ro dns /bin/sh -c './dnsmasq_exporter.test -test.v'