Skip to content

Commit

Permalink
Merge pull request #28 from basecamp/github-action-ci
Browse files Browse the repository at this point in the history
Run tests in Github actions
  • Loading branch information
djmb authored Oct 16, 2023
2 parents b7b960b + 2e76576 commit 6ca84fc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build
on: [push, pull_request]

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: [3.2.2]
database: [mysql]
services:
mysql:
image: mysql:8.0.31
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- 33060:3306
options: --health-cmd "mysql -h localhost -e \"select now()\"" --health-interval 1s --health-timeout 5s --health-retries 30
env:
TARGET_DB: ${{ matrix.database }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Setup test database
run: |
bin/rails db:setup
- name: Run tests
run: bin/rails test
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ GEM
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
racc (1.7.1)
rack (3.0.8)
rack-session (2.0.0)
Expand Down Expand Up @@ -184,6 +186,7 @@ GEM

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
debug
Expand Down
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ def signal_process(pid, signal, wait: nil)
end

def process_exists?(pid)
reap_processes
Process.getpgid(pid)
true
rescue Errno::ESRCH
false
end

def reap_processes
Process.waitpid(-1, Process::WNOHANG)
rescue Errno::ECHILD
end

# Allow skipping AR query cache, necessary when running test code in multiple
# forks. The queries done in the test might be cached and if we don't perform
# any non-SELECT queries after previous SELECT queries were cached on the connection
Expand Down

0 comments on commit 6ca84fc

Please sign in to comment.