From ccfa3497f3e923fbcc0044e7b06df589c287c3ea Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Sat, 25 Dec 2021 11:31:41 -0600 Subject: [PATCH] GitHub actions migration (#540) --- .github/workflows/checks.yml | 57 ++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ---------------- pkg/api/api_test.go | 15 +++++++++- 3 files changed, 71 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/checks.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..b2cc5ab --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,57 @@ +name: checks + +on: + - pull_request + - push + +env: + GO_VERSION: 1.17 + CGO_ENABLED: 0 + +jobs: + tests: + name: tests + runs-on: ubuntu-latest + services: + postgres: + image: postgres:12 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: booktown + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - run: go mod download + - run: make test + env: + MallocNanoZone: 0 # https://github.com/golang/go/issues/49138 + CGO_ENABLED: 1 + PGHOST: localhost + PGUSER: postgres + PGPASSWORD: postgres + PGDATABASE: booktown + + fmt: + name: fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - run: go mod download + - run: script/check_formatting.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0d23583..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -sudo: required -dist: trusty -group: deprecated-2017Q4 - -language: go - -services: - - docker - -addons: - postgresql: "9.6" - -go: - - "1.16" - -before_install: - - ./script/check_formatting.sh - -install: - - make setup - -script: - - make build - - make test - - make test-all - - make docker-release \ No newline at end of file diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index d717122..bb8a7f2 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -21,7 +21,20 @@ func Test_assetContentType(t *testing.T) { "foo": "text/plain; charset=utf-8", } + alternatives := map[string]string{ + "foo.js": "text/javascript; charset=utf-8", + } + for name, expected := range samples { - assert.Equal(t, expected, assetContentType(name)) + if alternatives[name] == "" { + assert.Equal(t, expected, assetContentType(name)) + continue + } + + actual := assetContentType(name) + + if actual != expected && actual != alternatives[name] { + t.Errorf("expected %v but got %v (alternative value failed)", expected, actual) + } } }