-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 1.5 KB
/
go.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
name: go lib
# define triggers
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
# agent
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
persist-credentials: false
- name: set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: install dependencies
run: go mod tidy
- name: run tests, generate coverage report
run: |
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
- name: deploy to pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
cd gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
cp ../coverage.html .
git add coverage.html
# commit changes, if any
if git diff-index --quiet HEAD; then
echo "No changes to commit"
else
git commit -m 'Update test report'
git push origin gh-pages
fi