Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflow for CI #246

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
/db/backup/
/db/backups/
/.fontello
/coverage/.*
/coverage/
/vendor/bundle

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ gem 'sinatra'

# Monitoring
gem 'newrelic_rpm'
gem 'coveralls', require: false
gem 'simplecov', require: false
gem 'sentry-raven'

group :development do
Expand Down
22 changes: 6 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -403,16 +396,13 @@ 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)
rack (>= 1, < 3)
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)
Expand Down Expand Up @@ -454,7 +444,6 @@ DEPENDENCIES
connection_pool
countries
country_select
coveralls
devise (~> 3.4.1)
facebox-rails
factory_bot_rails
Expand Down Expand Up @@ -495,6 +484,7 @@ DEPENDENCIES
sentry-raven
simple-navigation (= 3.11.0)
simple_form (= 3.2.1)
simplecov
sinatra
spring
squeel
Expand Down
2 changes: 1 addition & 1 deletion script/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions script/install/debootstrap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down