Skip to content

Commit 8797056

Browse files
committed
🛠️ Journal: Test only the Journal in CI
While working on zinc-collective#11, I realized I missed a piece of the refactor because I was leaning-on-ci as a way to confirm that everything was working as expected. Little did I know, CI was not working in this fork. Which makes sense, because you don't want to automatically turn on all the Workflows when you fork a project. This adds a Github Workflow for testing *just* the `Journal`, which should make detecting oopsie-daisys a bit easier for folks who are only interested in working on the Journal.
1 parent 7c33d7b commit 8797056

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Test Journal
2+
on: push
3+
4+
env:
5+
POSTGRES_USER: postgres
6+
POSTGRES_PASSWORD: postgres
7+
# Connect to locally-running Maildev for tests
8+
SMTP_PORT: 1025
9+
SMTP_DOMAIN: localhost
10+
SMTP_ENABLE_TLS: false
11+
REDIS_HOST: redis
12+
REDIS_PORT: 6379
13+
HEADLESS: true
14+
15+
jobs:
16+
setup:
17+
name: Install and cache dependencies
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Update apt
25+
env:
26+
DEBIAN_FRONTEND: noninteractive
27+
run:
28+
sudo apt-get update -qq -o Acquire::Retries=3
29+
30+
- name: Install libvips
31+
env:
32+
DEBIAN_FRONTEND: noninteractive
33+
run:
34+
# we only need the library
35+
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3
36+
libvips
37+
38+
- name: Setup Ruby and install gems
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
bundler-cache: true
42+
43+
- name: Setup Node with cache
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: 18
47+
cache: 'yarn'
48+
49+
- name: Install Node dependencies
50+
run: yarn install
51+
52+
test:
53+
name: Run Tests
54+
runs-on: ubuntu-latest
55+
needs: [setup]
56+
57+
services:
58+
postgres:
59+
image: postgres:latest
60+
env:
61+
POSTGRES_USER: postgres
62+
POSTGRES_PASSWORD: postgres
63+
ports:
64+
- 5432:5432
65+
# needed because the postgres container does not provide a healthcheck
66+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
67+
redis:
68+
image: redis
69+
ports:
70+
# Maps port 6379 on service container to the host
71+
- 6379:6379
72+
# Set health checks to wait until redis has started
73+
options: >-
74+
--health-cmd "redis-cli ping"
75+
--health-interval 10s
76+
--health-timeout 5s
77+
--health-retries 5
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v3
81+
82+
- name: Update apt
83+
env:
84+
DEBIAN_FRONTEND: noninteractive
85+
run:
86+
sudo apt-get update -qq -o Acquire::Retries=3
87+
88+
- name: Install libvips
89+
env:
90+
DEBIAN_FRONTEND: noninteractive
91+
run:
92+
# we only need the library
93+
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3
94+
libvips
95+
96+
- name: Install Firefox
97+
uses: browser-actions/setup-firefox@latest
98+
99+
- name: Setup Ruby and install gems
100+
uses: ruby/setup-ruby@v1
101+
with:
102+
bundler-cache: true
103+
104+
- name: Setup Node with cache
105+
uses: actions/setup-node@v3
106+
with:
107+
node-version: 18
108+
cache: 'yarn'
109+
110+
- name: Allow Ruby process to access port 80
111+
run: sudo setcap 'cap_net_bind_service=+ep' `which ruby`
112+
113+
- name: Setup CI database.yml
114+
run: cp config/database.yml.github-actions config/database.yml
115+
116+
- name: Setup rails
117+
run: bin/setup-rails && bin/rails assets:precompile
118+
119+
- name: Run Tests
120+
env:
121+
HEADLESS: true
122+
run: bundle exec rspec spec/furniture/journal
123+
- name: Upload RSpec Screenshots
124+
uses: actions/upload-artifact@v2
125+
if: failure()
126+
with:
127+
name: rspec-failed-screenshot
128+
path: tmp/capybara/*.png
129+
130+
lint:
131+
name: Run style checks
132+
runs-on: ubuntu-latest
133+
needs: [setup]
134+
135+
steps:
136+
- name: Checkout code
137+
uses: actions/checkout@v3
138+
139+
- name: Setup Ruby and install gems
140+
uses: ruby/setup-ruby@v1
141+
with:
142+
bundler-cache: true
143+
144+
- name: Setup Node with cache
145+
uses: actions/setup-node@v3
146+
with:
147+
node-version: 18
148+
cache: 'yarn'
149+
150+
- name: Install Node dependencies
151+
run: yarn install
152+
153+
- run: bundle exec rubocop --parallel --config .rubocop.yml
154+
- run: yarn prettier --check "./**/*.{scss,css,js}"

0 commit comments

Comments
 (0)