-
Notifications
You must be signed in to change notification settings - Fork 19
213 lines (198 loc) · 6.95 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
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
212
213
name: Rails Template CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
schedule:
# * is a special character in YAML so you have to quote this string
# * At 05:00 UTC every Monday, run the latest commit on the default or base branch
- cron: '0 5 * * MON'
concurrency:
# Pushing new changes to a branch will cancel any in-progress CI runs
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Restrict jobs in this workflow to have no permissions by default; permissions
# should be granted per job as needed using a dedicated `permissions` block
permissions: {}
env:
# reduces noise from npm install
DISABLE_OPENCOLLECTIVE: true
OPEN_SOURCE_CONTRIBUTOR: true
NPM_CONFIG_FUND: false
NPM_CONFIG_AUDIT: false
jobs:
audit_dependencies:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Audit dependencies for security vulnerabilities
uses: g-rath/check-with-osv-detector@main
with:
osv-detector-version: 0.13.0
test:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'yarn'
- run: yarn install
- run: yarn run format-check
rubocop:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Ruby and Bundler
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 'ruby'
- name: Run Rubocop
run: bundle exec rubocop
test_generated_apps:
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
# don't stop all variants if one of them fails (we usually want to know
# how many fail)
fail-fast: false
matrix:
js_package_manager:
- name: npm
installer: npm
- name: yarn_berry
installer: yarn
linker: pnp
- name: yarn_berry
installer: yarn
linker: node-modules
- name: yarn_berry
installer: yarn
linker: pnpm
- name: yarn_classic
installer: yarn
- name: pnpm
installer: pnpm
- name: bun
installer: bun
variant:
- name: defaults
config_path: 'ackama_rails_template.config.yml'
install_actionlint: 'yes'
- name: all
config_path: 'ci/configs/all.yml'
install_actionlint: 'yes'
- name: all-typescript
config_path: 'ci/configs/all-typescript.yml'
install_actionlint: 'yes'
- name: basic
config_path: 'ci/configs/basic.yml'
- name: basic-typescript
config_path: 'ci/configs/basic-typescript.yml'
- name: github_actions
config_path: 'ci/configs/github_actions.yml'
install_actionlint: 'yes'
- name: react
config_path: 'ci/configs/react.yml'
- name: react-typescript
config_path: 'ci/configs/react-typescript.yml'
- name: sidekiq
config_path: 'ci/configs/sidekiq.yml'
- name: devise
config_path: 'ci/configs/devise.yml'
- name: basic_with_skips
config_path: 'ci/configs/basic.yml'
skips: --skip-spring --skip-javascript
- name: bootstrap
config_path: 'ci/configs/bootstrap.yml'
- name: bootstrap-typescript
config_path: 'ci/configs/bootstrap-typescript.yml'
- name: capistrano
config_path: 'ci/configs/deploy_with_capistrano.yml'
- name: ackama_ec2_capistrano
config_path: 'ci/configs/deploy_with_ackama_ec2_capistrano.yml'
services:
db:
image: postgres
env:
# The Postgres service fails its docker health check unless you
# specify these environment variables
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: anything # can be anything, is ignored by the tests
ports: ['5432:5432']
# prettier-ignore
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
persist-credentials: false
# this ensures that osv-detector is available for running bin/ci-run
- name: Check dependencies for vulnerabilities (and setup osv-detector)
uses: g-rath/check-with-osv-detector@main
with:
osv-detector-version: 0.13.0
# this ensures that actionlint is available for running bin/ci-run
- name: Setup ActionLint
if: matrix.variant.install_actionlint == 'yes'
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
sudo ln -s "$PWD/actionlint" /usr/local/bin/actionlint
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- name: install package manager
run: npm i -g ${{ matrix.js_package_manager.installer }}
# We don't cache gems or JS packages because we are actually testing how
# installation and setup works in this project so, while caching would
# make CI faster, it might hide problems.
- name: Install Ruby and Bundler
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 'ruby'
- name: Setup git for committing
run: |
# We do some git commits during our testing so these need to be set
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
# prettier-ignore
- run: ./ci/bin/create-fake-js-package-managers ${{ matrix.js_package_manager.installer }}
- name: Run CI script
env:
# Remember that your app name becomes a top-level constant in the
# Rails app so you'll run into issues if that constant shares a name
# with a class provided by a gem. Basically, don't name your app
# "react", "sidekiq" etc.
APP_NAME: ${{ matrix.variant.name }}-demo
CONFIG_PATH: ${{ matrix.variant.config_path }}
SKIPS: '--skip-javascript --skip-docker ${{ matrix.variant.skips }}'
PGUSER: postgres
PGPASSWORD: postgres
PGHOST: localhost
PACKAGE_JSON_FALLBACK_MANAGER: ${{ matrix.js_package_manager.name }}
PACKAGE_JSON_YARN_BERRY_LINKER:
${{ matrix.js_package_manager.linker }}
run: ./ci/bin/build-and-test