Skip to content

feat/issues list cache (#1995) #4726

feat/issues list cache (#1995)

feat/issues list cache (#1995) #4726

Workflow file for this run

name: CI for KernelCI Dashboard
on:
push:
branches: [main]
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
concurrency:
group: ci-check-${{ github.ref }}
cancel-in-progress: true
env:
CI: true
jobs:
setup-node:
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
paths-node_modules: ${{ steps.paths-node_modules.outputs.paths }}
steps:
- uses: actions/checkout@v4
- name: Cache node_modules
uses: actions/cache@v4
id: cache-node_modules
with:
key: node_modules-${{ runner.os }}-${{ hashFiles('./dashboard/pnpm-lock.yaml') }}
path: ./dashboard/node_modules
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.2
- name: Installing dependencies with pnpm
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
working-directory: ./dashboard
pre-commit-checks:
runs-on: ubuntu-latest
needs: setup-node
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: 3.12
- name: Fetch node_modules
uses: actions/cache@v4
id: fetch-node_modules
with:
key: node_modules-${{ runner.os }}-${{ hashFiles('./dashboard/pnpm-lock.yaml') }}
path: ./dashboard/node_modules
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.2
- uses: actions/setup-node@v4
with:
node-version-file: './dashboard/.nvmrc'
- name: Cache Pre-Commit Hooks
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Setup pre-commit
run: pip install pre-commit
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
build-front:
if: github.event.pull_request.draft != true
needs: setup-node
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Fetch node_modules
uses: actions/cache@v4
id: fetch-node_modules
with:
key: node_modules-${{ runner.os }}-${{ hashFiles('./dashboard/pnpm-lock.yaml') }}
path: ./dashboard/node_modules
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.2
- uses: actions/setup-node@v4
with:
node-version-file: './dashboard/.nvmrc'
- name: Run tests
run: pnpm test
working-directory: ./dashboard
- name: Run build
run: pnpm build
working-directory: ./dashboard
unit-test-django:
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- name: Setup Backend
uses: ./.github/actions/setup-backend
- name: Run unit tests with coverage
run: |
poetry run pytest -m unit --cov=kernelCI_app --cov=kernelCI_cache --cov-report=term-missing
cp .coverage coverage-unit.sqlite
working-directory: ./backend
- name: Upload coverage data (unit)
uses: actions/upload-artifact@v4
with:
name: coverage-data-unit
path: backend/coverage-unit.sqlite
integration-test-django:
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Setup Backend
uses: ./.github/actions/setup-backend
- name: Run test database, redis service
run: |
docker compose -f docker-compose.test.yml up test_db redis -d
- name: Execute migrations
run: |
docker compose -f docker-compose.test.yml run --rm test_backend python manage.py migrate
- name: Populate database with test data
run: |
docker compose -f docker-compose.test.yml run --rm test_backend python manage.py seed_test_data --clear --yes
- name: Start test backend
run: |
docker compose -f docker-compose.test.yml up test_backend -d
sleep 5
docker ps
- name: Run integration tests with coverage
run: |
DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 DJANGO_SETTINGS_MODULE=kernelCI.test_settings poetry run pytest -m "integration" --use-local-db --run-all --cov=kernelCI_app --cov=kernelCI_cache --cov-report=term-missing
cp .coverage coverage-integration.sqlite
working-directory: ./backend
- name: Upload coverage data (integration)
uses: actions/upload-artifact@v4
with:
name: coverage-data-integration
path: backend/coverage-integration.sqlite
- name: Clean containers
run: |
docker compose -f docker-compose.test.yml down --volumes --remove-orphans
docker system prune -af
update-coverage-badge:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
runs-on: ubuntu-latest
needs:
- unit-test-django
- integration-test-django
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Backend
uses: ./.github/actions/setup-backend
- name: Download coverage data (unit)
uses: actions/download-artifact@v4
with:
name: coverage-data-unit
- name: Download coverage data (integration)
uses: actions/download-artifact@v4
with:
name: coverage-data-integration
- name: Rename coverage files for combine
run: |
cp coverage-unit.sqlite backend/.coverage.unit
cp coverage-integration.sqlite backend/.coverage.integration
ls -la backend/.coverage*
- name: Combine coverage and generate json
run: |
poetry run coverage combine
poetry run coverage json -o ${{ github.workspace }}/coverage.json
working-directory: ./backend
- name: Update Coverage Badge
uses: we-cli/coverage-badge-action@main
# Call job in a a split file
call-deploy-staging:
needs: [pre-commit-checks, build-front, unit-test-django, integration-test-django]
# This 'if' ensures it only runs on pushes to main (the production requirement)
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: ./.github/workflows/deploy-staging.yaml
secrets: inherit