Cryptopus CI build #2672
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cryptopus CI build | |
on: | |
push: | |
branches: | |
- master | |
- stable | |
pull_request: | |
# scheduled for 2AM UTC | |
schedule: | |
- cron: '0 2 * * *' | |
workflow_dispatch: | |
jobs: | |
# Set the job key. The key is displayed as the job name | |
# when a job name is not provided | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13 | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
POSTGRES_PASSWORD: password | |
env: | |
RAILS_DB_ADAPTER: 'postgresql' | |
RAILS_DB_HOST: 'localhost' | |
RAILS_DB_PORT: 5432 | |
RAILS_DB_USERNAME: postgres | |
RAILS_DB_PASSWORD: password | |
RAILS_DB_NAME: cryptopus_test | |
RAILS_ENV: test | |
steps: | |
# Checks out a copy of your repository on the ubuntu-latest machine | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Ruby 3.2 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2' | |
bundler-cache: true | |
# Setup Node | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '18.16.0' | |
# Npm global packages caching | |
- name: Cache global npm modules | |
id: global-node-modules-cache | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-global-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux | |
path: ~/.npm | |
key: ${{ runner.os }}-global-build-cache-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-global-build-cache-v1-${{ hashFiles('**/package-lock.json') }} | |
# Node modules caching | |
- name: Cache node modules | |
id: node-modules-cache | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm modules cache files are stored in `./node_modules` | |
path: ./node_modules' | |
key: ${{ runner.os }}-build-cache-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-cache-v1-${{ hashFiles('**/package-lock.json') }} | |
- name: Install bundler | |
run: gem install bundler:2.3.13 | |
- name: Create database | |
run: bundle exec rails db:setup | |
- name: Run yarn | |
if: steps.node-modules-cache.outputs.cache-hit != 'true' || steps.global-node-modules-cache.outputs.cache-hit != 'true' | |
run: yarn | |
- name: Add ember-cli | |
run: yarn global add ember-cli | |
- name: Add npm | |
run: yarn global add npm | |
- name: Set yarn prefix | |
run: yarn config set --prefix ./frontend install ./frontend | |
- name: Clear Logs | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
run: bundle exec rake ci:clear_logs --trace | |
- name: Rubocop | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
run: bundle exec rake ci:rubocop --trace | |
- name: Brakeman | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
run: bundle exec rake ci:brakeman --trace | |
# Frontend prepare | |
- name: Prepare Frontend | |
run: bundle exec rake ci:frontend_prepare --trace | |
# Frontend specs | |
- name: Run frontend specs | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
run: bundle exec rake ci:frontend_specs --trace | |
- name: Run backend specs | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
run: bundle exec rake ci:spec --trace | |
# Run end-to-end tests | |
- name: Run system specs | |
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' | |
run: bundle exec rake nightly:e2e --trace | |
# Cleanup | |
- name: Run rake frontend clean | |
run: bundle exec rake frontend:clean |