This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 229
177 lines (176 loc) · 4.92 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
name: CI
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "17 10 * * SAT"
env:
BUNDLE_PATH: "./vendor/bundle"
jobs:
generate:
name: "Generate App From Template"
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/ci
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: ci
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "ruby"
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
- shell: bash
name: rails new
run: |
TEMPLATE_HOME=`pwd`
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global init.defaultBranch main
gem install railties --version "~> 7.1.0" --no-document
gem install bundler --no-document
mkdir -p ~/scratch/generated_app
cd ~/scratch/generated_app
rails new . -d postgresql -m $TEMPLATE_HOME/template.rb << INPUT
ci.example.com
INPUT
rm -rf .git
tar cfz ../generated_app.tgz .
- uses: actions/upload-artifact@v3
with:
name: generated_app
path: ~/scratch/generated_app.tgz
retention-days: 1
if-no-files-found: error
test:
name: "Test"
runs-on: ubuntu-latest
needs: [generate]
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/ci
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: ci
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: mkdir -p ./tmp/screenshots
- run: bundle exec rake db:create db:schema:load test:all
- uses: actions/upload-artifact@v3
if: failure()
with:
name: system-test-screenshots
path: ./tmp/screenshots/
retention-days: 7
if-no-files-found: ignore
erblint:
name: "Lint / erblint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/erblint --lint-all
eslint:
name: "Lint / eslint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: yarn lint:js
rubocop:
name: "Lint / rubocop"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/rubocop
stylelint:
name: "Lint / stylelint"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: yarn
- run: npx --yes ci
- run: yarn lint:css
brakeman:
name: "Security / brakeman"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec brakeman --exit-on-warn --no-progress --color --output /dev/stdout
bundle-audit:
name: "Security / bundle-audit"
runs-on: ubuntu-latest
needs: [generate]
steps:
- uses: actions/download-artifact@v3
with:
name: generated_app
- run: tar xfz generated_app.tgz
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec bundle-audit check --update -v