Merge pull request #1025 from tripleee/bypass-nil-ttd-chart-934 #767
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation.g | |
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake | |
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby | |
name: Test | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
tags: | |
description: 'Test scenario tags' | |
env: | |
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts | |
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results | |
# The actions/cache holds old cache entries for 7 days and has no method of invalidating entries. | |
# The only thing that can be done is to change the key value to force the cache to miss. | |
# The ACTION_CACHE_VERSION is just a value to change if we don't want to use previously cached data. | |
ACTION_CACHE_VERSION: cache_version_1 | |
jobs: | |
rubocop: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Ruby | |
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, | |
# change this to (see https://github.com/ruby/setup-ruby#versioning): | |
# uses: ruby/setup-ruby@v1 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7.4 | |
- uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}- | |
- name: Install dependencies | |
run: | | |
sudo apt-get install libsqlite3-dev | |
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 | |
- name: Configure | |
run: | | |
mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS | |
cp config/config.sample.yml config/config.yml | |
- run: bundle exec rubocop | |
rails: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_USER: root | |
MYSQL_ROOT_PASSWORD: root | |
ports: | |
- 3306 | |
redis_main: | |
image: redis | |
# Map TCP port 6379 on Docker host to a random free port on the Redis container | |
ports: | |
- 6379/tcp | |
redis_logging: | |
image: redis | |
ports: | |
- "6379:6379" | |
env: | |
RAILS_ENV: test | |
RACK_ENV: test | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Ruby | |
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, | |
# change this to (see https://github.com/ruby/setup-ruby#versioning): | |
# uses: ruby/setup-ruby@v1 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7.4 | |
- name: Cache bundle | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}- | |
- name: Cache yarn packages | |
uses: actions/cache@v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-yarn-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules-yarn-${{ env.ACTION_CACHE_VERSION }}- | |
- name: Install dependencies | |
run: | | |
sudo apt-get install libsqlite3-dev | |
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 | |
yarn install | |
- name: Start MySQL | |
run: | | |
sudo systemctl start mysql.service | |
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root --password=root mysql | |
- name: Configure | |
run: | | |
mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS | |
cp config/config.sample.yml config/config.yml | |
mkdir -p config && echo 'test: | |
adapter: mysql2 | |
database: metasmoke_test | |
username: root | |
password: root | |
host: localhost | |
port: ${{ job.services.mysql.ports['3306'] }} | |
' > config/database.yml | |
mkdir -p config && echo 'test: | |
adapter: redis | |
timeout: 120 | |
url: redis://localhost:${{ job.services.redis_main.ports['6379'] }} | |
' > config/cable.yml | |
- name: Prepare | |
run: bundle exec rake db:create db:schema:load db:test:prepare db:migrate --trace | |
- name: Run tests | |
run: bundle exec rails test --verbose | |
- name: Upload Gemfile.lock | |
uses: actions/upload-artifact@v4 | |
if: ${{ failure() }} | |
with: | |
name: Gemfile.lock | |
path: Gemfile.lock | |
- name: Gem version diff | |
if: ${{ failure() }} | |
run: git diff Gemfile.lock | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
if: ${{ success() }} | |
with: | |
name: coverage | |
path: coverage | |
js: | |
runs-on: ubuntu-latest | |
env: | |
NODE_ENV: test | |
RAILS_ENV: test | |
RACK_ENV: test | |
steps: | |
- uses: actions/checkout@v2 | |
- run: export PATH="~/Charcoal-SE/metasmoke/node_modules/.bin:$PATH" | |
- uses: actions/cache@v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-npm-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules-npm-${{ env.ACTION_CACHE_VERSION }}- | |
- run: ls | |
- name: Install dependencies | |
run: yarn install | |
- name: Run tests | |
run: npm test |