-
-
Notifications
You must be signed in to change notification settings - Fork 153
133 lines (121 loc) · 4.77 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: docker build and test
on:
push:
branches:
- "**"
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out CourtListener
uses: actions/checkout@v4
with:
path: courtlistener
# Build docker image
- name: Set up docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
uses: docker/build-push-action@v6
with:
context: ./courtlistener
file: ./courtlistener/docker/django/Dockerfile
push: false # This image is for testing only
tags: courtlistener:latest
outputs: type=docker,dest=/tmp/courtlistener.tar
build-args: |
BUILD_ENV=dev
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: courtlistener
path: /tmp/courtlistener.tar
compression-level: 0
retention-days: 1
test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
tag_flags: ["--exclude-tag selenium", "--tag selenium"]
steps:
- name: Check out CourtListener
uses: actions/checkout@v4
with:
path: courtlistener
- name: Create the .env settings file
working-directory: courtlistener/
run: cp .env.example .env.dev
- name: Update .env.dev file
working-directory: courtlistener/
run: |
echo 'SECRET_KEY=Verbal-Kint-is-Keyser-Soze' >> .env.dev
echo 'ALLOWED_HOSTS=*' >> .env.dev
- name: Echo github actor name for debugging
run: echo ${{ github.actor }}
- name: Set up docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
# Prepare Docker images
- name: Pull docker images
working-directory: courtlistener/docker/courtlistener
run: docker compose pull --quiet --ignore-buildable
- name: Download courtlistener image
uses: actions/download-artifact@v4
with:
name: courtlistener
path: /tmp
- name: Load courtlistener image
run: docker load --input /tmp/courtlistener.tar
- name: Build cl-postgresql images # TODO: replace with an off-the-shelf image. Until then, build now for later steps.
working-directory: courtlistener/docker/courtlistener
run: docker compose build cl-postgresql
- name: List docker images
run: docker image ls -a --no-trunc
# Docker images are ready. Start them up.
- name: Create docker network
run: docker network create -d bridge --attachable cl_net_overlay
- name: Start docker containers
working-directory: courtlistener/docker/courtlistener
run: > # don't build, rather use loaded image from build step, specified by merging overriding config
docker compose -f docker-compose.yml -f docker-compose.tmpfs.yml -f <(echo 'services: { cl-django: { image: "courtlistener" }, cl-celery: { image: "courtlistener" } }') up -d --no-build --pull=never
- name: List docker containers
run: docker ps -a --no-trunc
- name: Show the docker startup logs
working-directory: courtlistener/docker/courtlistener
run: docker compose logs
# Run the checks and tests
- name: Check if migrations are missing
run: docker exec cl-django python /opt/courtlistener/manage.py makemigrations --check --dry-run
- name: Run the tests!
run: >
docker exec -e SELENIUM_DEBUG=1 -e SELENIUM_TIMEOUT=30 cl-django
python /opt/courtlistener/manage.py test
cl --verbosity=2 ${{ matrix.tag_flags }} --parallel
- name: Export selenium results from docker to host
if: failure()
run: |
# This is annoying b/c docker cp doesn't support globs. See:
# https://stackoverflow.com/q/35806102/
# https://github.com/moby/moby/issues/7710
mkdir selenium-screenshots
docker exec cl-django bash -c "mkdir /extract && mv /tmp/*-selenium.png /extract ||:"
docker cp 'cl-django:/extract' selenium-screenshots/
- name: Save selenium screenshot as Github artifacts
uses: actions/upload-artifact@master
if: failure()
with:
name: selenium-screenshots
path: selenium-screenshots/extract
if-no-files-found: ignore
# Cancel the current workflow (tests) for pull requests (head_ref) only. See:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true