-
Notifications
You must be signed in to change notification settings - Fork 26
159 lines (134 loc) · 4.03 KB
/
ci.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
149
150
151
152
153
154
155
156
157
158
159
name: CI
on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "LICENSE"
pull_request:
env:
GO_VERSION: 1.18
TINYGO_VERSION: 0.23.0
jobs:
test:
runs-on: ubuntu-20.04
steps:
# Set fetch-depth: 0 to fetch commit history and tags for use in version calculation
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0
submodules: true
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ env.GO_VERSION }}
- name: Run tests
shell: bash
run: make test
build:
runs-on: ubuntu-20.04
needs: test
steps:
# submodule needs .git folder, which is missing without installing a newer git command
# https://github.com/actions/checkout/issues/335
- name: "Install latest `git`"
run: |
sudo apt purge git -y
sudo apt-get update && sudo apt-get install -y software-properties-common make
sudo add-apt-repository ppa:git-core/ppa -y
# apt update fails to fetch some repo due to cert failure. Skip them.
sudo apt update || true; sudo apt install -y --no-install-recommends git
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0
submodules: true
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install TinyGo
run: |
wget https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo_${TINYGO_VERSION}_amd64.deb
sudo dpkg -i tinygo_${TINYGO_VERSION}_amd64.deb
export PATH=$PATH:/usr/local/bin
- name: "Cache generated .wasm file"
uses: actions/cache@v2
with:
path: |
build/main.wasm
key: ${{ runner.os }}-cache-build-${{ github.sha }}
- name: Build WASM filter
shell: bash
run: make build
- name: Install WASM
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Cargo
uses: actions-rs/cargo@v1
with:
command: install
args: wasm-tools
- name: Validate WASM output
shell: bash
run: wasm-tools validate build/main.wasm
e2e-test:
runs-on: ubuntu-20.04
needs: build
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Install func-e"
shell: bash
run: curl https://func-e.io/install.sh | bash -s -- -b /usr/local/bin
- name: "Restore the wasm files cache"
uses: actions/cache@v2
with:
path: |
build/main.wasm
key: ${{ runner.os }}-cache-build-${{ github.sha }}
- name: "Verify build"
shell: bash
run: test -f build/main.wasm
- name: "Spin up server and envoy"
shell: bash
run: |
func-e run -c e2e/envoy-config.yaml --log-level info --component-log-level wasm:debug &
- name: "Run tests"
shell: bash
run: |
./e2e/tests.sh
package:
runs-on: ubuntu-20.04
needs: e2e-test
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Restore the wasm files cache"
uses: actions/cache@v2
with:
path: |
build/main.wasm
key: ${{ runner.os }}-cache-build-${{ github.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: jcchavezs/coraza-wasm-filter:latest