-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (140 loc) · 4.72 KB
/
test.yaml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: test
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
get-go-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.go-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Go version
id: go-version
run: echo "version=$(sed -n 's/^go \([0-9\.]\+\)/\1/p' go.mod)" | tee -a ${GITHUB_OUTPUT}
test-nix:
runs-on: ${{ matrix.os }}
needs: [get-go-version]
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '${{ needs.get-go-version.outputs.version }}'
- name: Set path
run: echo "$(go env GOPATH)/bin" >> ${GITHUB_PATH}
- name: Test
run: |
go vet ./...
go test ./...
- name: Install scripts
run: |
mkdir -p "$(go env GOPATH)/bin/"
cp scripts/* "$(go env GOPATH)/bin/"
- name: Post comment
run: bash .ci/upload-test.sh "GitHub Actions ${{ runner.os }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment with -overwrite-existing
if: matrix.os == 'ubuntu-latest'
run: gh-pr-comment -overwrite-existing "✔ Comment with -overwrite-existing" "Base test"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment with -stdin
if: matrix.os == 'ubuntu-latest'
run: |
date | gh-pr-comment -stdin STDIN "✔ Comment with -stdin" 'Text from stdin:
```
STDIN```'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment with -overwrite-existing (overwrite)
if: matrix.os == 'ubuntu-latest'
run: gh-pr-comment -overwrite-existing "✔ Comment with -overwrite-existing" "Overwritten"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment by GITHUB_COMMENT_TOKEN
if: matrix.os == 'ubuntu-latest'
run: gh-pr-comment -overwrite-existing "✔ Comment with GITHUB_COMMENT_TOKEN" "Text"
env:
GITHUB_TOKEN: dummy-token
GITHUB_COMMENT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR number
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master'
id: get-pr-number
uses: kamatama41/get-pr-number-action@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment from master branch
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' && steps.get-pr-number.outputs.number != ''
run: |
gh-pr-comment -pr ${PR} "✔ Comment from master branch" "PR number: ${PR}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ steps.get-pr-number.outputs.number }}
- name: Post comment with command exec wrapper
if: matrix.os == 'ubuntu-latest'
run: gh-pr-comment-exec -c -- ls -x --color=always /
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.get-pr-number.outputs.number }}
- name: Post error comment with command exec wrapper
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
run: |
if gh-pr-comment-exec -c -- false This is expected to be failed
then
echo "Expected to be failed" >&2
false
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check GoReleaser
if: runner.os == 'Linux'
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: check
test-windows:
runs-on: windows-latest
needs: [get-go-version]
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '${{ needs.get-go-version.outputs.version }}'
- name: Post comment
run: |
go install ./...
$gobin=$(Join-Path $(go env GOPATH) "bin")
$env:PATH="$gobin;" + $env:PATH
echo "Test file" > test.txt
$env:ALLOW_PUBLIC_UPLOADER="true"
$env:IMAGE_UPLOADER="test"
gh-pr-upload test.txt
if ($?) {
$upload="OK"
} else {
$upload="Failed"
}
gh-pr-comment "✔ GitHub Actions ${{ runner.os }}" "upload test: ${upload}"
if ($upload -match "Failed") {
throw
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}