From df56754c553856ebe82066340de5ccd1d48bbb42 Mon Sep 17 00:00:00 2001 From: ramvignesh-b Date: Tue, 5 May 2026 18:08:09 +0530 Subject: [PATCH 1/5] ci: introduce tmp filespace to prevent postgres persist and migrate to custom artiifact upload --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 348f271..d2a30af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,13 @@ on: pull_request: branches: [ main ] +env: + # WHY?: services are executed way before the env can be sourced from .env file + # NOTE: still inlining these values because of gitea misbehaving with env loads + DB_NAME: piku_test_db + DB_USER: test + DB_PASSWORD: password123 + jobs: setup-environment: name: Generate Certificates @@ -19,11 +26,12 @@ jobs: mkcert -install mkcert -cert-file certs/localhost.pem -key-file certs/localhost-key.pem localhost 127.0.0.1 ::1 - - name: Cache certificates - uses: actions/cache/save@v4 + - name: Upload certificates + uses: christopherHX/gitea-upload-artifact@v4 with: - path: certs - key: certs-${{ runner.os }}-${{ github.sha }} + name: ssl-certs + path: certs/ + retention-days: 1 frontend: name: Frontend CI @@ -37,10 +45,10 @@ jobs: - uses: oven-sh/setup-bun@v2 - name: Restore certificates - uses: actions/cache/restore@v4 + uses: christopherHX/gitea-download-artifact@v4 with: - path: certs - key: certs-${{ runner.os }}-${{ github.sha }} + name: ssl-certs + path: certs/ - name: Install dependencies run: bun install --frozen-lockfile @@ -64,12 +72,12 @@ jobs: postgres: image: postgres:16-alpine env: - POSTGRES_DB: piku - POSTGRES_USER: user + POSTGRES_DB: piku_test_db + POSTGRES_USER: test POSTGRES_PASSWORD: password123 ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + - 5442:5432 + options: --tmpfs /var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 defaults: run: working-directory: ./backend @@ -82,10 +90,10 @@ jobs: cache-dependency-glob: "backend/uv.lock" - name: Restore certificates - uses: actions/cache/restore@v4 + uses: christopherHX/gitea-download-artifact@v4 with: - path: certs - key: certs-${{ runner.os }}-${{ github.sha }} + name: ssl-certs + path: certs/ - name: Setup Environment run: | @@ -94,6 +102,14 @@ jobs: - name: Lint & Test run: | + if [ "$GITEA_ACTIONS" = "true" ]; then + export DB_HOST="postgres" + export DB_PORT="5432" + else + export DB_HOST="127.0.0.1" + export DB_PORT="5442" + fi + uv run ruff check uv run python manage.py test @@ -101,24 +117,28 @@ jobs: name: E2E Tests runs-on: ubuntu-latest needs: setup-environment + # Skipping on Gitea pushes until cache server is configured + if: github.server_url == 'https://github.com' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v4 - name: Restore Certificates - uses: actions/cache/restore@v4 + uses: christopherHX/gitea-download-artifact@v4 with: - path: certs - key: certs-${{ runner.os }}-${{ github.sha }} + name: ssl-certs + path: certs/ - name: Setup Tools uses: astral-sh/setup-uv@v5 - uses: oven-sh/setup-bun@v2 - - name: Cache Playwright id: playwright-cache - uses: actions/cache@v4 + # Disable cache when not using GitHub Actions because the runner spends ~3mins trying to upload the cache and failing + # TODO: setup cache server in Gitea + if: github.server_url == 'https://github.com' + uses: actions/cache@v3 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/bun.lock') }} @@ -140,7 +160,7 @@ jobs: - name: Upload Playwright Report if: always() - uses: actions/upload-artifact@v4 + uses: christopherHX/gitea-upload-artifact@v4 with: name: playwright-report path: frontend/playwright-report/ -- 2.52.0 From 3f64a79af62d3456731ca03a781bf818a722cfb2 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 5 May 2026 19:12:28 +0530 Subject: [PATCH 2/5] refactor: update CI workflow to rename postgres service, adjust database configuration, and inline environment variables --- .github/workflows/ci.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2a30af..3a99c6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,6 @@ on: pull_request: branches: [ main ] -env: - # WHY?: services are executed way before the env can be sourced from .env file - # NOTE: still inlining these values because of gitea misbehaving with env loads - DB_NAME: piku_test_db - DB_USER: test - DB_PASSWORD: password123 - jobs: setup-environment: name: Generate Certificates @@ -69,10 +62,10 @@ jobs: runs-on: ubuntu-latest needs: setup-environment services: - postgres: + db: image: postgres:16-alpine env: - POSTGRES_DB: piku_test_db + POSTGRES_DB: piku__test POSTGRES_USER: test POSTGRES_PASSWORD: password123 ports: @@ -99,17 +92,19 @@ jobs: run: | cp ../.env.example ../.env uv sync - - - name: Lint & Test - run: | + export DB_NAME="piku__test" + export DB_USER="test" + export DB_PASSWORD="password123" if [ "$GITEA_ACTIONS" = "true" ]; then - export DB_HOST="postgres" + export DB_HOST="db" export DB_PORT="5432" else export DB_HOST="127.0.0.1" export DB_PORT="5442" fi + - name: Lint & Test + run: | uv run ruff check uv run python manage.py test -- 2.52.0 From c00a954266caf69cf0b3dd90673b88346963a2c5 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 5 May 2026 19:17:36 +0530 Subject: [PATCH 3/5] refactor: merge environment setup and test steps in CI workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a99c6e..e3d43db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,13 +88,15 @@ jobs: name: ssl-certs path: certs/ - - name: Setup Environment + - name: Setup & Test run: | cp ../.env.example ../.env uv sync + export DB_NAME="piku__test" export DB_USER="test" export DB_PASSWORD="password123" + if [ "$GITEA_ACTIONS" = "true" ]; then export DB_HOST="db" export DB_PORT="5432" @@ -103,8 +105,6 @@ jobs: export DB_PORT="5442" fi - - name: Lint & Test - run: | uv run ruff check uv run python manage.py test -- 2.52.0 From 133e79c0b32a97c6d8cb7a9cf9115a14e8216f74 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 5 May 2026 20:07:14 +0530 Subject: [PATCH 4/5] feat: configure e2e database and email host aliases for Gitea Actions environment --- scripts/run-e2e.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/run-e2e.sh b/scripts/run-e2e.sh index 45c31b7..c00ed5b 100755 --- a/scripts/run-e2e.sh +++ b/scripts/run-e2e.sh @@ -55,6 +55,18 @@ until $CONTAINER_BIN exec "$DB_NAME" pg_isready -U "${DB_USER:-test}" >/dev/null done export PIKU_ENV_FILE="$ENV_FILE" + +# NOTE: When running in Gitea Actions (within container), We must ponint DB and mail to the internal docker host instead. +if [ "$GITEA_ACTIONS" = "true" ]; then + sudo apt-get update && sudo apt-get install -y iproute2 + # Sample: "default via dev proto dhcp src metric 100" + HOST_IP=$(ip route show default | awk '/default/ {print $3}') + echo "Running on Gitea. Internal Docker host... $HOST_IP" + + export DB_HOST=$HOST_IP + export EMAIL_HOST=$HOST_IP +fi + echo "Starting Backend..." mkdir -p ./tmp/logs ( -- 2.52.0 From 917098dd87be189c6272981daa7c5203ac9b0bdf Mon Sep 17 00:00:00 2001 From: me Date: Tue, 5 May 2026 20:09:11 +0530 Subject: [PATCH 5/5] build: upgrade actions/cache to v4 in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3d43db..1b8f6ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,7 +133,7 @@ jobs: # Disable cache when not using GitHub Actions because the runner spends ~3mins trying to upload the cache and failing # TODO: setup cache server in Gitea if: github.server_url == 'https://github.com' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/bun.lock') }} -- 2.52.0