mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
refactor: optimize CI workflow caching
This commit is contained in:
+51
-60
@@ -7,70 +7,62 @@ on:
|
|||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
certs:
|
setup-environment:
|
||||||
name: Certificates
|
name: Generate Certificates
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup SSL using mkcert
|
- name: Generate SSL Certificates
|
||||||
id: certs
|
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update && sudo apt-get install -y mkcert libnss3-tools
|
||||||
sudo apt-get install -y mkcert libnss3-tools
|
|
||||||
mkdir -p certs
|
mkdir -p certs
|
||||||
mkcert -install
|
mkcert -install
|
||||||
mkcert -cert-file certs/localhost.pem -key-file certs/localhost-key.pem localhost 127.0.0.1 ::1
|
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
|
|
||||||
|
|
||||||
- name: Cache certificates
|
- name: Cache certificates
|
||||||
uses: actions/cache@v4
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
path: certs
|
path: certs
|
||||||
key: ${{ runner.os }}-certs-${{ github.sha }}
|
key: ${{ runner.os }}-certs-${{ github.sha }}
|
||||||
restore-keys: |
|
|
||||||
certs/localhost.pem
|
|
||||||
certs/localhost-key.pem
|
|
||||||
|
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
name: Frontend CI
|
name: Frontend CI
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: certs
|
needs: setup-environment
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Restore certificates
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: certs
|
|
||||||
key: ${{ runner.os }}-certs-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
certs/localhost.pem
|
|
||||||
certs/localhost-key.pem
|
|
||||||
|
|
||||||
- name: Create .env from example
|
|
||||||
run: cp ../.env.example ../.env
|
|
||||||
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
|
|
||||||
|
- name: Restore certificates
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: certs
|
||||||
|
key: certs-${{ github.sha }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
- name: Code Quality (Biome)
|
|
||||||
run: bun run check
|
- name: Code Quality
|
||||||
|
run: |
|
||||||
|
cp ../.env.example ../.env
|
||||||
|
bun run check
|
||||||
|
|
||||||
- name: Type Check & Build
|
- name: Type Check & Build
|
||||||
run: bun run build
|
run: bun run build
|
||||||
- name: Run Unit Tests
|
|
||||||
|
- name: Unit Tests
|
||||||
run: bun run test
|
run: bun run test
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
name: Backend CI
|
name: Backend CI
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: certs
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ./backend
|
working-directory: ./backend
|
||||||
@@ -83,28 +75,29 @@ jobs:
|
|||||||
POSTGRES_PASSWORD: password123
|
POSTGRES_PASSWORD: password123
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 # wait till up before starting (integrating) django app
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Create .env from example
|
|
||||||
run: cp ../.env.example ../.env
|
|
||||||
- name: Install uv
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@v5
|
uses: astral-sh/setup-uv@v5
|
||||||
with:
|
with:
|
||||||
version: "latest"
|
|
||||||
enable-cache: true
|
enable-cache: true
|
||||||
cache-dependency-glob: backend/uv.lock
|
cache-dependency-glob: backend/uv.lock
|
||||||
- name: Install dependencies
|
|
||||||
run: uv sync
|
- name: Setup Environment
|
||||||
- name: Lint (Ruff)
|
run: |
|
||||||
run: uv run ruff check
|
cp ../.env.example ../.env
|
||||||
- name: Run Tests
|
uv sync
|
||||||
run: uv run python manage.py test
|
|
||||||
|
- name: Lint & Test
|
||||||
|
run: |
|
||||||
|
uv run ruff check
|
||||||
|
uv run python manage.py test
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
name: E2E Tests
|
name: E2E Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: certs
|
needs: [frontend, backend, setup-environment]
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
@@ -122,35 +115,33 @@ jobs:
|
|||||||
- 1025:1025
|
- 1025:1025
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Restore certificates
|
|
||||||
uses: actions/cache@v4
|
- name: Restore Certificates
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
with:
|
with:
|
||||||
path: certs
|
path: certs
|
||||||
key: ${{ runner.os }}-certs-${{ github.sha }}
|
key: certs-${{ github.sha }}
|
||||||
restore-keys: |
|
|
||||||
certs/localhost.pem
|
|
||||||
certs/localhost-key.pem
|
|
||||||
|
|
||||||
- name: Install uv
|
- name: Setup Tools
|
||||||
uses: astral-sh/setup-uv@v5
|
uses: astral-sh/setup-uv@v5
|
||||||
with:
|
|
||||||
version: "latest"
|
|
||||||
enable-cache: true
|
|
||||||
cache-dependency-glob: backend/uv.lock
|
|
||||||
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
- name: Install Frontend dependencies
|
|
||||||
run: cd frontend && bun install
|
- name: Install Dependencies
|
||||||
- name: Install Playwright Browsers
|
run: |
|
||||||
run: cd frontend && bun x playwright install --with-deps
|
cd frontend && bun install
|
||||||
- name: Create .env.e2e
|
cd frontend && bun x playwright install --with-deps
|
||||||
run: cp .env.e2e.example .env.e2e
|
|
||||||
- name: Run E2E Script
|
- name: Run E2E
|
||||||
run: ./scripts/run-e2e.sh
|
run: |
|
||||||
|
cp .env.e2e.example .env.e2e
|
||||||
|
chmod +x ./scripts/run-e2e.sh
|
||||||
|
./scripts/run-e2e.sh
|
||||||
env:
|
env:
|
||||||
CI: "true"
|
CI: "true"
|
||||||
|
|
||||||
- name: Upload Playwright Report
|
- name: Upload Playwright Report
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
Reference in New Issue
Block a user