Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in Github actions #28

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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