Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

CI

CI #47

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "17 10 * * SAT"
env:
BUNDLE_PATH: "./vendor/bundle"
jobs:
generate:
name: "Generate App From Template"
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/ci
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: ci
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "ruby"
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
- shell: bash
name: rails new
run: |
TEMPLATE_HOME=`pwd`
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global init.defaultBranch main
gem install railties --version "~> 7.1.0" --no-document
gem install bundler --no-document
mkdir -p ~/scratch/generated_app
cd ~/scratch/generated_app
rails new . -d postgresql -m $TEMPLATE_HOME/template.rb << INPUT
ci.example.com
INPUT
rm -rf .git
tar cfz ../generated_app.tgz .
- uses: actions/upload-artifact@v3
with:
name: generated_app
path: ~/scratch/generated_app.tgz
retention-days: 1
if-no-files-found: error
test:
name: "Test"
runs-on: ubuntu-latest
needs: [generate]
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/ci
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: ci
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: mkdir -p ./tmp/screenshots
- run: bundle exec rake db:create db:schema:load test:all
- uses: actions/upload-artifact@v3
if: failure()
with:
name: system-test-screenshots
path: ./tmp/screenshots/
retention-days: 7
if-no-files-found: ignore
erblint:
name: "Lint / erblint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/erblint --lint-all
eslint:
name: "Lint / eslint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: yarn lint:js
rubocop:
name: "Lint / rubocop"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/rubocop
stylelint:
name: "Lint / stylelint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: yarn lint:css
brakeman:
name: "Security / brakeman"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec brakeman --exit-on-warn --no-progress --color --output /dev/stdout
bundle-audit:
name: "Security / bundle-audit"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec bundle-audit check --update -v