-
Notifications
You must be signed in to change notification settings - Fork 14
201 lines (181 loc) · 7.19 KB
/
ci.yml
File metadata and controls
201 lines (181 loc) · 7.19 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: CI
on:
push:
branches: [ master , develop ]
tags: [ "v*" ]
pull_request:
branches: [ master , develop ]
jobs:
setup:
runs-on: ubuntu-latest
strategy:
matrix:
yara-version: [ "v4.3.1" ]
steps:
- uses: actions/checkout@v3
- name: Build yara
uses: ./.github/actions/install-yara
with:
yara-version: ${{ matrix.yara-version }}
cache: 'true'
skip-install: 'true'
test:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
go-version: [ "1.18", "1.19", "1.20" ]
yara-version: [ "v4.3.1" ]
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-yara
with:
yara-version: ${{ matrix.yara-version }}
cache: 'true'
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum
- name: Running unit tests
run: go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg="$coverpkg" -v $(go list ./... | grep -v /acceptanceTests)
env:
coverpkg: github.com/fkie-cad/yapscan/...
- name: Running acceptance tests
run: go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg="$coverpkg" -v -quickchecks=${QUICKCHECKS:-100} -short .
env:
coverpkg: github.com/fkie-cad/yapscan/...
working-directory: acceptanceTests
- name: Consolidating coverage
run: cat acceptanceTests/coverage.txt | tail -n+2 >> coverage.txt && rm acceptanceTests/coverage.txt
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-linux-${{ matrix.go-version }}-${{ matrix.yara-version }}
path: coverage.txt
- name: Codecov
uses: codecov/codecov-action@v3
build-linux:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
go-version: [ "1.18", "1.19", "1.20" ]
yara-version: [ "v4.3.1" ]
openssl-version: [ "OpenSSL_1_1_1-stable" ]
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-yara
with:
yara-version: ${{ matrix.yara-version }}
cache: 'true'
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum
- run: mkdir -p cicd/build/
- name: Building yapscan for linux
run: go build -trimpath -o ../../cicd/build/yapscan
working-directory: cmd/yapscan
- name: Upload linux build
uses: actions/upload-artifact@v3
if: ${{ matrix.go-version == '1.20' }}
with:
name: yapscan-linux
path: cicd/build/yapscan
- name: Gather linux deps
uses: ./.github/actions/gather-linux-deps
- name: Upload linux deps
uses: actions/upload-artifact@v3
if: ${{ matrix.go-version == '1.20' }}
with:
name: deps-linux
path: |
cicd/build/libyara.so*
cicd/build/libcrypto.so*
cicd/build/libyara.license
build-windows:
runs-on: ubuntu-latest
needs: setup
if: github.event_name != 'pull_request' # pull_request events don't have access to secrets
strategy:
matrix:
go-version: [ "1.18", "1.19", "1.20" ]
yara-version: [ "v4.3.1" ]
openssl-version: [ "OpenSSL_1_1_1-stable" ]
steps:
- uses: actions/checkout@v3
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Caching docker images
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Crossbuild for windows
uses: ./.github/actions/crossbuild-windows
with:
openssl-version: ${{ matrix.openssl-version }}
yara-version: ${{ matrix.yara-version }}
go-version: ${{ matrix.go-version }}
- name: Upload windows build
uses: actions/upload-artifact@v3
if: ${{ matrix.go-version == '1.20' }}
with:
name: yapscan-windows
path: |
cicd/build/yapscan.exe
cicd/build/yapscan.dll
cicd/build/libyara.license
release:
runs-on: ubuntu-latest
needs: [ build-linux, build-windows, test ]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- run: mkdir yapscan_linux_amd64 yapscan_windows_amd64
- name: Download linux build
uses: actions/download-artifact@v3
with:
name: yapscan-linux
path: yapscan_linux_amd64
- name: Download linux build
uses: actions/download-artifact@v3
with:
name: yapscan-linux
path: yapscan_linux_amd64
- name: Download linux dependencies
uses: actions/download-artifact@v3
with:
name: deps-linux
path: yapscan_windows_amd64
- name: Download windows build
uses: actions/download-artifact@v3
with:
name: yapscan-windows
path: yapscan_windows_amd64
- name: Create linux TAR archive
run: tar -cvf - yapscan_linux_amd64/ | zstd -12 - -o yapscan_linux_amd64.tar.zst
- name: Create linux ZIP archive
run: 7z a yapscan_linux_amd64.zip yapscan_linux_amd64/
- name: Create windows TAR archive
run: tar -cvf - yapscan_windows_amd64/ | zstd -12 - -o yapscan_windows_amd64.tar.zst
- name: Create windows ZIP archive
run: 7z a yapscan_windows_amd64.zip yapscan_windows_amd64/
- name: Create release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
yapscan_linux_amd64.tar.zst
yapscan_linux_amd64.zip
yapscan_windows_amd64.tar.zst
yapscan_windows_amd64.zip