Use GitHub Actions for CI
This commit is contained in:
87
.github/workflows/ci.yml
vendored
Normal file
87
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
name: CI
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-20.04
|
||||
services:
|
||||
db:
|
||||
image: postgres:13
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
co_execenv_python:
|
||||
image: openhpi/co_execenv_python
|
||||
co_execenv_java:
|
||||
image: openhpi/co_execenv_java
|
||||
|
||||
steps:
|
||||
- name: Configure Docker host
|
||||
run: |
|
||||
echo $'{"hosts": ["tcp://127.0.0.1:2376", "unix:///var/run/docker.sock"], "iptables": false, "live-restore": true}' | sudo tee /etc/docker/daemon.json
|
||||
sudo mkdir -p /etc/systemd/system/docker.service.d
|
||||
echo $'[Service]\nExecStart=\nExecStart=/usr/bin/dockerd --containerd /var/run/containerd/containerd.sock' | sudo tee /etc/systemd/system/docker.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart docker
|
||||
docker restart $(docker ps -aq)
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.7
|
||||
bundler-cache: true
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
||||
- name: Manage yarn cache
|
||||
uses: actions/cache@v2
|
||||
# use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: Install yarn packages
|
||||
run: yarn install --pure-lockfile
|
||||
|
||||
- name: Prepare config files
|
||||
run: |
|
||||
cp config/action_mailer.yml.ci config/action_mailer.yml
|
||||
cp config/code_ocean.yml.ci config/code_ocean.yml
|
||||
cp config/database.yml.ci config/database.yml
|
||||
cp config/secrets.yml.ci config/secrets.yml
|
||||
cp config/docker.yml.erb.ci config/docker.yml.erb
|
||||
cp config/mnemosyne.yml.ci config/mnemosyne.yml
|
||||
|
||||
- name: Create database
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
run: |
|
||||
bundler exec rake db:schema:load RAILS_ENV=test
|
||||
- name: Run tests
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
CC_TEST_REPORTER_ID: true
|
||||
run: |
|
||||
bundle exec rspec --color --format progress --require spec_helper --require rails_helper
|
||||
|
||||
- name: Send coverage to CodeClimate
|
||||
uses: paambaati/codeclimate-action@v2.7.4
|
||||
continue-on-error: true
|
||||
if: ${{ success() || failure() }}
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
@ -1,2 +0,0 @@
|
||||
--color
|
||||
--format progress
|
62
.travis.yml
62
.travis.yml
@ -1,62 +0,0 @@
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
services:
|
||||
- docker
|
||||
- xvfb
|
||||
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.7.2
|
||||
cache:
|
||||
bundler: true
|
||||
directories:
|
||||
- node_modules # NPM and yarn packages
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: "DkOGGPCrRgV08KGgav3Bl+keZQqb11TINQRVQS2aeMaYR5GW7Rt9zEcZzhUE0JdKVVOvm4Cclft7BO4OyMd6Cq9XnZkOOHY+Yn8Qv923761SKrRgkGUkO8eeVKMawAA8lS53XGrMZWCP2xaLsLQYq8xzinnE3GqstoZJaHLnqVs="
|
||||
|
||||
addons:
|
||||
postgresql: "10"
|
||||
firefox: "latest-esr"
|
||||
|
||||
before_install:
|
||||
- sudo sed -i '/ExecStart=\/usr\/bin\/dockerd -H fd:\/\//c\ExecStart=\/usr\/bin\/dockerd' /lib/systemd/system/docker.service
|
||||
- sudo systemctl daemon-reload
|
||||
- "echo '{\"hosts\": [\"tcp://127.0.0.1:2376\", \"unix:///var/run/docker.sock\"], \"iptables\": false}' | sudo tee /etc/docker/daemon.json > /dev/null"
|
||||
- sudo service docker restart
|
||||
- sleep 5
|
||||
- docker pull openhpi/co_execenv_python
|
||||
- docker pull openhpi/co_execenv_java
|
||||
- mkdir ~/geckodriver
|
||||
- wget -O ~/geckodriver/download.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz
|
||||
- tar -xvzf ~/geckodriver/download.tar.gz -C ~/geckodriver/
|
||||
- rm ~/geckodriver/download.tar.gz
|
||||
- chmod +x ~/geckodriver/geckodriver
|
||||
- export PATH=~/geckodriver/:$PATH
|
||||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
||||
- chmod +x ./cc-test-reporter
|
||||
|
||||
install:
|
||||
- bundle install --jobs=3 --retry=3 --deployment --path=${BUNDLE_PATH:-vendor/bundle}
|
||||
- nvm install stable
|
||||
- nvm use stable
|
||||
- yarn install
|
||||
|
||||
before_script:
|
||||
- cp .rspec.travis .rspec
|
||||
- cp config/action_mailer.yml.travis config/action_mailer.yml
|
||||
- cp config/code_ocean.yml.travis config/code_ocean.yml
|
||||
- cp config/database.yml.travis config/database.yml
|
||||
- cp config/secrets.yml.travis config/secrets.yml
|
||||
- cp config/docker.yml.erb.travis config/docker.yml.erb
|
||||
- cp config/mnemosyne.yml.travis config/mnemosyne.yml
|
||||
- psql --command='CREATE DATABASE travis_ci_test;' --username=postgres
|
||||
- bundle exec rake db:schema:load RAILS_ENV=test
|
||||
- ./cc-test-reporter before-build
|
||||
|
||||
script: bundle exec rspec --color --format documentation --require spec_helper --require rails_helper
|
||||
|
||||
after_script:
|
||||
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
@ -1,5 +1,7 @@
|
||||
test:
|
||||
adapter: postgresql
|
||||
database: travis_ci_test
|
||||
database: postgres
|
||||
pool: 32
|
||||
host: localhost
|
||||
username: postgres
|
||||
password: postgres
|
Reference in New Issue
Block a user