generated from fun-stack/example
-
Notifications
You must be signed in to change notification settings - Fork 4
60 lines (55 loc) · 1.96 KB
/
build.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
name: Build
on:
push:
branches: ["master"]
tags: [v*]
pull_request:
types: [opened, synchronize]
workflow_dispatch:
permissions:
contents: read
# automatically cancel previous runs on the same PR
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre/67939898#67939898
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build:
name: "Build"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
# https://github.com/actions/checkout/issues/626
# This is correct, because we're using a merge queue (mergify) which only merges when built against the latest target branch.
# https://docs.mergify.com/actions/queue/
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- run: go build *.go
- name: Check if working directory is clean
run: git diff --quiet --exit-code || (git status && false)
lint:
name: "Lint"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
# https://github.com/actions/checkout/issues/626
# This is correct, because we're using a merge queue (mergify) which only merges when built against the latest target branch.
# https://docs.mergify.com/actions/queue/
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
- name: Check if go code is formatted
run: |
UNFORMATTED_FILES=$(gofmt -l .)
test -z $UNFORMATTED_FILES || (echo -e "Go code not formatted:\n$UNFORMATTED_FILES\n"; exit 1)