Skip to content

Be ready for production. (#7) #113

Be ready for production. (#7)

Be ready for production. (#7) #113

Workflow file for this run

name: CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
check-latest: true
- run: |
go version
go get
- name: Go test and benchmark
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
( make benchmark && make test ) | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: |
go version
go get
- run: make build
- name: Extract short commit SHA
id: short-sha
run: echo "value=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# Upload some useful binaries for debug
- uses: actions/upload-artifact@v4
with:
name: fingerproxy_darwin_arm64_${{ steps.short-sha.outputs.value }}
path: bin/fingerproxy_darwin_arm64
- uses: actions/upload-artifact@v4
with:
name: fingerproxy_linux_amd64_${{ steps.short-sha.outputs.value }}
path: bin/fingerproxy_linux_amd64
build-test-deps:
name: Build test deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
check-latest: true
- name: Build
run: |
go version
go get
go build -o echo-server -tags debug ./example/echo-server
go build -o fingerproxy -tags debug ./cmd
go build -C ./e2e/memtest/ -o $PWD/e2e-memtest .
./testdata/gencert.sh
- uses: actions/upload-artifact@v4
with:
name: ci-test-deps
path: |
echo-server
fingerproxy
e2e-memtest
tls.crt
tls.key
e2e-test:
name: E2E test
runs-on: ubuntu-latest
needs: build-test-deps
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-test-deps
- name: Setup curl
run: |
wget https://github.com/stunnel/static-curl/releases/download/8.6.0-1/curl-linux-x86_64-8.6.0.tar.xz
tar xf curl-linux-x86_64-8.6.0.tar.xz
./curl --version
- name: Test
run: |
chmod +x ./fingerproxy
./fingerproxy -verbose \
-listen-addr localhost:8443 \
-forward-url https://httpbin.org \
-preserve-host &
sleep 1
./curl -v --fail --insecure -o o.json "https://localhost:8443/anything?show_env=1"
cat o.json | jq
test $(jq -r '.headers."Host"' o.json) = "localhost"
test $(jq -r '.headers."X-Forwarded-Host"' o.json) = "localhost:8443"
test $(jq -r '.headers."X-Forwarded-Port"' o.json) = "443"
test $(jq -r '.headers."X-Forwarded-Proto"' o.json) = "https"
test $(jq -r '.headers."X-Http2-Fingerprint"' o.json) = "3:100;4:10485760;2:0|1048510465|0|m,s,a,p"
test $(jq -r '.headers."X-Ja3-Fingerprint"' o.json) = "0149f47eabf9a20d0893e2a44e5a6323"
test $(jq -r '.headers."X-Ja4-Fingerprint"' o.json) = "t13d3112h2_e8f1e7e78f70_6bebaf5329ac"
test $(jq -r '.headers."User-Agent"' o.json) = "curl/8.6.0"
e2e-webbrowser:
name: E2E web browser test
runs-on: ubuntu-latest
needs: build-test-deps
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-test-deps
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Test
run: |
chmod +x ./fingerproxy
./fingerproxy -verbose \
-listen-addr localhost:8443 \
-forward-url https://httpbin.org \
-preserve-host &
cd ./e2e/webbrowser
pip install --user pipenv
pipenv install
pipenv run pytest -s
e2e-memtest:
name: E2E memtest
runs-on: ubuntu-latest
needs: build-test-deps
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-test-deps
- name: Test
run: |
chmod +x ./fingerproxy
chmod +x ./e2e-memtest
./fingerproxy \
-listen-addr localhost:8443 \
-forward-url http://localhost:8000 &
sleep 1
./e2e-memtest | tee -a $GITHUB_STEP_SUMMARY
echo-load-test:
name: Echo load test
runs-on: ubuntu-latest
needs: build-test-deps
strategy:
matrix:
number_of_requests: [1000, 10000, 50000]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-test-deps
- name: Setup ab
run: |
sudo apt-get install -y apache2-utils
ab -V
- name: Test
run: |
chmod +x ./echo-server
./echo-server &
sleep 1
(
printf '> ' && cat /proc/$!/status | grep VmRSS
echo "<details><summary>ab result</summary>"
ab -n ${{ matrix.number_of_requests }} -c 10 https://localhost:8443/
echo "</details>"
echo
printf '> ' && cat /proc/$!/status | grep VmRSS
) | tee -a $GITHUB_STEP_SUMMARY
echo-benchmark:
name: Echo benchmark
runs-on: ubuntu-latest
needs: build-test-deps
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-test-deps
- name: Setup wrk
run: |
sudo apt-get install -y wrk
wrk --version || true
- name: Benchmark
run: |
chmod +x ./echo-server
bench() {
(
printf '> ' && cat /proc/$!/status | grep VmRSS
echo '```'
wrk -d 30 -c 10 https://localhost:8443/
echo '```'
printf '> ' && cat /proc/$!/status | grep VmRSS
) | tee -a $GITHUB_STEP_SUMMARY
}
./echo-server &
sleep 1
echo "### echo server" >> $GITHUB_STEP_SUMMARY
bench
kill $!
sleep 1
./echo-server --benchmark-control-group &
sleep 1
echo "### control group" >> $GITHUB_STEP_SUMMARY
bench