Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Jun 10, 2024
1 parent 2f301ce commit 1cc2248
Show file tree
Hide file tree
Showing 3 changed files with 907 additions and 77 deletions.
74 changes: 31 additions & 43 deletions .github/actions/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,40 @@ name: 'Reusable: Code Style Review'
on:
workflow_call:

permissions:
contents: read
pull-requests: write

jobs:
lint:
runs-on: 'ubuntu-latest'

steps:
- name: 'Checkout'
uses: actions/checkout@v2
# services:
# postgres:
# image: 'postgis/postgis:14-3.3-alpine'
# env:
# POSTGRESQL_PASSWORD: 'postgres'
# ports: ['5432:5432']
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 10s
# --health-retries 10
# memcached:
# image: 'memcached:alpine'
# ports: ['11211:11211']

env:
BUNDLE_PATH: 'vendor/bundle'
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}

- name: 'Set up Ruby'
uses: actions/setup-ruby@v1
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
- run: bundle install --jobs 4 --retry 3
- uses: reviewdog/action-rubocop@v2.12.0
with:
ruby-version: '2.7'

- name: 'Set up Reviewdog'
env:
REVIEWDOG_INSTALLER: 'https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh'
run: |
mkdir -p $HOME/bin
curl -sfL ${REVIEWDOG_INSTALLER} | sh -s -- -b $HOME/bin
- name: 'Set up Rubocop'
run: 'gem install rubocop rubocop-minitest rubocop-performance rubocop-rails'

- name: 'Run Rubocop'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
rubocop |
$HOME/bin/reviewdog \
-f=rubocop \
-name="Rubocop" \
-reporter=github-pr-review \
-level=error \
-diff="git diff $DIFF_BRANCH"
- name: 'Set up Haml-lint'
run: 'gem install haml-lint'

- name: 'Run Haml-lint'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
haml-lint |
$HOME/bin/reviewdog \
-efm="%f:%l %m" \
-name="Haml-lint" \
-reporter=github-pr-review \
-level=error \
-diff="git diff $DIFF_BRANCH"
reporter: github-pr-review
level: error
reviewdog_flags: '-diff="git diff $DIFF_BRANCH"'
rubocop_extensions: rubocop-rails rubocop-performance rubocop-rspec rubocop-i18n rubocop-rake rubocop-faker
50 changes: 16 additions & 34 deletions .github/actions/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,38 @@ jobs:
test:
runs-on: 'ubuntu-latest'

strategy:
matrix:
ruby: ['2.7'] # TODO: Reenable 3.0 when it's compatible

services:
postgres:
image: 'postgres:11'
image: 'postgis/postgis:14-3.3-alpine'
env:
POSTGRES_PASSWORD: 'postgres'
POSTGRESQL_PASSWORD: 'postgres'
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 10s
--health-retries 10
memcached:
image: 'memcached'
image: 'memcached:alpine'
ports: ['11211:11211']

steps:
- name: 'Checkout'
uses: actions/checkout@v2
env:
BUNDLE_PATH: 'vendor/bundle'
RAILS_TEST_DB_NAME: 'postgres'
RAILS_TEST_DB_USERNAME: 'postgres'
RAILS_TEST_DB_PASSWORD: 'postgres'
RAILS_ENV: 'test'

- name: 'Set up Ruby ${{ matrix.ruby }}'
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install required package
run: |
sudo apt-get install libpq-dev
- name: Cache gems
id: cache
uses: actions/cache@v2
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
path: vendor/bundle
key: ruby-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
ruby-${{ matrix.ruby }}-gem-
- name: 'Build and run tests'
env:
RAILS_TEST_DB_NAME: 'postgres'
RAILS_TEST_DB_USERNAME: 'postgres'
RAILS_TEST_DB_PASSWORD: 'postgres'
RAILS_ENV: 'test'
bundler-cache: true
- name: 'Install required libraries'
run: sudo apt-get install libpq-dev
- name: 'Run tests'
run: |
gem install bundler --version '~> 2'
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails test
Loading

0 comments on commit 1cc2248

Please sign in to comment.