-
-
Notifications
You must be signed in to change notification settings - Fork 171
125 lines (101 loc) · 2.88 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
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
name: Compile & Test
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Compile binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18.x
- name: Compile
run: CGO_ENABLED=0 go build -a -installsuffix cgo -o prometheus-nginxlog-exporter .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: prometheus-nginxlog-exporter
tests_unit:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18.x
- name: Run unit tests
run: go test ./...
test_acceptance:
name: Run acceptance tests
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install Behave
run: pip install behave requests
- uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Link built file to cwd
run: |
cp build/prometheus-nginxlog-exporter .
chmod +x ./prometheus-nginxlog-exporter
- name: Run acceptance tests
run: behave
test_release:
name: Test release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18.x
- name: Validate Goreleaser config
uses: goreleaser/goreleaser-action@v5
with:
version: v1.11.5
args: check
- name: Set current date
id: set_date
run: |
echo "BUILD_DATE=$(date)" >> $GITHUB_ENV
- name: Generate temporary dummy key for signing
run: |
sudo apt-get update
sudo apt-get install -y gnupg
export GNUPGHOME=/tmp
gpg --batch --gen-key <<EOF
%no-protection
Key-Type: default
Key-Length: 2048
Subkey-Type: default
Subkey-Length: 2048
Name-Real: Github Action
Name-Email: [email protected]
Expire-Date: seconds=120
EOF
gpg --export-secret-key --armor [email protected] > /tmp/signing-key
- name: Build Goreleaser snapshot release
uses: goreleaser/goreleaser-action@v5
with:
version: v1.11.5
args: release --rm-dist --skip-publish --snapshot
env:
BUILD_USER: ${{ github.actor }} (via Github Actions)