-
Notifications
You must be signed in to change notification settings - Fork 22
55 lines (53 loc) · 1.45 KB
/
pull_request.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
name: Check Pull Request
on:
pull_request:
#
jobs:
request:
permissions:
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
-
name: Action Checkout
uses: actions/checkout@v3
-
name: Setup Golang
uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
cache-dependency-path: ./go.sum
-
name: Go Generate
run: go generate .
-
name: Go Format
uses: actions/github-script@v7
with:
script: |
const child_process = require('child_process')
const patch = await new Promise((resolve, reject) => child_process.exec('gofmt -d .', (error, stdout, stderr) => {
if (stderr) {
console.error(stderr)
}
if (error) {
reject(error)
return
}
resolve(stdout)
}))
if (patch) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "<details><summary><h2>Change for better format</h2></summary>\n\n````````diff\n" + patch + "\n````````\n\n</details>",
})
}
-
name: Go Vet
run: go vet ./...
-
name: Go Test
run: go test -v ./...