Skip to content

Commit 604a902

Browse files
committed
sync up .circleci/config with template
1 parent a9a27d2 commit 604a902

File tree

4 files changed

+166
-55
lines changed

4 files changed

+166
-55
lines changed

.circleci/config.yml

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
browser-tools: circleci/browser-tools@1.5.2
4+
browser-tools: circleci/browser-tools@2.2.0
55
node: circleci/node@7.1.0
66

77
jobs:
@@ -10,12 +10,10 @@ jobs:
1010
docker:
1111
- image: cimg/ruby:4.0.1-browsers
1212
environment:
13-
BUNDLE_JOBS: 3
14-
BUNDLE_RETRY: 3
1513
BUNDLE_PATH: vendor/bundle
14+
NODE_VERSION: 22.17.1
1615
PGHOST: 127.0.0.1
1716
PGUSER: postgres
18-
RACK_ENV: test
1917
RAILS_ENV: test
2018
- image: cimg/postgres:10.18
2119
environment:
@@ -25,22 +23,27 @@ jobs:
2523

2624
steps:
2725
- checkout
28-
- browser-tools/install-browser-tools:
29-
install-chrome: false
30-
install-chromedriver: false
3126

3227
- node/install:
33-
node-version: lts
28+
node-version: 25.6.0
29+
30+
- node/install-packages:
31+
pkg-manager: pnpm
32+
33+
- browser-tools/install_firefox
3434

3535
- run:
36-
name: Which bundler?
37-
command: bundle -v
36+
name: Which versions?
37+
command: |
38+
bundle -v
39+
node --version
40+
pnpm --version
3841
3942
# https://circleci.com/docs/2.0/caching/
4043
- restore_cache:
4144
keys:
42-
- bundle-v1-{{ checksum "Gemfile.lock" }}
43-
- bundle-v1-
45+
- bundle-v2-{{ checksum "Gemfile.lock" }}
46+
- bundle-v2
4447

4548
- run: # Install Ruby dependencies
4649
name: Bundle Install
@@ -50,41 +53,46 @@ jobs:
5053
bundle clean
5154
5255
- save_cache:
53-
key: bundle-v1-{{ checksum "Gemfile.lock" }}
56+
key: bundle-v2-{{ checksum "Gemfile.lock" }}
5457
paths:
5558
- vendor/bundle
5659

57-
- node/install-packages:
58-
pkg-manager: pnpm
59-
60-
- run:
61-
name: Build JS assets
62-
command: pnpm build
63-
6460
- run:
6561
name: Wait for DB
6662
command: dockerize -wait tcp://localhost:5432 -timeout 1m
6763

6864
- run:
6965
name: Database setup
70-
command: bundle exec rake db:create db:schema:load --trace
66+
command: bin/rails db:setup --trace
7167

72-
# - run:
73-
# name: Brakeman
74-
# command: bundle exec brakeman
68+
- run:
69+
name: Typescript
70+
command: pnpm tscheck
71+
72+
- run:
73+
name: Find Unused ESLint Rules
74+
command: pnpm eslint_find_unused_rules
7575

7676
- run:
7777
name: ESLint
7878
command: pnpm eslint
7979

8080
- run:
81-
name: Stylelint
82-
command: pnpm stylelint
81+
name: Verify ESLint Autogen
82+
command: bundle exec exe/eslint_autogen
8383

8484
- run:
8585
name: Vitest
8686
command: pnpm vitest run --coverage
8787

88+
- run:
89+
name: Brakeman
90+
command: bundle exec brakeman
91+
92+
- run:
93+
name: Stylelint
94+
command: pnpm stylelint
95+
8896
- run:
8997
name: Verify Stylelint Autogen
9098
command: bundle exec exe/stylelint_autogen
@@ -94,37 +102,37 @@ jobs:
94102
command: bundle exec rubocop
95103

96104
- run:
97-
name: Run rspec in parallel
105+
name: ✨ 🌈 ✨ Run Unit Tests ✨ 🌈 ✨
98106
command: |
99-
bundle exec rspec --exclude-pattern "spec/system/*_spec.rb"
100-
# bundle exec rspec --profile 10 \
101-
# --format RspecJunitFormatter \
102-
# --out test_results/rspec.xml \
103-
# --format progress \
104-
# $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
105-
106-
- store_test_results: # https://circleci.com/docs/2.0/collect-test-data/
107-
path: test_results
107+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
108+
grep -v "spec/system" | \
109+
circleci tests split --split-by=timings)"
110+
111+
echo "******************** TEST_FILES ************************"
112+
echo "bundle exec rspec -s <seed-from-failed-build> $TEST_FILES"
113+
echo "********************************************************"
114+
115+
COVERAGE=true bundle exec rspec \
116+
--format progress \
117+
--format RspecJunitFormatter \
118+
--out /tmp/test-results/rspec.xml \
119+
$TEST_FILES
108120
109121
- run:
110-
name: Run system tests
122+
name: ✨ 🌈 ✨ Run System Tests ✨ 🌈 ✨
111123
command: |
112-
COVERAGE=false bundle exec rspec spec/system/
124+
TEST_FILES="$(circleci tests glob "spec/system/**/*_spec.rb" | \
125+
circleci tests split --split-by=timings)"
113126
114-
workflows:
115-
build:
116-
jobs:
117-
- build
118-
119-
# https://circleci.com/docs/2.0/workflows/#nightly-example
120-
# https://circleci.com/docs/2.0/configuration-reference/#filters-1
121-
repeat:
122-
jobs:
123-
- build
124-
triggers:
125-
- schedule:
126-
cron: "0,20,40 * * * *"
127-
filters:
128-
branches:
129-
only:
130-
- /.*ci-repeat.*/
127+
echo "******************** TEST_FILES ************************"
128+
echo "bundle exec rspec -s <seed-from-failed-build> $TEST_FILES"
129+
echo "********************************************************"
130+
131+
xvfb-run -a bundle exec rspec \
132+
--format progress \
133+
--format RspecJunitFormatter \
134+
--out /tmp/test-results/rspec.xml \
135+
$TEST_FILES
136+
137+
- store_test_results:
138+
path: test_results

exe/exe/eslint_autogen

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "active_support/all"
5+
require "stringio"
6+
7+
TODO_FILE_PATH = "./.eslint_todo.ts"
8+
HEADING = <<~COMMENTS.freeze
9+
// This configuration was generated by `exe/eslint_autogen`
10+
// on #{Time.now.utc}.
11+
// The point is for the user to remove these configuration records
12+
// one by one as the offenses are removed from the code base.
13+
COMMENTS
14+
15+
File.write(TODO_FILE_PATH, "export default []")
16+
json = `pnpm --silent eslint --format json`
17+
results = JSON.parse(json)
18+
19+
by_rule =
20+
results.each_with_object({}) do |result, hash|
21+
result.fetch("messages").each do |message|
22+
rule_id = message.fetch("ruleId")
23+
next if rule_id.nil?
24+
25+
hash[rule_id] ||= []
26+
hash[rule_id] << result.fetch("filePath")
27+
end
28+
end
29+
30+
output = StringIO.new
31+
output.puts(HEADING)
32+
output.puts
33+
output.puts("import type {Linter} from \"eslint\";")
34+
output.puts
35+
output.puts("const config: Linter.Config[] = [")
36+
37+
by_rule.sort.each do |rule, file_paths|
38+
output.puts(" // Offense count: #{file_paths.length}")
39+
output.puts(" {")
40+
output.puts(" files: [")
41+
42+
file_paths.uniq.sort.each do |file_path|
43+
relative_path = file_path.sub("#{Dir.pwd}/", "")
44+
output.puts(" \"#{relative_path}\",")
45+
end
46+
47+
output.puts(" ],")
48+
output.puts(" rules: {")
49+
output.puts(" \"#{rule}\": \"off\",")
50+
output.puts(" },")
51+
output.puts(" },")
52+
end
53+
54+
output.puts("];")
55+
output.puts
56+
output.puts("export default config;")
57+
58+
File.write(TODO_FILE_PATH, output.string)

exe/exe/stylelint_autogen

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "active_support/all"
5+
require "stringio"
6+
7+
TODO_FILE_PATH = "./.stylelint_todo.yml"
8+
HEADING = <<~COMMENTS.freeze
9+
# This configuration was generated by `exe/stylelint_autogen`
10+
# on #{Time.now.utc}.
11+
# The point is for the user to remove these configuration records
12+
# one by one as the offenses are removed from the code base.
13+
COMMENTS
14+
15+
File.write(TODO_FILE_PATH, "{}")
16+
json =
17+
`pnpm --silent stylelint --quiet-deprecation-warnings --formatter json 2>&1`
18+
results = JSON.parse(json)
19+
20+
by_rule =
21+
results.each_with_object({}) do |result, hash|
22+
result.fetch("warnings").each do |warning|
23+
hash[warning.fetch("rule")] ||= []
24+
hash[warning.fetch("rule")] << result.fetch("source")
25+
end
26+
end
27+
28+
output = StringIO.new
29+
output.puts(HEADING)
30+
output.puts
31+
output.puts("overrides:")
32+
33+
by_rule.sort.each do |rule, file_paths|
34+
output.puts
35+
output.puts(" # Offense count: #{file_paths.length}")
36+
output.puts(" - rules: { '#{rule}': null }")
37+
output.puts(" files:")
38+
39+
file_paths.uniq.sort.each do |file_path|
40+
output.puts(" - #{file_path.sub("#{Dir.pwd}/", "")}")
41+
end
42+
end
43+
44+
File.write(TODO_FILE_PATH, output.string)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"scripts": {
44
"build": "esbuild app/javascript/*.* --bundle --sourcemap --format=iife --outdir=app/assets/builds --public-path=/assets --alias:jquery=./node_modules/jquery/jquery.js --alias:bootstrap=./node_modules/bootstrap/dist/js/bootstrap.js --alias:jquery-visible=./node_modules/jquery-visible/jquery.visible.min.js",
55
"eslint": "eslint ./ --cache --max-warnings=0",
6+
"eslint_find_unused_rules": "eslint-find-rules --unused --flatConfig --no-core eslint.config.mts",
67
"stylelint": "stylelint 'app/assets/stylesheets/**/*.css'",
78
"tscheck": "tsc --noEmit",
89
"pretest": "pnpm tscheck && pnpm eslint",

0 commit comments

Comments
 (0)