Skip to content

Commit d38beb1

Browse files
committed
Lint
1 parent fb7582b commit d38beb1

File tree

13 files changed

+644
-110
lines changed

13 files changed

+644
-110
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,60 @@
11
name: CI
22

3+
# TODO: Don't do this! Use GitHub's encrypted secrets and set the value of the
4+
# variable as ${{ secrets.RAILS_MASTER_KEY }}
5+
# Ref: https://docs.github.com/en/actions/reference/encrypted-secrets
6+
env:
7+
RAILS_MASTER_KEY: 02a9ea770b4985659e8ce92699f218dc
8+
39
on:
4-
pull_request:
510
push:
611
branches: [ main ]
12+
pull_request:
13+
branches: [ main ]
714

8-
jobs:
9-
scan_ruby:
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v4
15-
16-
- name: Set up Ruby
17-
uses: ruby/setup-ruby@v1
18-
with:
19-
ruby-version: .ruby-version
20-
bundler-cache: true
21-
22-
- name: Scan for common Rails security vulnerabilities using static analysis
23-
run: bin/brakeman --no-pager
24-
25-
scan_js:
26-
runs-on: ubuntu-latest
27-
28-
steps:
29-
- name: Checkout code
30-
uses: actions/checkout@v4
31-
32-
- name: Set up Ruby
33-
uses: ruby/setup-ruby@v1
34-
with:
35-
ruby-version: .ruby-version
36-
bundler-cache: true
37-
38-
- name: Scan for security vulnerabilities in JavaScript dependencies
39-
run: bin/importmap audit
15+
permissions:
16+
contents: read
4017

41-
lint:
18+
jobs:
19+
test:
20+
name: Ruby specs
4221
runs-on: ubuntu-latest
43-
steps:
44-
- name: Checkout code
45-
uses: actions/checkout@v4
22+
timeout-minutes: 60
4623

47-
- name: Set up Ruby
48-
uses: ruby/setup-ruby@v1
49-
with:
50-
ruby-version: .ruby-version
51-
bundler-cache: true
24+
concurrency:
25+
group: "${{ github.workflow }} @ ${{ github.ref }}"
26+
cancel-in-progress: true
5227

53-
- name: Lint code for consistent style
54-
run: bin/rubocop -f github
55-
56-
test:
57-
runs-on: ubuntu-latest
28+
env:
29+
DATABASE_URL: postgres://postgres:postgres@localhost/ruby3_rails8_flowbite_render_development
30+
RAILS_ENV: test
5831

5932
services:
60-
postgres:
61-
image: postgres
33+
db:
34+
image: postgres:12
35+
ports: ['5432:5432']
6236
env:
63-
POSTGRES_USER: postgres
6437
POSTGRES_PASSWORD: postgres
65-
ports:
66-
- 5432:5432
67-
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
6838

69-
# redis:
70-
# image: redis
71-
# ports:
72-
# - 6379:6379
73-
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
39+
options: >-
40+
--health-cmd pg_isready
41+
--health-interval 10s
42+
--health-timeout 5s
43+
--health-retries 5
7444
7545
steps:
76-
- name: Install packages
77-
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config google-chrome-stable
78-
79-
- name: Checkout code
80-
uses: actions/checkout@v4
81-
82-
- name: Set up Ruby
83-
uses: ruby/setup-ruby@v1
84-
with:
85-
ruby-version: .ruby-version
86-
bundler-cache: true
87-
88-
- name: Run tests
89-
env:
90-
RAILS_ENV: test
91-
DATABASE_URL: postgres://postgres:postgres@localhost:5432
92-
# REDIS_URL: redis://localhost:6379/0
93-
run: bin/rails db:test:prepare test test:system
94-
95-
- name: Keep screenshots from failed system tests
96-
uses: actions/upload-artifact@v4
97-
if: failure()
98-
with:
99-
name: screenshots
100-
path: ${{ github.workspace }}/tmp/screenshots
101-
if-no-files-found: ignore
46+
- uses: actions/checkout@v4
47+
- name: Set up Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: '3.4.1'
51+
bundler-cache: true
52+
- name: Set up Database
53+
run: bundle exec rails db:prepare
54+
- name: Run specs
55+
run: bundle exec rake spec
56+
- name: Coveralls
57+
uses: coverallsapp/github-action@v2
58+
with:
59+
github-token: ${{ secrets.github_token }}
60+
path-to-lcov: 'coverage/lcov.info'

.github/workflows/lint.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
rubocop:
14+
name: RuboCop
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
18+
concurrency:
19+
group: "${{ github.workflow }} / rubocop @ ${{ github.ref }}"
20+
cancel-in-progress: true
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: tj-actions/changed-files@v45
25+
id: changed-files
26+
with:
27+
files: |
28+
.github/workflows/lint.yml
29+
.rubocop.yml
30+
**.rb
31+
**.rake
32+
Gemfile*
33+
Rakefile
34+
- name: Set up Ruby
35+
if: steps.changed-files.outputs.any_changed == 'true'
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: .ruby-version
39+
bundler-cache: true
40+
- name: Run RuboCop
41+
if: steps.changed-files.outputs.any_changed == 'true'
42+
run: bundle exec rubocop --format github
43+
44+
i18n:
45+
name: I18n tasks
46+
runs-on: ubuntu-latest
47+
timeout-minutes: 15
48+
49+
concurrency:
50+
group: "${{ github.workflow }} / i18n @ ${{ github.ref }}"
51+
cancel-in-progress: true
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: tj-actions/changed-files@v45
56+
id: changed-files
57+
with:
58+
files: |
59+
.github/workflows/lint.yml
60+
config/i18n-tasks.yml
61+
config/locales/**/*.yml
62+
app/**/*
63+
Gemfile*
64+
- name: Setup Ruby
65+
if: steps.changed-files.outputs.any_changed == 'true'
66+
uses: ruby/setup-ruby@v1
67+
with:
68+
ruby-version: '3.4.1'
69+
bundler-cache: true
70+
- name: Run i18n-tasks health
71+
if: steps.changed-files.outputs.any_changed == 'true'
72+
run: bundle exec i18n-tasks health
73+
74+
slimlint:
75+
name: Slim-Lint
76+
runs-on: ubuntu-latest
77+
timeout-minutes: 15
78+
79+
concurrency:
80+
group: "${{ github.workflow }} / slimlint @ ${{ github.ref }}"
81+
cancel-in-progress: true
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: tj-actions/changed-files@v45
86+
id: changed-files
87+
with:
88+
files: |
89+
.github/workflows/lint.yml
90+
.slim-lint.yml
91+
**.slim
92+
- name: Set up Ruby
93+
if: steps.changed-files.outputs.any_changed == 'true'
94+
uses: ruby/setup-ruby@v1
95+
with:
96+
ruby-version: .ruby-version
97+
bundler-cache: true
98+
- name: Run Slim-Lint
99+
if: steps.changed-files.outputs.any_changed == 'true'
100+
run: bundle exec slim-lint . -r github
101+
102+
eslint:
103+
name: ESLint
104+
runs-on: ubuntu-latest
105+
timeout-minutes: 15
106+
107+
concurrency:
108+
group: "${{ github.workflow }} / eslint @ ${{ github.ref }}"
109+
cancel-in-progress: true
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
- uses: tj-actions/changed-files@v45
114+
id: changed-files
115+
with:
116+
files: |
117+
.eslintignore
118+
.eslintrc.cjs
119+
.github/workflows/lint.yml
120+
app/**/*.js
121+
- uses: pnpm/action-setup@v4
122+
- name: Set up Node
123+
if: steps.changed-files.outputs.any_changed == 'true'
124+
uses: actions/setup-node@v4
125+
with:
126+
node-version: '22'
127+
cache: 'pnpm'
128+
- name: Install node dependencies
129+
run: pnpm install
130+
- name: Run ESLint
131+
if: steps.changed-files.outputs.any_changed == 'true'
132+
run: pnpm eslint app/**/*.js
133+
134+
stylelint:
135+
name: Stylelint
136+
runs-on: ubuntu-latest
137+
timeout-minutes: 15
138+
139+
concurrency:
140+
group: "${{ github.workflow }} / stylelint @ ${{ github.ref }}"
141+
cancel-in-progress: true
142+
143+
steps:
144+
- uses: actions/checkout@v4
145+
- uses: tj-actions/changed-files@v45
146+
id: changed-files
147+
with:
148+
files: |
149+
.github/workflows/lint.yml
150+
.stylelintrc
151+
app/**/*.{scss,css}
152+
- uses: pnpm/action-setup@v4
153+
- name: Set up Node
154+
if: steps.changed-files.outputs.any_changed == 'true'
155+
uses: actions/setup-node@v4
156+
with:
157+
node-version: '22'
158+
cache: 'pnpm'
159+
- name: Install node dependencies
160+
run: pnpm install
161+
- name: Install stylelint GitHub formatter
162+
run: pnpm install @csstools/stylelint-formatter-github
163+
- name: Run Stylelint
164+
if: steps.changed-files.outputs.any_changed == 'true'
165+
run: pnpm stylelint app/**/*.{scss,css} --custom-formatter @csstools/stylelint-formatter-github

.github/workflows/security.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Security Audits
2+
3+
on:
4+
schedule:
5+
- cron: '30 8 * * 5'
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
bundle_audit:
12+
name: Bundle audit
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 15
15+
16+
concurrency:
17+
group: "${{ github.workflow }} / bundle_audit @ ${{ github.ref }}"
18+
cancel-in-progress: true
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: .ruby-version
26+
bundler-cache: false
27+
- name: Bundle audit
28+
run: |
29+
gem install bundler-audit
30+
bundle audit check --update
31+
32+
bundle_leak:
33+
name: Bundle leak
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 15
36+
37+
concurrency:
38+
group: "${{ github.workflow }} / bundle_leak @ ${{ github.ref }}"
39+
cancel-in-progress: true
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Set up Ruby
44+
uses: ruby/setup-ruby@v1
45+
with:
46+
ruby-version: .ruby-version
47+
bundler-cache: false
48+
- name: Bundle leak
49+
run: |
50+
gem install bundler-leak
51+
bundle leak check --update
52+
53+
importmap_audit:
54+
name: importmap audit
55+
runs-on: ubuntu-latest
56+
timeout-minutes: 15
57+
58+
concurrency:
59+
group: "${{ github.workflow }} / importmap_audit @ ${{ github.ref }}"
60+
cancel-in-progress: true
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
- name: Set up Ruby
65+
uses: ruby/setup-ruby@v1
66+
with:
67+
ruby-version: .ruby-version
68+
bundler-cache: true
69+
70+
- name: Scan for security vulnerabilities in JavaScript dependencies
71+
run: bin/importmap audit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
!/app/assets/builds/.keep
3838

3939
/spec/examples.txt
40+
/coverage

0 commit comments

Comments
 (0)