Skip to content

CI

CI #6894

Workflow file for this run

name: CI
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
pull_request:
branches: ["master", "main"]
paths-ignore: ["docs/**"]
push:
branches: ["master", "main"]
paths-ignore: ["docs/**"]
merge_group:
jobs:
build-scss:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4.1.0
- name: Install node dependencies
run: npm ci
- name: Build scss
run: npm run build
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
env:
SKIP: no-commit-to-branch,stylelint
# With no caching at all the entire ci process takes 4m 30s to complete!
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Copy .env.example file
uses: canastro/copy-file-action@master
with:
source: ".env.example"
target: ".env"
- name: Create docker network as used in dev
run: docker network create caselaw
- name: Build the Stack
run: docker compose build postgres django
- name: Run DB Migrations
run: docker compose run --rm django python manage.py migrate --settings=config.settings.test
- name: Run Django Tests with coverage
run: docker compose run django coverage run -m pytest -vvvv -rsa -m "not local"
- name: Generate coverage XML
run: docker compose run django coverage xml
- name: Run mypy
run: docker compose run django mypy ds_judgements_public_ui judgments
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
- name: Upload coverage to CodeClimate
uses: paambaati/codeclimate-action@v9.0.0
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
- name: Tear down the Stack
run: docker compose down
e2e-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Copy .env.example file
uses: canastro/copy-file-action@master
with:
source: ".env.example"
target: ".env"
- name: Create docker network as used in dev
run: docker network create caselaw
- name: Build the Stack
run: docker compose build postgres django
- name: Checkout Marklogic repo
uses: actions/checkout@v4
with:
repository: "nationalarchives/ds-caselaw-marklogic"
path: "./marklogic"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Setup Python
uses: actions/setup-python@v5
- name: Install requests
run: "pip install requests"
- name: Run marklogic docker container
run: docker compose up -d --wait
working-directory: "./marklogic"
- name: Deploy marklogic configuration
run: gradle mlDeploy
working-directory: "./marklogic"
- name: Populate marklogic DB with test data
run: python ./development_scripts/populate_from_caselaw.py
working-directory: "./marklogic"
- name: Publish imported documents
run: gradle publishAllDocuments
working-directory: "./marklogic"
- name: Run DB Migrations
run: docker compose run --rm django python manage.py migrate --settings=config.settings.test
- name: Setup django server for e2e tests
run: docker compose up -d
- name: Install NPM deps
run: npm install
- name: Build the JS and SASS
run: npm run build
- name: Kick off the django server itself
run: docker compose exec -d django python manage.py runserver 0.0.0.0:3000
- name: Build playwright runner container
run: docker compose build e2e_tests
- name: Run playwright e2e tests
run: docker compose run e2e_tests pytest --base-url http://django:3000
- name: Tear down marklogic
run: docker compose down
working-directory: "./marklogic"
- name: Tear down the Stack
run: docker compose down