Skip to content

Commit

Permalink
lifecycle: better pre release test (cherry-pick #12806) (#12808)
Browse files Browse the repository at this point in the history
lifecycle: better pre release test (#12806)

* move pre-release docker test to script



* set pipefail in ak



* don't reinstall wheels since they don't exist anymore



* fix image



* fix config error on startup



---------

Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Jens L. <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and BeryJu authored Jan 25, 2025
1 parent 7afc59d commit 764b211
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ jobs:
- uses: actions/checkout@v4
- name: Pre-release test
run: |
echo "PG_PASS=$(openssl rand 32 | base64 -w 0)" >> .env
echo "AUTHENTIK_SECRET_KEY=$(openssl rand 32 | base64 -w 0)" >> .env
docker buildx install
mkdir -p ./gen-ts-api
docker build -t testing:latest .
echo "AUTHENTIK_IMAGE=testing" >> .env
echo "AUTHENTIK_TAG=latest" >> .env
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all
make test-docker
- id: generate_token
uses: tibdex/github-app-token@v2
with:
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ help: ## Show this help
go-test:
go test -timeout 0 -v -race -cover ./...

test-docker: ## Run all tests in a docker-compose
echo "PG_PASS=$(shell openssl rand 32 | base64 -w 0)" >> .env
echo "AUTHENTIK_SECRET_KEY=$(shell openssl rand 32 | base64 -w 0)" >> .env
docker compose pull -q
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all
rm -f .env

test: ## Run the server tests and produce a coverage report (locally)
coverage run manage.py test --keepdb authentik
coverage html
Expand Down Expand Up @@ -263,6 +254,9 @@ docker: ## Build a docker image of the current source tree
mkdir -p ${GEN_API_TS}
DOCKER_BUILDKIT=1 docker build . --progress plain --tag ${DOCKER_IMAGE}

test-docker:
./scripts/test_docker.sh

#########################
## CI
#########################
Expand Down
3 changes: 2 additions & 1 deletion authentik/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ def get_int(self, path: str, default=0) -> int:
def get_optional_int(self, path: str, default=None) -> int | None:
"""Wrapper for get that converts value into int or None if set"""
value = self.get(path, default)

if value is UNSET:
return default
try:
return int(value)
except (ValueError, TypeError) as exc:
Expand Down
4 changes: 2 additions & 2 deletions lifecycle/ak
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env -S bash -e
#!/usr/bin/env -S bash
set -e -o pipefail
MODE_FILE="${TMPDIR}/authentik-mode"

function log {
Expand Down Expand Up @@ -87,7 +88,6 @@ elif [[ "$1" == "bash" ]]; then
elif [[ "$1" == "test-all" ]]; then
prepare_debug
chmod 777 /root
pip install --force-reinstall /wheels/*
check_if_root "python -m manage test authentik"
elif [[ "$1" == "healthcheck" ]]; then
run_authentik healthcheck $(cat $MODE_FILE)
Expand Down
18 changes: 18 additions & 0 deletions scripts/test_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e -x -o pipefail

export PG_PASS=$(openssl rand -base64 36 | tr -d '\n')
export AUTHENTIK_SECRET_KEY=$(openssl rand -base64 60 | tr -d '\n')
export AUTHENTIK_IMAGE="xghcr.io/goauthentik/server"
export AUTHENTIK_TAG=$(git rev-parse HEAD | cut -c1-15)
export COMPOSE_PROJECT_NAME="authentik-test-${AUTHENTIK_TAG}"

# Ensure buildx is installed
docker buildx install
# For release builds we have an empty client here as we use the NPM package
mkdir -p ./gen-ts-api
docker build -t ${AUTHENTIK_IMAGE}:${AUTHENTIK_TAG} .
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all
docker compose down -v

0 comments on commit 764b211

Please sign in to comment.