-
-
Notifications
You must be signed in to change notification settings - Fork 52
118 lines (102 loc) · 3.41 KB
/
master.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Go
on: [ push ]
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Run tests with coverage
run: |
go test -v `go list ./... | grep -v example | grep -v tools` -coverprofile=coverage.tmp.txt -covermode=atomic -coverpkg=github.com/danielvladco/go-proto-gql/...
cat coverage.tmp.txt | grep -v .pb.go > coverage.txt
- name: Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
sanity_checks:
name: Sanity checks
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Go fmt
run: |
go fmt ./...
files=$(git diff --name-only)
if [[ -n $files ]]; then
echo "The following files are not formatted correctly:"
echo $files
exit 1
fi
- name: Go mod is tidy
run: |
go mod tidy
pushd example/codegen
go mod tidy
popd
pushd example/codegen/api
go mod tidy
popd
files=$(git diff --name-only)
if [[ -n $files ]]; then
echo "Detected changes to the files after mod tidy (please run `go mod tidy` and push again):"
echo $files
exit 1
fi
- name: Generated files are up to date
run: |
make
pushd example/codegen/api
make
popd
pushd example/gateway
make
popd
files=$(git diff --name-only)
if [[ -n $files ]]; then
echo "Detected changes to the files after generating (please run make and push again):"
echo $files
exit 1
fi
build_push_gateway:
name: Build & Push Gateway
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Build
run: CGO_ENABLED=0 GOOS=linux go build -v ./cmd/gateway
- name: Build and push Docker images
uses: docker/[email protected]
with:
# Username used to log in to a Docker registry. If not set then no login will occur
username: danielvladco
# Password or personal access token used to log in to a Docker registry. If not set then no login will occur
password: ${{ secrets.GITHUB_TOKEN }}
# Server address of Docker registry. If not set then will default to Docker Hub
registry: docker.pkg.github.com
# Docker repository to tag the image with
repository: ${{ github.repository }}/gateway
# Comma-delimited list of tags. These will be added to the registry/repository to form the image's tags
tag_with_sha: true
tag_with_ref: true