This repository has been archived by the owner on Mar 15, 2023. It is now read-only.
forked from pupilfirst/pupilfirst
-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (124 loc) · 4 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
name: Continuous Integration
on:
workflow_dispatch:
push:
branches: ['*']
paths-ignore:
- 'docs/**'
pull_request:
branches: [ master ]
paths-ignore:
- 'docs/**'
jobs:
tests:
runs-on: ubuntu-18.04
if: "!contains(github.event.head_commit.message, 'skip ci')"
services:
postgres:
image: postgres:11.7
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
RAILS_ENV: test
RUBYOPT: '-W:no-deprecated -W:no-experimental'
JAVASCRIPT_DRIVER: headless_chrome
DB_HOST: localhost
DB_NAME_TEST: postgres
DB_USERNAME: postgres
DB_PASSWORD: postgres
CAPYBARA_MAX_WAIT_TIME: 5
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
SPEC_USER_TIME_ZONE: Etc/UTC
SPEC_RETRY_COUNT: 2
RECAPTCHA_V3_SITE_KEY: ignored
RECAPTCHA_V3_SECRET_KEY: ignored
RECAPTCHA_V2_SITE_KEY: ignored
RECAPTCHA_V2_SECRET_KEY: ignored
SEGMENT_WRITE_KEY: ignored
steps:
- uses: actions/checkout@v2
- name: Use Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Set branch name & commit SHA in env
uses: actions/github-script@v3
with:
script: |
console.log(`Event: ${context.eventName}`);
let branchName = "";
if (context.eventName === "push") {
// Pushes have a '/ref/heads/' prefixed to the branch name.
branchName = process.env.GITHUB_REF.replace("refs/heads/", "");
} else {
branchName = process.env.GITHUB_HEAD_REF;
}
console.log(`Setting GIT_BRANCH=${branchName}`);
core.exportVariable("GIT_BRANCH", branchName);
console.log(`Setting GIT_COMMIT_SHA=${context.sha}`);
core.exportVariable("GIT_COMMIT_SHA", context.sha);
- name: Restore Bundle
uses: actions/cache@master
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Rubocop
run: bundle exec rubocop
- name: Setup Database
run: |
bundle exec rake db:schema:load
- name: Restore Assets
uses: actions/cache@master
with:
path: |
public/assets
public/packs-test
key: ${{ runner.os }}-assets-${{ env.GIT_BRANCH }}
restore-keys: |
${{ runner.os }}-assets-
- name: Restore Lerna
uses: actions/cache@master
with:
path: |
node_modules
app/javascript/packages/*/node_modules
key: ${{ runner.os }}-lerna-${{ hashFiles('**/yarn.lock') }}
- name: Precompile Assets
run: |
bundle exec rails assets:precompile
echo Precompilation complete. Cleaning assets...
bundle exec rails assets:clean
echo Cleaning complete! All done.
- name: Specs (On master branch)
if: env.GIT_BRANCH == 'master'
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
COVERAGE=true bundle exec rspec -fd
./cc-test-reporter after-build -t simplecov --exit-code $?
- name: Specs (On non-master branches)
if: env.GIT_BRANCH != 'master'
run: bundle exec rspec -fd
- uses: actions/upload-artifact@v2
if: failure()
with:
name: Logs
path: |
tmp/capybara
log/test.log