Repository: cisagov/manage.get.gov

Issue:
Add pa11y testing to CI pipeline
Install [pa11y-ci](https://github.com/pa11y/pa11y-ci) and use a Github action to automate as part of CI. 


Discussion:

Resolving patch:
diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py
--- a/src/registrar/config/settings.py
+++ b/src/registrar/config/settings.py
@@ -158,6 +158,7 @@
                 "django.template.context_processors.request",
                 "django.contrib.auth.context_processors.auth",
                 "django.contrib.messages.context_processors.messages",
+                "registrar.context_processors.language_code",
             ],
         },
     },
@@ -493,8 +494,8 @@
         "::1",
     ]
 
-    # allow dev laptop to connect
-    ALLOWED_HOSTS += ("localhost",)
+    # allow dev laptop and docker-compose network to connect
+    ALLOWED_HOSTS += ("localhost", "app")
     SECURE_SSL_REDIRECT = False
     SECURE_HSTS_PRELOAD = False
 
diff --git a/src/registrar/context_processors.py b/src/registrar/context_processors.py
new file mode 100644
--- /dev/null
+++ b/src/registrar/context_processors.py
@@ -0,0 +1,13 @@
+from django.conf import settings
+
+
+def language_code(request):
+    """Add LANGUAGE_CODE to the template context.
+
+    The <html> element of a web page should include a lang="..." attribute. In
+    Django, the correct thing to put in that attribute is the value of
+    settings.LANGUAGE_CODE but the template context can't access that value
+    unless we add it here (and configure this context processor in the
+    TEMPLATES dict of our settings file).
+    """
+    return {"LANGUAGE_CODE": settings.LANGUAGE_CODE}
diff --git a/src/registrar/views/health.py b/src/registrar/views/health.py
--- a/src/registrar/views/health.py
+++ b/src/registrar/views/health.py
@@ -2,4 +2,6 @@
 
 
 def health(request):
-    return HttpResponse("OK")
+    return HttpResponse(
+        '<html lang="en"><head><title>OK - Get.gov</title></head><body>OK</body>'
+    )


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -12,61 +12,30 @@ on:
 jobs:
   python-linting:
     runs-on: ubuntu-latest
-
     steps:
       - uses: actions/checkout@v3
-      - name: Set up Python 3.10
-        uses: actions/setup-python@v3
-      - name: Install linters
-        run: |
-          python -m pip install --upgrade pip
-          pip install bandit black flake8 mypy types-requests
-      - name: Lint with flake8
-        working-directory: ./src
-        run: flake8 . --count --show-source --statistics
-      - name: Check formatting with black
-        working-directory: ./src
-        run: black --check .
-      - name: Run type checking
-        working-directory: ./src
-        run: mypy .
-      - name: Run bandit security scanning
+
+      - name: Linting
         working-directory: ./src
-        run: bandit -r .
+        # all of our linting is configured in
+        # registrar/management/commands/lint.py
+        run: docker compose run app python manage.py lint
 
   python-test:
     runs-on: ubuntu-latest
-    services:
-      postgres:
-        image: postgres
-        env:
-          POSTGRES_DB: app
-          POSTGRES_USER: user
-          POSTGRES_PASSWORD: feedabee
-        options: >-
-          --health-cmd pg_isready
-          --health-interval 10s
-          --health-timeout 5s
-          --health-retries 5
-        ports:
-          - 5432:5432
-
     steps:
       - uses: actions/checkout@v3
-      - name: Set up Python 3.10
-        uses: actions/setup-python@v3
-      - name: Install Django
+
+      - name: Unit tests
         working-directory: ./src
-        run: |
-          python -m pip install --upgrade pip
-          pip install pipenv
-          pipenv install --system --dev
-      - name: Test
+        run: docker compose run app python manage.py test
+
+  pa11y-scan:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: Accessibility Scan
         working-directory: ./src
-        env:
-          PYTHONUNBUFFERED: yup
-          DATABASE_URL: postgres://user:feedabee@localhost/app
-          DJANGO_SETTINGS_MODULE: registrar.config.settings
-          DJANGO_SECRET_KEY: feedabee
-          DJANGO_DEBUG: True
-        run: ./manage.py test
+        # leverage the docker compose setup that we already have for local development
+        run: docker compose run pa11y npm run pa11y-ci
diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py
--- a/src/registrar/tests/test_views.py
+++ b/src/registrar/tests/test_views.py
@@ -8,4 +8,4 @@ def setUp(self):
     def test_health_check_endpoint(self):
         response = self.client.get("/health/")
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(response.content, b"OK")
+        self.assertContains(response, "OK")