47 lines
1.6 KiB
YAML
47 lines
1.6 KiB
YAML
name: Check ORM (Sequel) usage
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- master
|
|
jobs:
|
|
orm-check:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout current repository
|
|
uses: actions/checkout@v1
|
|
|
|
- name: Check if the last commit modified deprecated Sequel models
|
|
shell: bash
|
|
run: |
|
|
# This script will exit if any of these files is found in the head branch.
|
|
ORM_FILES=$(git grep -l 'class.*Sequel::Model' -- app/models)
|
|
|
|
MODIFIED_FILES=()
|
|
while IFS='$\n' read -r c; do
|
|
# Mark files as modified if new lines have been added
|
|
added=$(echo $c | awk '{print $1}')
|
|
removed=$(echo $c | awk '{print $2}')
|
|
is_numeric='^[0-9]+$'
|
|
if [[ $added =~ $is_numeric && $removed =~ $is_numeric ]]; then
|
|
summary=$(( $added - $removed ))
|
|
filename=$(echo $c | awk '{for(i=3;i<=NF;++i)print $i}')
|
|
|
|
if [ $summary -gt 0 ]; then
|
|
for orm in $ORM_FILES; do
|
|
if [ $filename = $orm ]; then
|
|
MODIFIED_FILES+=($filename)
|
|
fi
|
|
done
|
|
fi
|
|
fi
|
|
done < <(git diff $(git merge-base $(git rev-parse HEAD) origin/master) --numstat)
|
|
|
|
if [[ ${#MODIFIED_FILES[@]} -gt 0 ]]; then
|
|
for i in ${MODIFIED_FILES[@]}; do
|
|
echo "::error file=$i::This file has been flagged to be migrated, please do not add new lines."
|
|
done
|
|
exit 1
|
|
fi
|
|
exit 0
|