From 49e7adb356251e6a9f71f4654761f640a594cf69 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Tue, 18 Jun 2024 15:02:43 -0230 Subject: [PATCH 1/3] Initial attempt to set up an automated accessibility test --- .github/workflows/accessibility.yml | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/accessibility.yml diff --git a/.github/workflows/accessibility.yml b/.github/workflows/accessibility.yml new file mode 100644 index 000000000..e20cb9eee --- /dev/null +++ b/.github/workflows/accessibility.yml @@ -0,0 +1,74 @@ +name: Accessibility Score + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lighthouse: + runs-on: ubuntu-latest + services: + postgres: + image: postgis/postgis:latest + ports: + - "5432:5432" + env: + POSTGRES_DB: rails_test + POSTGRES_USER: rails + POSTGRES_PASSWORD: password + env: + RAILS_ENV: development + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # Install ruby and gems + - name: Install Ruby and gems + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + with: + bundler-cache: true + + # Clean up old pids + - name: Clean up any possible previous puma pids + run: rm -f spec/dummy/tmp/pids/server.pid + + # Set up database + - name: Set up database schema + run: rails db:schema:load + + # RUn rails server + - name: Run Rails server + run: rails s -p 3000 -b 0.0.0.0 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install Lighthouse + run: npm install -g lighthouse + + - name: Run Lighthouse + run: | + URL_TO_TEST="http://localhost:3000" # Adjust this to your app's URL + lighthouse $URL_TO_TEST --only-categories=accessibility --output=json --output-path=./report.json + + - name: Upload Lighthouse report + uses: actions/upload-artifact@v2 + with: + name: lighthouse-report + path: ./report.json + + - name: Parse Lighthouse report + run: | + score=$(cat ./report.json | jq '.categories.accessibility.score') + if (( $(echo "$score < 0.9" | bc -l) )); then + echo "Accessibility score is below 90%. Failing the build." + exit 1 + fi + echo "Accessibility score is acceptable." From 1187b1794a7df7a4601ec6816581fb39bee0863f Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Tue, 18 Jun 2024 15:47:12 -0230 Subject: [PATCH 2/3] Update accessibility.yml Prefix bundle exec to accessibility runner rails commands Signed-off-by: Robert Smith --- .github/workflows/accessibility.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/accessibility.yml b/.github/workflows/accessibility.yml index e20cb9eee..51dcb97db 100644 --- a/.github/workflows/accessibility.yml +++ b/.github/workflows/accessibility.yml @@ -39,11 +39,11 @@ jobs: # Set up database - name: Set up database schema - run: rails db:schema:load + run: bundle exec rails db:schema:load # RUn rails server - name: Run Rails server - run: rails s -p 3000 -b 0.0.0.0 + run: bundle exec rails s -p 3000 -b 0.0.0.0 - name: Set up Node.js uses: actions/setup-node@v2 From bd549060f3a8ead689ddd2dbf7412ba3f4ff959c Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Wed, 7 Aug 2024 14:38:45 -0230 Subject: [PATCH 3/3] Ensure that rails server command called from dummy app directory Signed-off-by: Robert Smith --- .github/workflows/accessibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/accessibility.yml b/.github/workflows/accessibility.yml index 51dcb97db..8f9b7a058 100644 --- a/.github/workflows/accessibility.yml +++ b/.github/workflows/accessibility.yml @@ -43,7 +43,7 @@ jobs: # RUn rails server - name: Run Rails server - run: bundle exec rails s -p 3000 -b 0.0.0.0 + run: bash -c "cd spec/dummy && bundle exec rails s -p 3000 -b 0.0.0.0" - name: Set up Node.js uses: actions/setup-node@v2