-
Notifications
You must be signed in to change notification settings - Fork 34
169 lines (162 loc) · 5.55 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# 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@v2
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@v2
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