From d9e131871167003c439dba642803a5b43d0cb653 Mon Sep 17 00:00:00 2001 From: Rob Nichols Date: Wed, 20 Nov 2024 14:27:14 +0000 Subject: [PATCH] Configure CI --- .github/workflows/ci.yml | 55 ------------------------- .github/workflows/rubyonrails.yml | 67 +++++++++++++++++++++++++++++++ bin/lint | 3 ++ 3 files changed, 70 insertions(+), 55 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/rubyonrails.yml create mode 100644 bin/lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 875e92e..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: [ main ] - -jobs: - scan_ruby: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for common Rails security vulnerabilities using static analysis - run: bin/brakeman --no-pager - - scan_js: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for security vulnerabilities in JavaScript dependencies - run: bin/importmap audit - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Lint code for consistent style - run: bin/rubocop -f github - diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml new file mode 100644 index 0000000..af56265 --- /dev/null +++ b/.github/workflows/rubyonrails.yml @@ -0,0 +1,67 @@ +# This workflow will install a prebuilt Ruby version, install dependencies, and +# run tests and linters. +name: "Ruby on Rails CI" +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:11-alpine + ports: + - "5432:5432" + env: + POSTGRES_DB: rails_test + POSTGRES_USER: rails + POSTGRES_PASSWORD: password + env: + RAILS_ENV: test + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # Cofigure JavaScript environment + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Run install + uses: borales/actions-yarn@v4 + with: + cmd: install # will run `yarn install` command + + # Configure Ruby and Rails environment + - name: Install Ruby and gems + uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 + with: + bundler-cache: true + + # Add or replace database setup steps here + - name: Set up database schema + run: bin/rails db:schema:load + + - name: Build assets + run: bundle exec rails dartsass:build + + # Add or replace test runners here + - name: Run tests + run: bin/rake + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 + with: + bundler-cache: true + # Add or replace any other lints here + - name: Lint Ruby files + run: bin/lint diff --git a/bin/lint b/bin/lint new file mode 100644 index 0000000..008198f --- /dev/null +++ b/bin/lint @@ -0,0 +1,3 @@ +#!/bin/sh + +bundle exec rubocop