-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.62 KB
/
test.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
on:
workflow_run:
workflows:
- "Lint"
branches:
- '*'
types:
- completed
name: Test
jobs:
tests:
if: "${{ github.event.workflow_run.conclusion == 'success' && !contains(github.event.commits[0].message, 'chore(release):') }}"
strategy:
matrix:
go-version: [ 1.14.x ]
# platform: [ macos-latest, ubuntu-latest ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Configure Docker
uses: docker-practice/actions-setup-docker@master
- name: Run MongoDB Container
if: ${{ matrix.platform == 'ubuntu-latest' }} || ${{ matrix.platform == 'macos-latest' }}
run: |
docker run --name mongo -d -e MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME}} -e MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD}} -p 27017:27017 mongo:${{ env.MONGODB_VERSION }}
env:
MONGODB_VERSION: 5.0.5
- name: Test
run: |
go test -coverprofile="${{ matrix.platform }}_coverage.out" -covermode=atomic -coverpkg=./... ./...
go tool cover -func="${{ matrix.platform }}_coverage.out"
env:
PUSH_OVER_NOTIFICATION_TOKEN: ${{ secrets.PUSH_OVER_NOTIFICATION_TOKEN }}
PUSH_OVER_NOTIFICATION_USER: ${{ secrets.PUSH_OVER_NOTIFICATION_USER }}
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_INITDB_ROOT_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}
- name: "Upload overage to Codecov"
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
- name: Upload coverage report
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.platform }}_coverage
path: ${{ matrix.platform }}_coverage.out
coverage:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- name: Download coverage report
uses: actions/download-artifact@v1
with:
name: ubuntu-latest_coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}