-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (153 loc) · 5.52 KB
/
Copy pathbuild.yml
File metadata and controls
176 lines (153 loc) · 5.52 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
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
strategy:
matrix:
ruby-version: ["3.2", "3.3"]
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
steps:
- name: Checkout
uses: actions/checkout@v4
- 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: |
gem install bundler
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
needs: [lint]
strategy:
matrix:
ruby-version: ["3.2", "3.3"]
packages:
- forest_admin_agent
- forest_admin_datasource_active_record
- forest_admin_datasource_customizer
- forest_admin_datasource_toolkit
- forest_admin_datasource_mongoid
- forest_admin_rpc_agent
- forest_admin_datasource_rpc
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v4
- 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: |
gem install bundler
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 == '3.3' }}
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
needs: [test]
strategy:
matrix:
ruby-version: ["3.3"]
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_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
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: 18.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@v2
id: semantic
with:
semantic_version: 17.3.0
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 }}