Skip to content

Commit

Permalink
Merge pull request #52 from thatch-health/olivier-fix-ci
Browse files Browse the repository at this point in the history
Fix test suite and CI
  • Loading branch information
jorgemanrubia committed Dec 25, 2023
2 parents 1b361af + a499fe2 commit b228cc7
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 56 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
Expand All @@ -27,28 +27,37 @@ jobs:
image: postgres:13.4
env:
POSTGRES_HOST_AUTH_METHOD: "trust"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 55433:5432
mysql:
image: percona:5.7.22
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 33307:3306
env:
TARGET_DB: ${{ matrix.database }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Setup test database
run: |
bin/rails db:setup
env:
RAILS_ENV: test
run: bin/rails db:setup
- name: Run tests
run: bin/rails test
- name: Run system tests
run: bin/rails app:test:system
run: bundle exec rake test
22 changes: 20 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in audits1984.gemspec.
gemspec

gem 'sassc-rails'
gem 'sqlite3'
gem 'pg'
gem 'mysql2'

group :development do
gem 'sqlite3'
gem 'rubocop', '>= 1.18.4'
gem 'rubocop-performance'
gem 'rubocop-minitest'
gem 'rubocop-md'
gem 'rubocop-packaging'
gem 'rubocop-rails'
end

group :test do
gem 'minitest'

gem 'rails'
gem 'sprockets-rails'
gem 'puma'

gem 'capybara'
gem 'cuprite'
end

# To use a debugger
Expand Down
118 changes: 99 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,45 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.5)
actionpack (= 7.0.5)
activesupport (= 7.0.5)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.5)
actionpack (= 7.0.5)
activejob (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.5)
actionpack (= 7.0.5)
actionview (= 7.0.5)
activejob (= 7.0.5)
activesupport (= 7.0.5)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.5)
actionview (= 7.0.5)
activesupport (= 7.0.5)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.5)
actionpack (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.5)
activesupport (= 7.0.5)
builder (~> 3.1)
Expand All @@ -26,6 +58,18 @@ GEM
activejob (7.0.5)
activesupport (= 7.0.5)
globalid (>= 0.3.6)
activemodel (7.0.5)
activesupport (= 7.0.5)
activerecord (7.0.5)
activemodel (= 7.0.5)
activesupport (= 7.0.5)
activestorage (7.0.5)
actionpack (= 7.0.5)
activejob (= 7.0.5)
activerecord (= 7.0.5)
activesupport (= 7.0.5)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
Expand All @@ -49,8 +93,16 @@ GEM
parser
rainbow
crass (1.0.6)
cuprite (0.15)
capybara (~> 3.0)
ferrum (~> 0.14.0)
date (3.3.4)
erubi (1.12.0)
ffi (1.15.5)
ferrum (0.14)
addressable (~> 2.5)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (>= 0.6, < 0.8)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.14.1)
Expand All @@ -59,12 +111,31 @@ GEM
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.5)
minitest (5.18.0)
mysql2 (0.5.5)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.15.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.2-x86_64-darwin)
Expand All @@ -82,6 +153,20 @@ GEM
rack (2.2.7)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.5)
actioncable (= 7.0.5)
actionmailbox (= 7.0.5)
actionmailer (= 7.0.5)
actionpack (= 7.0.5)
actiontext (= 7.0.5)
actionview (= 7.0.5)
activejob (= 7.0.5)
activemodel (= 7.0.5)
activerecord (= 7.0.5)
activestorage (= 7.0.5)
activesupport (= 7.0.5)
bundler (>= 1.15.0)
railties (= 7.0.5)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
Expand All @@ -96,7 +181,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
regexp_parser (2.8.0)
rexml (3.2.5)
rinku (2.0.6)
Expand Down Expand Up @@ -127,62 +212,57 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.9.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.3)
mini_portile2 (~> 2.8.0)
sqlite3 (1.6.3-arm64-darwin)
sqlite3 (1.6.3-x86_64-darwin)
sqlite3 (1.6.3-x86_64-linux)
thor (1.2.2)
tilt (2.2.0)
timeout (0.4.1)
turbo-rails (1.4.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
websocket (1.2.9)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.8)

PLATFORMS
arm64-darwin-21
ruby
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
audits1984!
capybara
cuprite
minitest
mysql2
pg
puma
rails
rubocop (>= 1.18.4)
rubocop-md
rubocop-minitest
rubocop-packaging
rubocop-performance
rubocop-rails
sassc-rails
selenium-webdriver
sprockets-rails
sqlite3

BUNDLED WITH
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
![example workflow](https://github.com/basecamp/audits1984/actions/workflows/build.yml/badge.svg)
[![Build Status](https://github.com/basecamp/audits1984/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/basecamp/audits1984/actions?query=branch%3Amaster)

# Audits1984

A simple auditing tool for [`console1984`](https://github.com/basecamp/console1984).



## Installation

Add it to your `Gemfile`:
Expand All @@ -16,7 +14,7 @@ gem 'audits1984'

Create tables to store audits in the database:

```ruby
```sh
rails audits1984:install:migrations
rails db:migrate
```
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
t.warning = false
end

task default: :test
12 changes: 0 additions & 12 deletions audits1984.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,4 @@ Gem::Specification.new do |spec|
spec.add_dependency 'turbo-rails'
spec.add_dependency 'rinku'
spec.add_dependency 'console1984'

spec.add_development_dependency 'rubocop', '>= 1.18.4'
spec.add_development_dependency 'rubocop-performance'
spec.add_development_dependency 'rubocop-minitest'
spec.add_development_dependency 'rubocop-md'
spec.add_development_dependency 'rubocop-packaging'
spec.add_development_dependency 'rubocop-rails'
spec.add_development_dependency 'capybara'
spec.add_development_dependency 'selenium-webdriver'
spec.add_development_dependency 'puma'
spec.add_development_dependency 'pg'
spec.add_development_dependency 'mysql2'
end
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ services:
volumes:
- db:/var/lib/postgres
ports: [ "127.0.0.1:55433:5432" ]
mysql:
image: percona:5.7.22
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- db:/var/lib/mysql
ports: [ "127.0.0.1:33307:3306" ]

4 changes: 3 additions & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require "test_helper"

require "capybara/cuprite"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 900 ]
driven_by :cuprite, screen_size: [1440, 900], options: { headless: "new" }

include Audits1984::Engine.routes.url_helpers
end
3 changes: 3 additions & 0 deletions test/fixtures/console1984_sensitive_accesses.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sensitive_access:
session: sensitive_printing
justification: "Hi"
7 changes: 7 additions & 0 deletions test/fixtures/console1984_sessions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
arithmethic:
reason: "Arithmetic operations"
user: user

sensitive_printing:
reason: "Sensitive printing"
user: user
2 changes: 2 additions & 0 deletions test/fixtures/console1984_users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user:
username: user
2 changes: 1 addition & 1 deletion test/models/audits1984/filtered_sessions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Audits1984::FilteredSessionsTest < ActiveSupport::TestCase
test "return all sessions ordered by creation date" do
assert Console1984::Session.any?
assert_predicate Console1984::Session, :any?
assert_equal Console1984::Session.order(created_at: :desc, id: :desc), Audits1984::FilteredSessions.new.all
end

Expand Down
Loading

0 comments on commit b228cc7

Please sign in to comment.