Add CI GitHub Actions workflow #1
This file contains hidden or 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: "CI" | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| merge_group: | |
| types: [checks_requested] | |
| jobs: | |
| lint-ruby: | |
| name: Lint Ruby | |
| uses: alphagov/govuk-infrastructure/.github/workflows/rubocop.yml@main | |
| lint-scss: | |
| name: Lint SCSS | |
| uses: alphagov/govuk-infrastructure/.github/workflows/stylelint.yml@main | |
| lint-javascript: | |
| name: Lint JavaScript | |
| uses: alphagov/govuk-infrastructure/.github/workflows/standardx.yml@main | |
| with: | |
| files: "'app/frontend/javascript/**/*.js'" | |
| test-ruby: | |
| name: Run RSpec | |
| runs-on: ubuntu-latest | |
| env: | |
| RAILS_ENV: "test" | |
| DATABASE_URL: "postgres://postgres:postgres@localhost:5432/forms_runner_test" | |
| QUEUE_DATABASE_URL: "postgres://postgres:postgres@localhost:5432/forms_runner_test_queue" | |
| steps: | |
| - name: Setup Postgres | |
| id: setup-postgres | |
| uses: alphagov/govuk-infrastructure/.github/actions/setup-postgres@main | |
| with: | |
| POSTGRES_DB: forms_runner_test | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| - name: Setup ChromeDriver | |
| uses: nanasess/setup-chromedriver@e93e57b843c0c92788f22483f1a31af8ee48db25 # v2.3.0 | |
| with: | |
| chromedriver-version: '128.0.6613.8600' | |
| chromeapp: chrome | |
| - name: Purge Google Chrome | |
| run: | | |
| sudo apt-get purge google-chrome-stable | |
| - name: Setup Chrome | |
| uses: browser-actions/setup-chrome@b94431e051d1c52dcbe9a7092a4f10f827795416 # v2.1.0 | |
| with: | |
| chrome-version: 128 | |
| install-chromedriver: 'false' | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| bundler-cache: true | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "npm" | |
| - name: Install JavaScript dependencies | |
| run: npm ci | |
| - name: Run Vite build | |
| run: bin/vite build | |
| - name: Initialize database | |
| run: bundle exec rails db:setup | |
| - name: Run RSpec | |
| run: bundle exec rake spec | |
| test-javascript: | |
| name: Test JavaScript | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "npm" | |
| - name: Install JavaScript dependencies | |
| run: npm ci | |
| - name: Run Vite build | |
| run: bin/vite build | |
| - name: Run Vitest | |
| run: npm run test | |
| security-analysis: | |
| name: Security Analysis | |
| uses: alphagov/govuk-infrastructure/.github/workflows/brakeman.yml@main | |
| secrets: inherit | |
| permissions: | |
| contents: read | |
| security-events: write | |
| actions: read | |
| audit-dependencies: | |
| name: Audit dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Run bundle audit | |
| run: bundle exec bundle-audit check --update | |