Skip to content

Commit

Permalink
run ci
Browse files Browse the repository at this point in the history
Signed-off-by: Aleem Isiaka <[email protected]>
  • Loading branch information
limistah committed May 24, 2024
1 parent a7af044 commit 9b6473f
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Validate Project

on:
push:
branches-ignore:
- main

jobs:
ci_validation:
runs-on: ubuntu-latest
env:
RAILS_ENV: test

services:
postgres:
image: postgres:alpine
ports:
- 5432:5432
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.3
bundler-cache: true
cache-version: 1

- name: Test
run: bundle exec rspec

- name: Upload Coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage

- name: Lint
run: bundle exec rubocop

- name: Validate Coverage
run: |
covered_percent=$(cat coverage/coverage.json | jq -r '.metrics.covered_percent');
re='^[+-]?[0-9]+([.||,][0-9]+)?$';
if ! [[ $covered_percent =~ $re ]]; then
echo "WARNING :: Couldn't get coverage from artifact.";
exit 0
fi
required_coverage=${{env.MINIMUM_COVERAGE}};
if [ $covered_percent -le $required_coverage ]; then
echo "Coverage ($covered_percent%) is below the required threshold of $required_coverage%.";
exit 1
else
echo "Coverage ($covered_percent%) passed the required threshold of $required_coverage%."
fi

0 comments on commit 9b6473f

Please sign in to comment.