-
Notifications
You must be signed in to change notification settings - Fork 1
211 lines (186 loc) · 8.04 KB
/
Copy pathbuild.yml
File metadata and controls
211 lines (186 loc) · 8.04 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: Lint, Test, Coverage and Deploy
on:
push:
branches:
- main
- beta
pull_request:
permissions:
contents: read
id-token: write
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
env:
BUNDLE_PATH: /tmp/bundle
strategy:
matrix:
ruby-version: ["3.4", "4.0"]
packages:
- forest_admin_agent
- forest_admin_datasource_active_record
- forest_admin_datasource_customizer
- forest_admin_datasource_toolkit
- forest_admin_test_toolkit
- forest_admin_rails
- forest_admin_datasource_mongoid
- forest_admin_rpc_agent
- forest_admin_datasource_rpc
- forest_admin_datasource_zendesk
- forest_admin_datasource_snowflake
- forest_admin_datasource_mambu_payments
- forest_admin_datasource_graphql_hasura
steps:
- name: Checkout
uses: actions/checkout@v4
# The Azure mirror the runner image points at stalls intermittently, and apt's
# own Acquire timeouts bound a single connection, not a whole fetch.
- name: Install unixODBC headers for ruby-odbc
if: ${{ matrix.packages == 'forest_admin_datasource_snowflake' }}
timeout-minutes: 8
run: |
sudo timeout -k 30 90 apt-get update -o Acquire::Retries=1 -o Acquire::http::Timeout=10 ||
echo 'apt-get update incomplete; continuing with the lists on the image'
sudo DEBIAN_FRONTEND=noninteractive timeout -k 30 240 apt-get install -y \
--no-install-recommends -o Acquire::Retries=1 -o Acquire::http::Timeout=10 unixodbc-dev
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies on main repo
run: bundle install
- name: Install dependencies on packages
run: cd packages/${{ matrix.packages }} && bundle install && cd -
- name: Run RuboCop
run: bundle exec rubocop
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [lint]
env:
BUNDLE_PATH: /tmp/bundle
strategy:
matrix:
ruby-version: ["3.4", "4.0"]
packages:
- forest_admin_agent
- forest_admin_datasource_active_record
- forest_admin_datasource_customizer
- forest_admin_datasource_toolkit
- forest_admin_rails
- forest_admin_datasource_mongoid
- forest_admin_rpc_agent
- forest_admin_datasource_rpc
- forest_admin_datasource_zendesk
- forest_admin_datasource_snowflake
- forest_admin_datasource_mambu_payments
- forest_admin_datasource_graphql_hasura
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v4
# The Azure mirror the runner image points at stalls intermittently, and apt's
# own Acquire timeouts bound a single connection, not a whole fetch.
- name: Install unixODBC headers for ruby-odbc
if: ${{ matrix.packages == 'forest_admin_datasource_snowflake' }}
timeout-minutes: 8
run: |
sudo timeout -k 30 90 apt-get update -o Acquire::Retries=1 -o Acquire::http::Timeout=10 ||
echo 'apt-get update incomplete; continuing with the lists on the image'
sudo DEBIAN_FRONTEND=noninteractive timeout -k 30 240 apt-get install -y \
--no-install-recommends -o Acquire::Retries=1 -o Acquire::http::Timeout=10 unixodbc-dev
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies on main repo
run: bundle install
- name: Wait for MongoDB
if: ${{ matrix.packages == 'forest_admin_datasource_mongoid' }}
run: |
for i in {1..30}; do
nc -z localhost 27017 && echo "MongoDB is up" && exit 0
echo "Waiting for MongoDB..."
sleep 1
done
exit 1
- name: Test
run: |
cd packages/${{ matrix.packages }} && \
BUNDLE_GEMFILE=Gemfile-test bundle install && \
BUNDLE_GEMFILE=Gemfile-test bundle exec rspec --color --format doc && \
cd -
- name: Upload coverage
if: ${{ matrix.ruby-version == '4.0' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ruby-version }}-${{ matrix.packages }}
path: packages/${{ matrix.packages }}/coverage/*
retention-days: 1
coverage:
name: Send Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [test]
strategy:
matrix:
# Must match the ruby-version the test job uploads artifacts for
# (the `if` on its "Upload coverage" step), or every file path below
# resolves to nothing and qlty silently sends zero coverage.
ruby-version: ["4.0"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
path: reports
- name: Send coverage
uses: qltysh/qlty-action/coverage@8d5c844f32f80364ccc135534671640466e7f610 #v1.1
with:
verbose: true
oidc: true
files: ${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_agent/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_active_record/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_customizer/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_toolkit/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_rails/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_mongoid/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_rpc_agent/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_rpc/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_zendesk/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_snowflake/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_mambu_payments/coverage.json,${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_graphql_hasura/coverage.json
deploy:
name: Release package
runs-on: ubuntu-latest
needs: [coverage]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
- uses: actions/setup-node@v4
with:
node-version: 22.14.0
- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install semantic release dependencies
run: yarn
- name: Setup credentials
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${{secrets.GEM_HOST_API_KEY}}\n" > $HOME/.gem/credentials
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}