-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (83 loc) · 2.74 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
name: Main
on: [push, pull_request]
jobs:
go-tests:
runs-on: self-hosted
container:
image: golang:1.17.1
options: --user 1000
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Go test
env:
TEST_DB_HOST: postgres
TEST_DB_PORT: 5432
run: |
# we run vet in another step
go test -coverpkg=./... -vet=off -timeout=1m -coverprofile=covprofile ./...
# -race can easily make the crypto stuff 10x slower
go test -vet=off -timeout=10m -race ./...
- name: Debug on failure
if: failure()
uses: mxschmitt/action-tmate@v3
- name: Go analyze
run: |
diff -u <(echo -n) <(gofmt -s -d $(git ls-files '*.go'))
go vet ./...
curl -L https://github.com/dominikh/go-tools/releases/download/2020.2.3/staticcheck_linux_amd64.tar.gz | tar -xzf -
./staticcheck/staticcheck ./...
- name: Install goveralls
env:
GO111MODULE: off
run: go get github.com/mattn/goveralls
- name: Send coverage to coverall.io
env:
COVERALLS_TOKEN: ${{ secrets.github_token }}
run: goveralls -coverprofile=covprofile -service=github
docker-release:
runs-on: self-hosted
needs: [go-tests]
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/stage' || startsWith(github.ref, 'refs/heads/release')
steps:
- name: Check out the repo
uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Get short branch name
id: var
shell: bash
# Grab the short branch name, convert slashes to dashes
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-' )"
- name: Push to ghcr.io
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: |
ghcr.io/vocdoni/${{ github.event.repository.name }}:latest,ghcr.io/vocdoni/${{ github.event.repository.name }}:${{ steps.var.outputs.branch }}