From 1d8e98c5ecf1940277df17cc54f53199b425958f Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 28 Dec 2025 23:59:48 -0500 Subject: [PATCH] test(nginx): fix tests to work in GHA (#1372) * test(nginx): fix tests to work in GHA Closes: #1371 Signed-off-by: Xe Iaso * fix(test): does this work lol Signed-off-by: Xe Iaso * fix(test): does this other thing work lol Signed-off-by: Xe Iaso * fix(test): pki folder location Signed-off-by: Xe Iaso --------- Signed-off-by: Xe Iaso Signed-off-by: Jason Cameron Co-authored-by: Jason Cameron --- test/docker-registry/docker-compose.yaml | 2 +- test/lib/lib.sh | 75 ++++++++++++------------ test/nginx/test.sh | 15 ++--- test/palemoon/amd64/docker-compose.yml | 4 +- test/palemoon/i386/docker-compose.yml | 4 +- 5 files changed, 48 insertions(+), 52 deletions(-) diff --git a/test/docker-registry/docker-compose.yaml b/test/docker-registry/docker-compose.yaml index a1095bc..963fcea 100644 --- a/test/docker-registry/docker-compose.yaml +++ b/test/docker-registry/docker-compose.yaml @@ -14,7 +14,7 @@ services: ports: - 3004:3004 volumes: - - ../pki/registry.local.cetacean.club:/etc/techaro/pki/registry.local.cetacean.club + - ./pki/registry.local.cetacean.club:/etc/techaro/pki/registry.local.cetacean.club anubis: image: ko.local/anubis diff --git a/test/lib/lib.sh b/test/lib/lib.sh index 132848a..0317598 100644 --- a/test/lib/lib.sh +++ b/test/lib/lib.sh @@ -1,53 +1,56 @@ REPO_ROOT=$(git rev-parse --show-toplevel) (cd $REPO_ROOT && go install ./utils/cmd/...) +mkdir -p pki +echo '*' >>./pki/.gitignore + function cleanup() { - set +e + set +e - pkill -P $$ + pkill -P $$ - if [ -f "docker-compose.yaml" ]; then - docker compose down -t 1 || : - docker compose rm -f || : - fi + if [ -f "docker-compose.yaml" ]; then + docker compose down -t 1 || : + docker compose rm -f || : + fi } trap cleanup EXIT SIGINT function build_anubis_ko() { - ( - cd $REPO_ROOT && npm ci && npm run assets - ) - ( - cd $REPO_ROOT && - VERSION=devel ko build \ - --platform=all \ - --base-import-paths \ - --tags="latest" \ - --image-user=1000 \ - --image-annotation="" \ - --image-label="" \ - ./cmd/anubis \ - --local - ) + ( + cd $REPO_ROOT && npm ci && npm run assets + ) + ( + cd $REPO_ROOT && + VERSION=devel ko build \ + --platform=all \ + --base-import-paths \ + --tags="latest" \ + --image-user=1000 \ + --image-annotation="" \ + --image-label="" \ + ./cmd/anubis \ + --local + ) } function mint_cert() { - if [ "$#" -ne 1 ]; then - echo "Usage: mint_cert " - fi + if [ "$#" -ne 1 ]; then + echo "Usage: mint_cert " + fi - domainName="$1" + domainName="$1" - # If the transient local TLS certificate doesn't exist, mint a new one - if [ ! -f "${REPO_ROOT}/test/pki/${domainName}/cert.pem" ]; then - # Subshell to contain the directory change - ( - cd ${REPO_ROOT}/test/pki && - mkdir -p "${domainName}" && - go tool minica -domains "${domainName}" && - cd "${domainName}" && - chmod 666 * - ) - fi + # If the transient local TLS certificate doesn't exist, mint a new one + if [ ! -f "./pki/${domainName}/cert.pem" ]; then + # Subshell to contain the directory change + ( + cd ./pki && + mkdir -p "${domainName}" && + go tool minica -domains "${domainName}" && + cd "${domainName}" && + chmod 666 * + ) + fi } diff --git a/test/nginx/test.sh b/test/nginx/test.sh index 071479f..c9d9475 100755 --- a/test/nginx/test.sh +++ b/test/nginx/test.sh @@ -1,24 +1,17 @@ #!/usr/bin/env bash -export VERSION=$GITHUB_COMMIT-test -export KO_DOCKER_REPO=ko.local - source ../lib/lib.sh +export KO_DOCKER_REPO=ko.local + set -euo pipefail -build_anubis_ko mint_cert mimi.techaro.lol docker run --rm \ - -v ./conf/nginx:/etc/nginx:ro \ - -v ../pki:/techaro/pki:ro \ + -v $PWD/conf/nginx:/etc/nginx:ro \ + -v $PWD/pki:/techaro/pki:ro \ nginx \ nginx -t -docker compose up -d - -docker compose down -t 1 || : -docker compose rm -f || : - exit 0 diff --git a/test/palemoon/amd64/docker-compose.yml b/test/palemoon/amd64/docker-compose.yml index 9403df3..59566e3 100644 --- a/test/palemoon/amd64/docker-compose.yml +++ b/test/palemoon/amd64/docker-compose.yml @@ -26,7 +26,7 @@ services: KEY_FNAME: key.pem PROXY_TO: http://anubis:3000 volumes: - - ../../pki/relayd:/techaro/pki:ro + - ./pki/relayd:/techaro/pki:ro # novnc: # image: geek1011/easy-novnc @@ -42,7 +42,7 @@ services: environment: DISPLAY: display:0 volumes: - - ../../pki:/usr/local/share/ca-certificates/minica:ro + - ./pki:/usr/local/share/ca-certificates/minica:ro - ../scripts:/hack/scripts:ro depends_on: - anubis diff --git a/test/palemoon/i386/docker-compose.yml b/test/palemoon/i386/docker-compose.yml index cda915d..98ec72a 100644 --- a/test/palemoon/i386/docker-compose.yml +++ b/test/palemoon/i386/docker-compose.yml @@ -24,7 +24,7 @@ services: KEY_FNAME: key.pem PROXY_TO: http://anubis:3000 volumes: - - ../../pki/relayd:/techaro/pki:ro + - ./pki/relayd:/techaro/pki:ro # novnc: # image: geek1011/easy-novnc @@ -40,5 +40,5 @@ services: environment: DISPLAY: display:0 volumes: - - ../../pki:/usr/local/share/ca-certificates/minica:ro + - ./pki:/usr/local/share/ca-certificates/minica:ro - ../scripts:/hack/scripts:ro