Skip to content

Commit

Permalink
Improve Github workflows and add a "lint" badge to README.
Browse files Browse the repository at this point in the history
Github workflows will now only run on pull requests and on master. Pushes to other branches will no longer trigger the running of Github actions.
  • Loading branch information
vkononov authored Jul 12, 2023
1 parent f5d5fd5 commit 1577428
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Lint

on: [ push, pull_request ]
on:
push:
branches:
- main
pull_request:

jobs:
test:
Expand All @@ -17,4 +21,4 @@ jobs:
- name: Install dependencies
run: bundle install
- name: Run Rubocop
run: bundle exec rubocop
run: bin/lint --no-fix
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Test

on: [ push, pull_request ]
on:
push:
branches:
- main
pull_request:

jobs:
test:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# FillablePDF

[![Gem Version](https://badge.fury.io/rb/fillable-pdf.svg)](https://rubygems.org/gems/fillable-pdf)
[![Test Status](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions)
[![Lint Status](https://github.com/vkononov/fillable-pdf/actions/workflows/lint.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions/workflows/lint.yml)
[![Test Status](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml)

FillablePDF is an extremely simple and lightweight utility that bridges iText and Ruby in order to fill out fillable PDF forms or extract field values from previously filled out PDF forms.

Expand Down
30 changes: 30 additions & 0 deletions bin/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

RESET_COLOR='\033[0m'
HIGHLIGHT_COLOR='\033[0;35m'
SUCCESS_COLOR='\033[0;32m'
ERROR_COLOR='\033[0;31m'

clear

# linter configuration paths
RUBOCOP_CONFIG=.rubocop.yml

# Checking for existence of configuration files...
test -e ${RUBOCOP_CONFIG} || { echo -e "${ERROR_COLOR}"ERROR: ${RUBOCOP_CONFIG} not found."${RESET_COLOR}"; exit 1; }

# Running linters
echo -e "${HIGHLIGHT_COLOR}"Linting Ruby on Rails using RuboCop..."${RESET_COLOR}"
if [[ "$1" == "--no-fix" ]]; then
bundle exec rubocop || { valid=false; }
else
bundle exec rubocop --autocorrect-all || { valid=false; }
fi

# Printing summary
if [[ "$valid" == false ]]; then
echo -e "${ERROR_COLOR}"ERROR: Lint errors have been found in your code."${RESET_COLOR}"
exit 1
else
echo -e "${SUCCESS_COLOR}"SUCCESS: All lints have completed without errors."${RESET_COLOR}"
fi

0 comments on commit 1577428

Please sign in to comment.