diff --git a/.github/workflows/tests-axe.yml b/.github/workflows/tests-axe.yml new file mode 100644 index 0000000000..dc95a48475 --- /dev/null +++ b/.github/workflows/tests-axe.yml @@ -0,0 +1,64 @@ +name: Accessibility tests +on: + workflow_dispatch: + pull_request: + paths-ignore: + - ".github/workflows/**" + - "*.md" + - "integration/**" + - AUTHORS + +concurrency: + group: ci-${{ github.ref }}-a11y + cancel-in-progress: true + +env: + MIX_ENV: dev + MBTA_API_BASE_URL: ${{ secrets.MBTA_API_BASE_URL }} + MBTA_API_KEY: ${{ secrets.MBTA_API_KEY }} + +jobs: + axe_test: + name: Run accessibility tests against Docker container + timeout-minutes: 30 + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version-file: .tool-versions + cache: npm + cache-dependency-path: package-lock.json + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: us-east-1 + mask-aws-account-id: true + - run: npm install --ignore-scripts + - run: cp .env.template .env # The docker compose expects an .env file + - name: docker compose up + run: docker compose --file deploy/dev-standalone.yml up --build --detach --wait + - uses: docker://mcr.microsoft.com/playwright:v1.42.1-jammy + with: + args: npx playwright test axe + env: + CI: true + HOME: /root + - uses: actions/upload-artifact@v4 + if: always() + with: + name: axe-report-${{ github.sha }} + path: playwright-report + retention-days: 30 + - name: show docker container logs + run: docker compose --file deploy/dev-standalone.yml logs dotcom + if: ${{ failure() }} + - name: docker compose down + if: always() + run: docker compose --file deploy/dev-standalone.yml down diff --git a/deploy/dev-standalone.yml b/deploy/dev-standalone.yml new file mode 100644 index 0000000000..0cc33ab9d6 --- /dev/null +++ b/deploy/dev-standalone.yml @@ -0,0 +1,112 @@ +services: + dotcom: + build: + context: ../ + dockerfile: ./deploy/dotcom/dev/1/Dockerfile + env_file: + - ../.env + depends_on: + redis-cluster-init: + condition: service_started + environment: + - MIX_ENV=dev + - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} + - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - MBTA_API_BASE_URL=${MBTA_API_BASE_URL} + - MBTA_API_KEY=${MBTA_API_KEY} + - PORT=4001 + - REDIS_HOST=10.0.0.11 + - REDIS_PORT=6379 + - WEBPACK_PORT=8092 + - WARM_CACHES=false + expose: + - 4001 + ports: + - 4001:4001 + - 8092:8092 + healthcheck: + test: curl --fail http://localhost:4001/_health || exit 1 + interval: 10s + retries: 5 + start_period: 180s + timeout: 10s + volumes: + - ../:/app + networks: + dotcom_network: + ipv4_address: 10.0.0.1 + redis-cluster-init: + image: redis:7.2.4 + command: redis-cli --cluster create 10.0.0.11:6379 10.0.0.12:6379 10.0.0.13:6379 10.0.0.14:6379 10.0.0.15:6379 10.0.0.16:6379 --cluster-replicas 1 --cluster-yes + depends_on: + redis-1: + condition: service_healthy + redis-2: + condition: service_healthy + redis-3: + condition: service_healthy + redis-4: + condition: service_healthy + redis-5: + condition: service_healthy + redis-6: + condition: service_healthy + networks: + dotcom_network: + ipv4_address: 10.0.0.10 + redis-1: &redis + build: + context: ../ + dockerfile: ./deploy/redis/Dockerfile + healthcheck: + test: [ "CMD", "redis-cli", "PING"] + timeout: 10s + interval: 3s + retries: 10 + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.11 + networks: + dotcom_network: + ipv4_address: 10.0.0.11 + redis-2: + <<: *redis + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.12 + networks: + dotcom_network: + ipv4_address: 10.0.0.12 + redis-3: + <<: *redis + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.13 + networks: + dotcom_network: + ipv4_address: 10.0.0.13 + redis-4: + <<: *redis + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.14 + networks: + dotcom_network: + ipv4_address: 10.0.0.14 + redis-5: + <<: *redis + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.15 + networks: + dotcom_network: + ipv4_address: 10.0.0.15 + redis-6: + <<: *redis + environment: + - CLUSTER_ANNOUNCE_IP=10.0.0.16 + networks: + dotcom_network: + ipv4_address: 10.0.0.16 +networks: + dotcom_network: + driver: bridge + ipam: + config: + - subnet: 10.0.0.0/24 + gateway: 10.0.0.254 diff --git a/deploy/dev.yml b/deploy/dev.yml index 9703089432..6beab132aa 100644 --- a/deploy/dev.yml +++ b/deploy/dev.yml @@ -33,10 +33,13 @@ services: - MIX_ENV=dev - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - MBTA_API_BASE_URL=${MBTA_API_BASE_URL} + - MBTA_API_KEY=${MBTA_API_KEY} - PORT=4002 - REDIS_HOST=10.0.0.11 - REDIS_PORT=6379 - WEBPACK_PORT=8092 + - WARM_CACHES=false expose: - 4002 ports: @@ -66,10 +69,13 @@ services: - MIX_ENV=dev - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - MBTA_API_BASE_URL=${MBTA_API_BASE_URL} + - MBTA_API_KEY=${MBTA_API_KEY} - PORT=4003 - REDIS_HOST=10.0.0.11 - REDIS_PORT=6379 - WEBPACK_PORT=8093 + - WARM_CACHES=false expose: - 4003 ports: diff --git a/deploy/dotcom/dev/1/Dockerfile b/deploy/dotcom/dev/1/Dockerfile index 187a1652c0..9a10556872 100644 --- a/deploy/dotcom/dev/1/Dockerfile +++ b/deploy/dotcom/dev/1/Dockerfile @@ -14,6 +14,8 @@ COPY assets/package.json ./assets/package.json RUN mix local.hex --force RUN mix local.rebar --force -RUN mix deps.get -RUN npm --prefix assets install --package-lock-only --ignore-scripts --no-save --audit false --fund false --loglevel verbose -CMD elixir --sname dotcom1 --cookie foobarbaz -S mix phx.server +CMD mix deps.get \ + && npm install --no-save \ + && mix phx.digest \ + && npm --prefix assets install --package-lock-only --ignore-scripts --no-save --audit false --fund false --loglevel verbose \ + && elixir --sname dotcom1 --cookie foobarbaz -S mix phx.server diff --git a/deploy/dotcom/dev/2/Dockerfile b/deploy/dotcom/dev/2/Dockerfile index 89fd8bd119..1eb0fb02ed 100644 --- a/deploy/dotcom/dev/2/Dockerfile +++ b/deploy/dotcom/dev/2/Dockerfile @@ -8,5 +8,5 @@ WORKDIR /app COPY mix.exs . COPY mix.lock . -RUN mix deps.get -CMD elixir --sname dotcom2 --cookie foobarbaz -S mix phx.server +CMD mix deps.get \ + && elixir --sname dotcom2 --cookie foobarbaz -S mix phx.server