diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..909e1650 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +name: Continuous Integration +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-20.04 + services: + postgres: + image: postgres:11-alpine + ports: ["5432:5432"] + env: + #POSTGRES_DB: nztraintest # not required because script/install.bash creates the database + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis + ports: ["6379:6379"] + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + env: + RAILS_ENV: test + DATABASE_URL: "postgresql://postgres:postgres@localhost:5432" + + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - run: bash script/install/config.bash --defaults + env: + DATABASE_INSTALL: false + DATABASE_USERNAME: postgres + DATABASE: + TEST_DATABASE: nztraintest + REDIS_INSTALL: false + REDIS_PASS: + SCHEDULE_BACKUPS: 0 + ISOLATE_ROOT: / + ISOLATE_CGROUPS: false + ISOLATE_BRANCH: master + + - run: AUTOCONFIRM=true script/install.bash + env: + PGHOST: localhost + PGUSER: postgres + PGPASSWORD: postgres + + #- run: bundle exec rake db:test:load # not required because script/install.bash runs db:migrate + - run: bundle exec rspec + + - uses: coverallsapp/github-action@v2 + + lint: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - run: bundle exec standardrb --parallel diff --git a/.gitignore b/.gitignore index 8b5ec3b4..8bfd125f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,6 @@ /db/backup/ /db/backups/ /.fontello -/coverage/.* +/coverage/ /vendor/bundle diff --git a/Gemfile b/Gemfile index 27bf685b..110aed37 100644 --- a/Gemfile +++ b/Gemfile @@ -62,7 +62,7 @@ gem 'sinatra' # Monitoring gem 'newrelic_rpm' -gem 'coveralls', require: false +gem 'simplecov', require: false gem 'sentry-raven' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 42a1bb12..722abfd3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,12 +106,6 @@ GEM country_select (3.1.1) countries (~> 2.0) sort_alphabetical (~> 1.0) - coveralls (0.8.21) - json (>= 1.8, < 3) - simplecov (~> 0.14.1) - term-ansicolor (~> 1.3) - thor (~> 0.19.4) - tins (~> 1.6) crass (1.0.5) daemons (1.4.1) debug_inspector (0.0.3) @@ -123,7 +117,7 @@ GEM thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.5.0) - docile (1.1.5) + docile (1.3.5) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) erubi (1.12.0) @@ -365,11 +359,10 @@ GEM simple_form (3.2.1) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) - simplecov (0.14.1) - docile (~> 1.1.0) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-html (0.12.3) sinatra (1.4.8) rack (~> 1.5) rack-protection (~> 1.4) @@ -403,8 +396,6 @@ GEM request_store (~> 1.0.3) strong_attributes (~> 0.0.2) superfish-rails (1.6.0.1) - term-ansicolor (1.6.0) - tins (~> 1.0) thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) @@ -412,7 +403,6 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (2.0.8) - tins (1.16.3) ttfunk (1.5.1) tzinfo (1.2.11) thread_safe (~> 0.1) @@ -454,7 +444,6 @@ DEPENDENCIES connection_pool countries country_select - coveralls devise (~> 3.4.1) facebox-rails factory_bot_rails @@ -495,6 +484,7 @@ DEPENDENCIES sentry-raven simple-navigation (= 3.11.0) simple_form (= 3.2.1) + simplecov sinatra spring squeel diff --git a/script/install.bash b/script/install.bash index 61274dbd..9dedd570 100755 --- a/script/install.bash +++ b/script/install.bash @@ -47,7 +47,7 @@ bash script/install/jdk.bash || exit 1 # required by yui-compressor sudo bash script/install/isolate.bash || exit 1 # install isolate sudo bash script/install/cgroup.bash || exit 1 # install cgroups sudo bash script/install/isolock.bash || exit 1 # install isolock -sudo bash script/install/debootstrap.bash || exit 1 # install debootstrap ubuntu if required +sudo CI=$CI bash script/install/debootstrap.bash || exit 1 # install debootstrap ubuntu if required if [[ "$REDIS_INSTALL" = "true" ]]; then sudo bash script/install/redis.bash || exit 1 # install redis diff --git a/script/install/debootstrap.bash b/script/install/debootstrap.bash index 6e532e9b..187415dc 100644 --- a/script/install/debootstrap.bash +++ b/script/install/debootstrap.bash @@ -59,7 +59,7 @@ chroot "$ISOLATE_ROOT" apt-get update echo "$chroot_install software-properties-common" chroot "$ISOLATE_ROOT" apt-get install software-properties-common # provides add-apt-repository -[ -z "$TRAVIS" ] && { # if not in Travis-CI +[ -z "$CI" ] && { # if not in CI # python ppa if ! chroot "$ISOLATE_ROOT" apt-cache show python3.4 &>/dev/null || ! chroot "$ISOLATE_ROOT" apt-cache show python3.8 &>/dev/null; then @@ -91,7 +91,7 @@ chroot "$ISOLATE_ROOT" apt-get install build-essential # C/C++ (g++, gcc) echo "$chroot_install ruby" chroot "$ISOLATE_ROOT" apt-get install ruby # Ruby (ruby) -[ -z "$TRAVIS" ] && { # if not in Travis-CI +[ -z "$CI" ] && { # if not in CI # add haskell ppa echo "$chroot_cmd add-apt-repository ppa:hvr/ghc -y" chroot "$ISOLATE_ROOT" add-apt-repository ppa:hvr/ghc -y @@ -125,7 +125,7 @@ fi echo "$chroot_install openjdk-11-jdk" chroot "$ISOLATE_ROOT" apt-get install openjdk-11-jdk # Java -[ -z "$TRAVIS" ] && { # if not in Travis-CI +[ -z "$CI" ] && { # if not in CI # echo "$chroot_install python" # chroot "$ISOLATE_ROOT" apt-get install python # Python 2 (deprecated) @@ -204,11 +204,11 @@ echo "$chroot_cmd update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 chroot "$ISOLATE_ROOT" update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 75 # gcc 9 done -[ -z "$TRAVIS" ] && bash script/confirm.bash 'Install the V8 JavaScript Engine (submissions in JavaScript will fail without this!)' && { +[ -z "$CI" ] && bash script/confirm.bash 'Install the V8 JavaScript Engine (submissions in JavaScript will fail without this!)' && { HOME=/root ISOLATE_ROOT= chroot "$ISOLATE_ROOT" bash < script/install/v8.bash } -[ -z "$TRAVIS" ] && bash script/confirm.bash 'Install .NET Core (C#)' && { +[ -z "$CI" ] && bash script/confirm.bash 'Install .NET Core (C#)' && { # check kernel version uname -r | bash script/check_version.bash 4.14.0 || { echo "Warning: Linux kernel $(uname -r) detected, .NET Core requires kernel >= 4.14" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 118c29f9..fcdf3a9b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ -require 'coveralls' -Coveralls.wear!('rails') +require 'simplecov' +SimpleCov.start 'rails' # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test'