-
Notifications
You must be signed in to change notification settings - Fork 8
176 lines (157 loc) · 6.57 KB
/
capture_tests.yaml
File metadata and controls
176 lines (157 loc) · 6.57 KB
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
170
171
172
173
174
175
176
###############################################################
# GitHub Actions Continuous Integration
#
# This runs a special 'capture' test script.
#
# Most of the actions here are duplicates of the
# ones for the main CBRAIN server CI tests, because
# we need to set up our own CBRAIN instance first.
# So, see also this link for the original:
#
# https://github.com/aces/cbrain/blob/master/.github/workflows/cbrain_ci.yaml
#
# At the end, a Slack notification can be sent if the
# GitHub repo secret "SLACK_WEBHOOK" is set to a URL
# (which you can generate within your SLACK config webpage)
#
# Pierre Rioux, July 2025
###############################################################
name: capture_tests
on: [ push, pull_request ]
jobs:
run-tests:
name: CBRAIN CLI client tests
runs-on: ubuntu-24.04
env:
RAILS_ENV: test
###########################################################
services:
mariadb:
image: mariadb
env: # the docker container's autosetup use MYSQL_ variables
MYSQL_ROOT_PASSWORD: that_is_nothing
MYSQL_DATABASE: cbrain_test
MYSQL_USER: cbrain_user
MYSQL_PASSWORD: fake_pw_of_course
ports:
- 3306:3306
###########################################################
steps:
###########################################################
- name: Checkout CBRAIN-CLI Codebase
uses: actions/checkout@v4
###########################################################
- name: Checkout CBRAIN Server Codebase
uses: actions/checkout@v4
with:
repository: aces/cbrain
path: ./server
###########################################################
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
###########################################################
- name: Setup BrainPortal And Bourreau Names
working-directory: server
run: |
bash .github/workflows/scripts/make_cbrain_app_name_rb.sh > BrainPortal/config/initializers/config_portal.rb
###########################################################
- name: Configure Database Connection
working-directory: server
env: # keep in sync with the values in the 'services' section above
MARIADB_ROOT_PASSWORD: that_is_nothing
MARIADB_DATABASE: cbrain_test
MARIADB_USER: cbrain_user
MARIADB_PASSWORD: fake_pw_of_course
MARIADB_HOST: 127.0.0.1
MARIADB_PORT: 3306
run: |
bash .github/workflows/scripts/make_database_yml.sh > BrainPortal/config/database.yml || exit 2
sleep 10 # darn...
mysql --host ${MARIADB_HOST} --port ${MARIADB_PORT} -u ${MARIADB_USER} -p${MARIADB_PASSWORD} -D ${MARIADB_DATABASE} -e "SHOW TABLES;"
###########################################################
- name: Reload Cached Gems
uses: actions/cache@v3 # speeds up 'Prepare Ruby Gems' below
with:
path: server/gem-cache
key: ubuntu-24-gems-${{ hashFiles('server/BrainPortal/Gemfile') }}
###########################################################
- name: Prepare Ruby Gems
working-directory: server
run: |
cd BrainPortal || exit 2
bundle config path ../gem-cache || exit 3
bundle install || exit 4
cd ../Bourreau || exit 2
bundle config path ../gem-cache || exit 3
bundle install || exit 4
###########################################################
- name: Configure Plugins
working-directory: server/BrainPortal
run: |
bundle exec rake cbrain:plugins:install:plugins
###########################################################
- name: Setup Database
working-directory: server/BrainPortal
run: |
bundle exec rake db:create || exit 3
bundle exec rake db:schema:load || exit 4
###########################################################
- name: Seed Database
working-directory: server/BrainPortal
run: |
bundle exec rake db:seed
###########################################################
- name: Seed Boureau Test Data
working-directory: server/BrainPortal
run: |
bundle exec rake db:seed:test:bourreau
###########################################################
- name: Perform Sanity Checks
working-directory: server/BrainPortal
run: |
bundle exec rake db:sanity:check
###########################################################
# MAIN CLI CLIENT TEST
###########################################################
- name: CLI Client Tests
id: cbrain_cli
run: |
cd server/BrainPortal
bundle exec rake "db:seed:test:api" || exit 2
bundle exec rails server puma -p 3000 -d || exit 3
sleep 5 # we need a better way
cd ../..
mkdir -p $HOME/.config/cbrain
cd capture_tests
bash run_and_diff_captures
###########################################################
- name: Save Error Diffs
if: ${{ failure() || success() }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: git_captures.diff
path: capture_tests/git_captures.diff
retention-days: 7
overwrite: true
###########################################################
# Final notification
###########################################################
#- name: Notify Slack
# if: ${{ failure() || success() }}
# continue-on-error: true
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL || 'cbrain_ci' }}
# SLACK_COLOR: ${{ job.status == 'success' && '#00ff00' || job.status == 'cancelled' && '#ffff00' || '#ff0000' }}
# SLACK_TITLE: "${{ github.repository }} CI tests: ${{ job.status }}"
# SLACK_USERNAME: "GitHub CI" # Doesn't have to be a real slack user
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_FOOTER: ""
# SLACK_ICON: https://github.com/aces/cbrain/raw/master/BrainPortal/public/images/custom_logos/cb-small_white_blue.png
# SLACK_MESSAGE: |
# ```
# CBRAIN CLI capture tests : ${{ steps.cbrain_cli.outcome }}
# ```