|
| 1 | +# This workflow uses actions that are not certified by GitHub. They are |
| 2 | +# provided by a third-party and are governed by separate terms of service, |
| 3 | +# privacy policy, and support documentation. |
| 4 | +# |
| 5 | +# This workflow will install a prebuilt Ruby version, install dependencies, and |
| 6 | +# run tests and linters. |
| 7 | + |
| 8 | +name: "CI" |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: [main] |
| 13 | + pull_request: |
| 14 | + branches: [main] |
| 15 | + merge_group: |
| 16 | + types: [checks_requested] |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint-ruby: |
| 20 | + name: Lint Ruby |
| 21 | + uses: alphagov/govuk-infrastructure/.github/workflows/rubocop.yml@59fd794d40eef8c53f0973c3b6080f94f056ba6d |
| 22 | + |
| 23 | + lint-scss: |
| 24 | + name: Lint SCSS |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 |
| 29 | + |
| 30 | + - name: Setup Node |
| 31 | + uses: ./.github/actions/setup-node |
| 32 | + |
| 33 | + - name: Run linter |
| 34 | + run: npm run lint:scss |
| 35 | + |
| 36 | + lint-javascript: |
| 37 | + name: Lint JavaScript |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Checkout repository |
| 41 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 |
| 42 | + |
| 43 | + - name: Setup Node |
| 44 | + uses: ./.github/actions/setup-node |
| 45 | + |
| 46 | + - name: Run linter |
| 47 | + run: npm run lint:javascript |
| 48 | + |
| 49 | + test-ruby: |
| 50 | + name: Run RSpec |
| 51 | + runs-on: ubuntu-latest |
| 52 | + env: |
| 53 | + RAILS_ENV: "test" |
| 54 | + DATABASE_URL: "postgres://postgres:postgres@localhost:5432/forms_runner_test" |
| 55 | + QUEUE_DATABASE_URL: "postgres://postgres:postgres@localhost:5432/forms_runner_test_queue" |
| 56 | + steps: |
| 57 | + - name: Setup Postgres |
| 58 | + id: setup-postgres |
| 59 | + uses: alphagov/govuk-infrastructure/.github/actions/setup-postgres@59fd794d40eef8c53f0973c3b6080f94f056ba6d |
| 60 | + with: |
| 61 | + POSTGRES_DB: forms_runner_test |
| 62 | + POSTGRES_USER: postgres |
| 63 | + POSTGRES_PASSWORD: postgres |
| 64 | + |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 67 | + |
| 68 | + - name: Setup ChromeDriver |
| 69 | + uses: ./.github/actions/setup-chromedriver |
| 70 | + |
| 71 | + - name: Setup Ruby |
| 72 | + uses: ruby/setup-ruby@f8d7259c7a66155a7c4a157a1a10ca601f186594 |
| 73 | + with: |
| 74 | + bundler-cache: true |
| 75 | + |
| 76 | + - name: Setup Node |
| 77 | + uses: ./.github/actions/setup-node |
| 78 | + |
| 79 | + - name: Run Vite build |
| 80 | + run: bin/vite build |
| 81 | + |
| 82 | + - name: Initialize database |
| 83 | + run: bundle exec rails db:setup |
| 84 | + |
| 85 | + - name: Run RSpec |
| 86 | + run: bundle exec rake spec |
| 87 | + |
| 88 | + test-javascript: |
| 89 | + name: Test JavaScript |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: Checkout repository |
| 93 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 |
| 94 | + |
| 95 | + - name: Setup Ruby |
| 96 | + uses: ruby/setup-ruby@f8d7259c7a66155a7c4a157a1a10ca601f186594 |
| 97 | + with: |
| 98 | + bundler-cache: true |
| 99 | + |
| 100 | + - name: Setup Node |
| 101 | + uses: ./.github/actions/setup-node |
| 102 | + |
| 103 | + - name: Run Vitest |
| 104 | + run: npm run test |
| 105 | + |
| 106 | + security-analysis: |
| 107 | + name: Security Analysis |
| 108 | + uses: alphagov/govuk-infrastructure/.github/workflows/brakeman.yml@59fd794d40eef8c53f0973c3b6080f94f056ba6d |
| 109 | + secrets: inherit |
| 110 | + permissions: |
| 111 | + contents: read |
| 112 | + security-events: write |
| 113 | + actions: read |
| 114 | + |
| 115 | + build-image: |
| 116 | + name: Build image |
| 117 | + uses: alphagov/forms-deploy/.github/workflows/reusable-build-image.yml@main |
| 118 | + |
| 119 | + audit-dependencies: |
| 120 | + name: Audit dependencies |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - name: Checkout repository |
| 124 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 |
| 125 | + |
| 126 | + - name: Setup Ruby |
| 127 | + uses: ruby/setup-ruby@f8d7259c7a66155a7c4a157a1a10ca601f186594 |
| 128 | + with: |
| 129 | + bundler-cache: true |
| 130 | + |
| 131 | + - name: Run bundle audit |
| 132 | + run: bundle exec bundle-audit check --update |
| 133 | + |
0 commit comments