Merge pull request #1682 from alphagov/dependabot/github_actions/ruby… #5284
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. They are | |
# provided by a third-party and are governed by separate terms of service, | |
# privacy policy, and support documentation. | |
# | |
# This workflow will install a prebuilt Ruby version, install dependencies, and | |
# run tests and linters. | |
name: "Tests" | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
merge_group: | |
types: [checks_requested] | |
permissions: | |
contents: read | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13-alpine | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_DB: forms_admin_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
env: | |
RAILS_ENV: "test" | |
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/forms_admin_test" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Add or replace dependency steps here | |
- name: Install Ruby and gems | |
# The ruby version is taken from the .ruby-version file, no need to specify here. | |
uses: ruby/setup-ruby@540484a3c0f308b08619664ec40bf6c371d172c3 # v1.205.0 | |
with: | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install frontend dependencies | |
run: npm ci | |
- name: Run Frontend build | |
run: bin/vite build | |
# Add or replace database setup steps here | |
- name: Create db | |
run: bin/rails db:migrate | |
- name: Set up database schema | |
run: bin/rails db:schema:load | |
# Add or replace test runners here | |
- name: Run Ruby tests | |
run: bundle exec rspec | |
- name: Run JS tests | |
run: npm test | |
# Add or replace any other lints here | |
- name: Security audit dependencies | |
run: bundle exec bundle-audit check --update | |
- name: Security audit application code | |
run: bundle exec brakeman -q -w2 | |
- name: Lint Ruby files | |
run: bundle exec rubocop --parallel | |
- name: Lint JS and CSS files | |
run: npm run lint |