From 040e08219edb835ca89376e9cbeb6da7d82b3178 Mon Sep 17 00:00:00 2001 From: danthe1st Date: Wed, 28 Feb 2024 10:10:30 +0100 Subject: [PATCH] verify executable on CI build --- .github/scripts/verifyExecutable.sh | 26 ++++++++++++++++++++++++++ .github/workflows/build.yml | 5 +++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/verifyExecutable.sh diff --git a/.github/scripts/verifyExecutable.sh b/.github/scripts/verifyExecutable.sh new file mode 100755 index 0000000..ce0437e --- /dev/null +++ b/.github/scripts/verifyExecutable.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +./certs.sh + +./target/https-intercept > intercept.log 2>&1 & +sleep 1 +interceptPID="$!" + +curl_result="$(curl --connect-to example.com:1337:127.0.0.1 https://example.com:1337 --cacert root.pem -i)" + +kill "$interceptPID" + +statusCode="$(echo "$curl_result" | head -n 1 | cut -d' ' -f2)" + +# assert successful response +if [ "$statusCode" -ne 200 ]; then + echo "status code does not match!" + exit 1 +fi + +# assert text Example Domain in response +echo "$curl_result" | grep "Example Domain" + +cat intercept.log +rm intercept.log \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ae3cfc..fe4ca67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,6 @@ jobs: with: distribution: 'graalvm' java-version: '21' - components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} cache: 'maven' - name: Build image @@ -19,4 +18,6 @@ jobs: - uses: actions/upload-artifact@v4 with: path: target/https-intercept - if-no-files-found: error \ No newline at end of file + if-no-files-found: error + - name: verify executable + run: ./.github/scripts/verifyExecutable.sh