Check loading all files in CI

closed #14
This commit is contained in:
ChillerDragon 2022-11-13 11:53:59 +01:00
parent a663bae03b
commit 49086b6058
4 changed files with 77 additions and 23 deletions

37
.github/workflows/dynamic.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: Runtime tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
syntax:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 3.1
uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Loading all files should not crash
run: |
gem install bundler
bundle install --jobs 4 --retry 3
./scripts/require_all.sh
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 3.1
uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Run rspec tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rspec

View file

@ -1,23 +0,0 @@
name: Unit tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
rspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 3.1
uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Run rspec tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rspec

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
Gemfile.lock Gemfile.lock
scripts/tmp
integration_test/*.txt integration_test/*.txt
integration_test/*.log integration_test/*.log
integration_test/*.db integration_test/*.db

39
scripts/require_all.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
if [ ! -d spec ]
then
echo "Error: spec folder not found"
echo " run this script from the root of repo"
exit 1
fi
tmpdir=scripts/tmp
mkdir -p scripts/tmp
tmpfile="$tmpdir/require_all.rb"
{
echo '# frozen_string_literal: true'
echo ''
} > "$tmpfile"
function require_all() {
local ruby_file
while read -r ruby_file
do
ruby_file="${ruby_file::-3}"
echo "require_relative '../../$ruby_file'" >> "$tmpfile"
done < <(find lib/ -name "*.rb")
if ruby "$tmpfile"
then
echo "[+] OK: no file crashed when being run."
return 1
else
echo "[-] Error: loading all files crashed"
return 0
fi
}
if require_all
then
exit 1
fi