GitHub actions migration (#540)

This commit is contained in:
Dan Sosedoff 2021-12-25 11:31:41 -06:00 committed by GitHub
parent b1b50045a5
commit ccfa3497f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 27 deletions

57
.github/workflows/checks.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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)
}
}
}