Use docker-compose for local scanning

This commit is contained in:
Neil Martinsen-Burrell 2022-09-12 10:47:48 -05:00
parent 049bbac27e
commit f0a9866e0d
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
8 changed files with 12398 additions and 4 deletions

View file

@ -61,3 +61,17 @@ Linters:
```shell ```shell
docker-compose exec app ./manage.py lint docker-compose exec app ./manage.py lint
``` ```
## Accessibility Scanning
The tool `pa11y-ci` is used to scan pages for compliance with a set of
accessibility rules. The scan runs as part of our CI setup (see
`.github/workflows/test.yaml`) but it can also be run locally. To run locally,
just
```shell
docker-compose run pa11y npm run pa11y-ci
```
The URLs that `pa11y-ci` will scan are configured in `src/.pa11yci`. When new
views and pages are added, their URLs should also be added to that file.

6
src/.pa11yci Normal file
View file

@ -0,0 +1,6 @@
{
"urls": [
"http://app:8080/",
"http://app:8080/health/"
]
}

View file

@ -40,3 +40,18 @@ services:
- POSTGRES_DB=app - POSTGRES_DB=app
- POSTGRES_USER=user - POSTGRES_USER=user
- POSTGRES_PASSWORD=feedabee - POSTGRES_PASSWORD=feedabee
pa11y:
build:
context: .
dockerfile: node.Dockerfile
cap_add:
- SYS_ADMIN
volumes:
- .:/app
- /app/node_modules
working_dir: /app
links:
- app
profiles:
- pa11y

10
src/node.Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM docker.io/cimg/node:current-browsers
WORKDIR /app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=circleci:circleci package*.json ./
RUN npm install

12330
src/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

20
src/package.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "getgov",
"version": "1.0.0",
"description": "========================",
"main": "index.js",
"scripts": {
"pa11y-ci": "pa11y-ci",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@uswds/uswds": "^3.1.0",
"pa11y-ci": "^3.0.1",
"sass": "^1.54.8"
},
"devDependencies": {
"@uswds/compile": "^1.0.0-beta.3"
}
}

View file

@ -486,8 +486,8 @@ if DEBUG:
"::1", "::1",
] ]
# allow dev laptop to connect # allow dev laptop and docker-compose network to connect
ALLOWED_HOSTS += ("localhost",) ALLOWED_HOSTS += ("localhost", "app")
SECURE_SSL_REDIRECT = False SECURE_SSL_REDIRECT = False
SECURE_HSTS_PRELOAD = False SECURE_HSTS_PRELOAD = False

View file

@ -1,5 +1,4 @@
from django.http import HttpResponse from django.http import HttpResponse
def health(request): def health(request):
return HttpResponse("OK") return HttpResponse('<html lang="en"><head><title>OK - Get.gov</title></head><body>OK</body>')