80 lines (69 loc) · 2.81 KB
/
integration.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
name: Integration tests
on: [push]
jobs:
test:
name: Integration tests
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: '1'
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v2
with:
go-version: 1.13
id: go
- name: Check out code
uses: actions/checkout@v2
# http://man7.org/linux/man-pages/man1/date.1.html
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- name: Enable caching
# We would use the official actions/cache@v2, but it doesn't save the cache if the build fails
# caches are scoped to a branch but will also check the default branch upon cache miss
uses: pat-s/always-upload-cache@v2.0.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-int-${{ steps.get-date.outputs.date }}
- name: Install Protoc
uses: arduino/setup-protoc@master
- name: Install Protoc Gen Micro
working-directory: ./cmd/protoc-gen-micro
run: go install
- name: Install Protoc Gen Go
run: go get -u github.com/golang/protobuf/protoc-gen-go
- name: Install micro
run: |
go install # this is used by the tests themselves
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
# This sets up a local docker registry to push and pull our test docker image so that we can persist
# Based on https://dev.to/dtinth/caching-docker-builds-in-github-actions-which-approach-is-the-fastest-a-research-18ei
- name: Setup docker caching
id: cache-docker
# We would use the official actions/cache@v2, but it doesn't save the cache if the build fails
# caches are scoped to a branch but will also check the default branch upon cache miss
uses: pat-s/always-upload-cache@v2.0.0
with:
path: /tmp/docker-registry
key: docker-registry-int-${{ steps.get-date.outputs.date }}
- name: Setup docker registry
run: |
docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2 && npx wait-on tcp:5000
- name: Build docker image
run: |
docker build -f test/Dockerfile . -t micro --cache-from=localhost:5000/micro --build-arg BUILDKIT_INLINE_CACHE=1
- name: Tag and push docker
run: |
docker tag micro localhost:5000/micro && docker push localhost:5000/micro || true
- name: Test micro server
working-directory: ./test
env:
GITHUB_PAT: ${{ secrets.MICRO_ACTIONS_PAT }}
GITLAB_PAT: ${{ secrets.GITLAB_PAT }}
run: |
# Generate keys for JWT tests
ssh-keygen -f /tmp/sshkey -m pkcs8 -q -N ""
ssh-keygen -f /tmp/sshkey -e -m pkcs8 > /tmp/sshkey.pub
go clean -testcache && go test --tags=integration -v -run ./...