Skip to content

Commit 29f42bc

Browse files
committed
Add GitHub Actions for CI
Make sure we test if the apps actually work.
1 parent 0ce623e commit 29f42bc

3 files changed

Lines changed: 91 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Frontend test setups tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
schedule:
13+
- cron: "0 0 * * 1-5"
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ !contains(github.ref, 'main') }}
18+
19+
env:
20+
RUNNING_IN_CI: "true"
21+
22+
jobs:
23+
test:
24+
name: "Test ${{ matrix.app }}"
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 15
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
app:
31+
- angular/13
32+
- angular/14
33+
- react/cra-16
34+
- react/cra-17
35+
- react/cra-17-typescript
36+
- react/cra-18
37+
- react/vite-18
38+
- react/vite-19
39+
- stimulus/3
40+
- vue/2
41+
- vue/3
42+
- vue/3-class-component
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version-file: .tool-versions
51+
52+
- name: Setup Ruby
53+
uses: ruby/setup-ruby@v1
54+
with:
55+
ruby-version: "3.3"
56+
bundler-cache: true
57+
58+
- name: Install yarn
59+
run: npm install -g yarn
60+
61+
- name: Setup Chrome
62+
uses: browser-actions/setup-chrome@v1
63+
with:
64+
chrome-version: stable
65+
66+
- name: Run tests
67+
env:
68+
CI: "true"
69+
TEST_APP: ${{ matrix.app }}
70+
run: bundle exec rspec

spec/features/error_tracking_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "spec_helper"
22

3-
describe "Error tracking", :type => :feature do
3+
describe "Error tracking", type: :feature do
44
before :all do
55
Thread.new do
66
run_endpoint
@@ -13,7 +13,8 @@
1313
end
1414
end
1515

16-
all_apps.each do |a_app|
16+
apps = ENV["TEST_APP"] ? [ENV["TEST_APP"]] : all_apps
17+
apps.each do |a_app|
1718
context "for #{a_app}" do
1819
let(:app) { a_app }
1920

@@ -51,7 +52,7 @@
5152
body = JSON.parse(request.body.read)
5253

5354
# Timestamp
54-
expect(body["timestamp"]).to be > 1644138966
55+
expect(body["timestamp"]).to be > 1_644_138_966
5556

5657
# Error
5758
expect(body["error"]).to be_a_kind_of Hash
@@ -68,7 +69,7 @@
6869
expect(body["revision"]).to eq "revision"
6970

7071
# Tags
71-
expect(body["tags"]). to be_a_kind_of Hash
72+
expect(body["tags"]).to be_a_kind_of Hash
7273
end
7374
end
7475
end

spec/spec_helper.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require "capybara/rspec"
22
require "json"
33
require "pry"
4-
require_relative "../support/helpers.rb"
5-
require_relative "./support/endpoint_server.rb"
4+
require_relative "../support/helpers"
5+
require_relative "./support/endpoint_server"
66

77
RSpec.configure do |config|
88
config.expect_with :rspec do |expectations|
@@ -16,7 +16,20 @@
1616
config.shared_context_metadata_behavior = :apply_to_host_groups
1717
end
1818

19-
Capybara.default_driver = :selenium
19+
Capybara.register_driver :headless_chrome do |app|
20+
options = Selenium::WebDriver::Chrome::Options.new
21+
options.add_argument("--headless=new")
22+
options.add_argument("--no-sandbox")
23+
options.add_argument("--disable-dev-shm-usage")
24+
options.add_argument("--disable-gpu")
25+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
26+
end
27+
28+
Capybara.default_driver = if ENV["CI"]
29+
:headless_chrome
30+
else
31+
:selenium
32+
end
2033

2134
def run_endpoint
2235
EndpointServer.run!

0 commit comments

Comments
 (0)