|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+---
|
|
|
2
|
+
|
|
|
3
|
+name: CI
|
|
|
4
|
+
|
|
|
5
|
+on:
|
|
|
6
|
+ push:
|
|
|
7
|
+ tags:
|
|
|
8
|
+ - v*
|
|
|
9
|
+ branches:
|
|
|
10
|
+ - master
|
|
|
11
|
+ release:
|
|
|
12
|
+ types:
|
|
|
13
|
+ - published
|
|
|
14
|
+ - released
|
|
|
15
|
+ pull_request:
|
|
|
16
|
+ types:
|
|
|
17
|
+ - opened
|
|
|
18
|
+ - edited
|
|
|
19
|
+ - reopened
|
|
|
20
|
+ - synchronize
|
|
|
21
|
+ - ready_for_review
|
|
|
22
|
+
|
|
|
23
|
+jobs:
|
|
|
24
|
+ test:
|
|
|
25
|
+ name: Test
|
|
|
26
|
+ runs-on: ubuntu-latest
|
|
|
27
|
+ timeout-minutes: 5
|
|
|
28
|
+ strategy:
|
|
|
29
|
+ matrix:
|
|
|
30
|
+ go_version:
|
|
|
31
|
+ - ~1.14
|
|
|
32
|
+ - ~1.15
|
|
|
33
|
+ - ^1.16
|
|
|
34
|
+ steps:
|
|
|
35
|
+ - name: Checkout
|
|
|
36
|
+ uses: actions/checkout@v2
|
|
|
37
|
+ with:
|
|
|
38
|
+ submodules: recursive
|
|
|
39
|
+
|
|
|
40
|
+ - name: Setup Go
|
|
|
41
|
+ uses: actions/setup-go@v2
|
|
|
42
|
+ with:
|
|
|
43
|
+ go-version: ${{ matrix.go_version }}
|
|
|
44
|
+
|
|
|
45
|
+ - name: Cache dependencies
|
|
|
46
|
+ uses: actions/cache@v2
|
|
|
47
|
+ with:
|
|
|
48
|
+ path: ~/go/pkg/mod
|
|
|
49
|
+ key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
50
|
+ restore-keys: ${{ runner.os }}-go-
|
|
|
51
|
+
|
|
|
52
|
+ - name: Run tests
|
|
|
53
|
+ run: go test -coverprofile=./coverage.txt -covermode=atomic -v ./...
|
|
|
54
|
+
|
|
|
55
|
+ - name: Collect coverage
|
|
|
56
|
+ uses: codecov/codecov-action@v1
|
|
|
57
|
+ with:
|
|
|
58
|
+ file: ./coverage.txt
|
|
|
59
|
+
|
|
|
60
|
+ lint:
|
|
|
61
|
+ name: Lint
|
|
|
62
|
+ runs-on: ubuntu-latest
|
|
|
63
|
+ timeout-minutes: 5
|
|
|
64
|
+ steps:
|
|
|
65
|
+ - name: Checkout
|
|
|
66
|
+ uses: actions/checkout@v2
|
|
|
67
|
+ with:
|
|
|
68
|
+ submodules: recursive
|
|
|
69
|
+
|
|
|
70
|
+ - name: Run linter
|
|
|
71
|
+ uses: golangci/golangci-lint-action@v2
|
|
|
72
|
+ with:
|
|
|
73
|
+ version: v1.37.1
|
|
|
74
|
+
|
|
|
75
|
+ docker:
|
|
|
76
|
+ name: Docker
|
|
|
77
|
+ runs-on: ubuntu-latest
|
|
|
78
|
+ timeout-minutes: 15
|
|
|
79
|
+ steps:
|
|
|
80
|
+ - name: Checkout
|
|
|
81
|
+ uses: actions/checkout@v2
|
|
|
82
|
+ with:
|
|
|
83
|
+ submodules: recursive
|
|
|
84
|
+
|
|
|
85
|
+ - name: Get Docker meta
|
|
|
86
|
+ id: docker_meta
|
|
|
87
|
+ uses: crazy-max/ghaction-docker-meta@v1
|
|
|
88
|
+ with:
|
|
|
89
|
+ images: nineseconds/mtg,ghcr.io/9seconds/mtg
|
|
|
90
|
+ tag-semver: "{{version}},{{major}},{{major}}.{{minor}}"
|
|
|
91
|
+
|
|
|
92
|
+ - name: Setup QEMU
|
|
|
93
|
+ uses: docker/setup-qemu-action@v1
|
|
|
94
|
+
|
|
|
95
|
+ - name: Setup BuildX
|
|
|
96
|
+ uses: docker/setup-buildx-action@v1
|
|
|
97
|
+
|
|
|
98
|
+ - name: Setup cache
|
|
|
99
|
+ uses: actions/cache@v2
|
|
|
100
|
+ with:
|
|
|
101
|
+ path: /tmp/buildx-cache
|
|
|
102
|
+ key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
103
|
+ restore-keys: |
|
|
|
104
|
+ ${{ runner.os }}-buildx-
|
|
|
105
|
+
|
|
|
106
|
+ - name: Login to DockerHub
|
|
|
107
|
+ if: github.event_name != 'pull_request'
|
|
|
108
|
+ uses: docker/login-action@v1
|
|
|
109
|
+ with:
|
|
|
110
|
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
111
|
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
112
|
+
|
|
|
113
|
+ - name: Login to GHCR.io
|
|
|
114
|
+ if: github.event_name != 'pull_request'
|
|
|
115
|
+ uses: docker/login-action@v1
|
|
|
116
|
+ with:
|
|
|
117
|
+ registry: ghcr.io
|
|
|
118
|
+ username: ${{ github.repository_owner }}
|
|
|
119
|
+ password: ${{ secrets.GH_PAT }}
|
|
|
120
|
+
|
|
|
121
|
+ - name: Build and push
|
|
|
122
|
+ uses: docker/build-push-action@v2
|
|
|
123
|
+ with:
|
|
|
124
|
+ pull: true
|
|
|
125
|
+ context: .
|
|
|
126
|
+ platforms: linux/amd64,linux/arm64,linux/386
|
|
|
127
|
+ push: ${{ github.event_name != 'pull_request' }}
|
|
|
128
|
+ tags: ${{ steps.docker_meta.outputs.tags }}
|
|
|
129
|
+ labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
130
|
+ cache-from: type=local,src=/tmp/buildx-cache
|
|
|
131
|
+ cache-to: type=local,dest=/tmp/buildx-cache
|