-
Notifications
You must be signed in to change notification settings - Fork 5
109 lines (91 loc) · 2.83 KB
/
build-test.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
name: Build and test Caddy with WAF (test)
on:
push:
branches:
- test
pull_request:
branches:
- test
workflow_dispatch:
jobs:
build-and-test:
name: Build and Test Caddy WAF
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y wget git build-essential
- name: Install Go 1.23.4
uses: actions/setup-go@v4
with:
go-version: '1.23.4'
- name: Validate Go Installation
run: |
go version
if ! go version | grep -q "go1.23.4"; then
echo "Go installation failed or incorrect version"
exit 1
fi
- name: Clone caddy-waf Repository (test)
run: |
git clone --branch test https://github.com/fabriziosalmi/caddy-waf.git
cd caddy-waf
- name: Validate Repository Cloning
run: |
if [ ! -d "caddy-waf" ]; then
echo "Repository cloning failed"
exit 1
fi
- name: Install Go Dependencies
run: |
cd caddy-waf
go mod tidy
go get -v github.com/fabriziosalmi/caddy-waf github.com/caddyserver/caddy/v2 github.com/oschwald/maxminddb-golang
- name: Download GeoLite2 Country Database
run: |
cd caddy-waf
wget https://git.io/GeoLite2-Country.mmdb
- name: Validate GeoLite2 Download
run: |
cd caddy-waf
if [ ! -f "GeoLite2-Country.mmdb" ]; then
echo "GeoLite2 database download failed"
exit 1
fi
- name: Build Caddy with caddy-waf
run: |
cd caddy-waf
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
xcaddy build --with github.com/fabriziosalmi/caddy-waf=./
- name: Validate Build
run: |
cd caddy-waf
if [ ! -f "caddy" ]; then
echo "Caddy build failed"
exit 1
fi
- name: Test Caddy Run and Validate WAF Provisioning
run: |
cd caddy-waf
chmod +x caddy
./caddy run > caddy_output.log 2>&1 &
sleep 5
if ! pgrep -f "caddy run"; then
echo "Caddy run failed"
cat caddy_output.log
exit 1
fi
if ! grep -q "WAF middleware provisioned successfully" caddy_output.log; then
echo "WAF provisioning log not found"
cat caddy_output.log
exit 1
fi
echo "Caddy WAF build and run successful with WAF middleware provisioned"
- name: Clean Up
if: always()
run: |
pkill -f "caddy run" || true
echo "Cleaned up running Caddy instances"