Skip to content

Styled Languages (#40) #84

Styled Languages (#40)

Styled Languages (#40) #84

Workflow file for this run

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
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/medstick_test
run: |
bin/rails db:create
bin/rails db:schema:load
- name: Run tests with coverage
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/medstick_test
COVERAGE: true
run: bin/rails spec
- name: Archive code coverage results
uses: actions/upload-artifact@v4
if: always()
with:
name: code-coverage-report
path: coverage
retention-days: 7
- name: Check coverage requirements
run: |
if [ ! -f coverage/.last_run.json ]; then
echo "No coverage report found!"
exit 1
fi
COVERAGE=$(ruby -rjson -e "puts JSON.parse(File.read('coverage/.last_run.json'))['result']['line']")
if [ $(echo "$COVERAGE < 90" | bc -l) -eq 1 ]; then
echo "Coverage $COVERAGE% is below the required 90%"
exit 1
fi
echo "Coverage: $COVERAGE%"