From 2e0c4e557d7e6df3e3ac61c0ab0c2c5921e46816 Mon Sep 17 00:00:00 2001 From: ramvignesh-b Date: Thu, 16 Apr 2026 05:34:08 +0530 Subject: [PATCH] ci: implement certificate caching in workflow --- .github/workflows/ci.yml | 15 ++++++++++++++- backend/users/tests.py | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2e6a14..c985047 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,8 @@ jobs: setup-environment: name: Generate Certificates runs-on: ubuntu-latest - + outputs: + cache-key: ${{ steps.cert-key.outputs.key }} steps: - uses: actions/checkout@v4 - name: Generate SSL Certificates @@ -19,6 +20,11 @@ jobs: mkdir -p certs mkcert -install mkcert -cert-file certs/localhost.pem -key-file certs/localhost-key.pem localhost 127.0.0.1 ::1 + echo "cert_path=certs/localhost.pem" >> $GITHUB_OUTPUT + echo "key_path=certs/localhost-key.pem" >> $GITHUB_OUTPUT + + - id: cert-key + run: echo "key=${{ runner.os }}-certs-${{ github.sha }}" >> $GITHUB_OUTPUT - name: Cache certificates uses: actions/cache/save@v4 @@ -63,6 +69,7 @@ jobs: backend: name: Backend CI runs-on: ubuntu-latest + needs: setup-environment defaults: run: working-directory: ./backend @@ -84,6 +91,12 @@ jobs: enable-cache: true cache-dependency-glob: backend/uv.lock + - name: Restore certificates + uses: actions/cache/restore@v4 + with: + path: certs + key: ${{ runner.os }}-certs-${{ github.sha }} + - name: Setup Environment run: | cp ../.env.example ../.env diff --git a/backend/users/tests.py b/backend/users/tests.py index 5c495fd..879f86a 100644 --- a/backend/users/tests.py +++ b/backend/users/tests.py @@ -32,10 +32,10 @@ class AuthTests(APITestCase): self.assertIn("access", response.data) self.assertNotIn("refresh", response.data) self.assertIn(cookie_name, response.cookies) - self.assertTrue(response.cookies[cookie_name].value) - self.assertTrue(response.cookies[cookie_name].httponly) - self.assertTrue(response.cookies[cookie_name].secure) - self.assertEqual(response.cookies[cookie_name]["samesite"], "Lax") + self.assertIsNotNone(response.cookies[cookie_name].value) + self.assertTrue(response.cookies[cookie_name].get("httponly")) + self.assertTrue(response.cookies[cookie_name].get("secure")) + self.assertEqual(response.cookies[cookie_name].get("samesite"), "Lax") class ActivationTests(APITestCase):