-
Notifications
You must be signed in to change notification settings - Fork 8
112 lines (111 loc) · 3.76 KB
/
parallel_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
name: Parallel CI
on:
workflow_call:
secrets:
SECRET_KEY_BASE:
required: true
SESSION_ENCRYPTED_COOKIE_SALT:
required: true
JWT_PRIVATE_KEY:
required: true
JWT_PUBLIC_KEY:
required: true
MDS_USERNAME:
required: true
MDS_PASSWORD:
required: true
AWS_REGION:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
parallel-test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
# set N-1 indexes for parallel jobs
# When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
# Set N number of parallel jobs you want to run
# Remember to update ci_node_index above to 0..N-1
ci_node_total: [16]
services:
memcached:
image: memcached:1.4.31
ports:
- 11211
mysql:
image: mysql:8.0.36
env:
MYSQL_DATABASE: datacite
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- 3306
elasticsearch:
image: opensearchproject/opensearch:2
env:
discovery.type: single-node
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
OPENSEARCH_INITIAL_ADMIN_PASSWORD: AnUnsecurePassword123
DISABLE_SECURITY_PLUGIN: true
http.cors.enabled: true
bootstrap.memory_lock: true
http.cors.allow-origin: "*"
compatibility.override_main_response_version: true
logger.org.opensearch.discovery: "ERROR"
ports:
- 9200
env:
MYSQL_HOST: "127.0.0.1"
MYSQL_DATABASE: datacite
MYSQL_USER: root
ES_HOST: "localhost:9200"
ELASTIC_PASSWORD: "AnUnsecurePassword123"
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
SESSION_ENCRYPTED_COOKIE_SALT: ${{ secrets.SESSION_ENCRYPTED_COOKIE_SALT }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
MDS_USERNAME: ${{ secrets.MDS_USERNAME }}
MDS_PASSWORD: ${{ secrets.MDS_PASSWORD }}
AWS_REGION: ${{ secrets.AWS_REGION }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby 3.1.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
- uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install
env:
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: |
cp .env.build .env
gem install rubygems-update -v 3.4.22
gem install bundler:2.5.6
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundle exec rails db:setup RAILS_ENV=test
- name: Test
env:
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
ES_HOST: localhost:${{ job.services.elasticsearch.ports[9200] }}
ELASTIC_PASSWORD: "AnUnsecurePassword123"
MEMCACHE_SERVERS: localhost:${{ job.services.memcached.ports[11211] }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
RAILS_ENV: test
run: |
bundle exec parallel_test spec/ -n $CI_NODE_TOTAL --only-group $CI_NODE_INDEX --type rspec -o "--fail-fast"
echo $?