From 49086b6058a4c749c3a55941dceea7b1ac6af4b6 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 13 Nov 2022 11:53:59 +0100 Subject: [PATCH] Check loading all files in CI closed #14 --- .github/workflows/dynamic.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/ruby_rspec.yml | 23 ------------------- .gitignore | 1 + scripts/require_all.sh | 39 ++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/dynamic.yml delete mode 100644 .github/workflows/ruby_rspec.yml create mode 100755 scripts/require_all.sh diff --git a/.github/workflows/dynamic.yml b/.github/workflows/dynamic.yml new file mode 100644 index 0000000..71ae4a2 --- /dev/null +++ b/.github/workflows/dynamic.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ruby_rspec.yml b/.github/workflows/ruby_rspec.yml deleted file mode 100644 index a6e5efe..0000000 --- a/.github/workflows/ruby_rspec.yml +++ /dev/null @@ -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 diff --git a/.gitignore b/.gitignore index af86b03..0256355 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Gemfile.lock +scripts/tmp integration_test/*.txt integration_test/*.log integration_test/*.db diff --git a/scripts/require_all.sh b/scripts/require_all.sh new file mode 100755 index 0000000..f7e559f --- /dev/null +++ b/scripts/require_all.sh @@ -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 +