Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Jun 19, 2020
1 parent 6620a8a commit 7ef2370
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Test"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup ssh key
run: |
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 700 ~/
chmod 400 ~/.ssh/authorized_keys
- name: Check ssh access
run: |
ssh -o StrictHostKeyChecking=no localhost uptime
- name: Setup systemd
run: |
loginctl enable-linger $USER
- name: Set up RVM
run: |
curl -sSL https://get.rvm.io | bash
- name: Run tests
run: |
source $HOME/.rvm/scripts/rvm
rvm install $(cat .ruby-version)
rvm in . do gem install bundler
rvm in . do bundle install --with development
rvm in . do bundle exec rake test
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.6.6
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ source "https://www.rubygems.org"

gem "rake"

ruby "2.6.6"

gemspec
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ Default systemctl command is ```systemctl --user```, this can be changed, for ex
For non privileged user (non sudo) usage set up path for systemctl unit file:

```ruby
set :service_unit_path, '/home/www/.config/systemd/user'
set :service_unit_path, '$HOME/.config/systemd/user'
```

where ```www``` is the username. For details see systemctl [doc page](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)
For details see systemctl [doc page](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)

To use systemctl integration with rbenv bundler path must be setted:

Expand Down
22 changes: 2 additions & 20 deletions test/deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ def mina(task)
system cmd
end

def check_process(pid)
pid = pid.to_i
begin
Process.kill(0, pid)
return true
rescue Errno::EPERM => e
puts "No permission to query #{pid}!"
raise e
rescue Errno::ESRCH
puts "#{pid} is NOT running."
return false
rescue
puts "Unable to determine status for #{pid} : #{$!}"
end
end

describe "setup" do
before { mina "setup" }
it "should deploy" do
Expand All @@ -49,15 +33,13 @@ def check_process(pid)
end
end
it "should start/stop sidekiq" do
sidekiq_pid_path = @env_root.join("deploy", "shared", "pids", "sidekiq.pid")
# fresh deploy
mina "deploy"
mina "sidekiq:start"
pid = File.read(sidekiq_pid_path)
check_process(pid).must_equal true
_(`systemctl --user is-active sidekiq-production.service`.strip).must_equal "is_active"
# second deploy
mina "sidekiq:stop"
check_process(pid).must_equal false
_(`systemctl --user is-active sidekiq-production.service`.strip).wont_equal "is_active"
end
end
end
6 changes: 4 additions & 2 deletions test_env/config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
FileUtils.mkdir_p "#{Dir.pwd}/deploy"

set :ssh_options, '-o StrictHostKeyChecking=no'
set :init_system, :systemd
set :systemctl_command, 'systemctl --user'
set :service_unit_path, "$HOME/.config/systemd/user"

set :domain, 'localhost'
set :deploy_to, "#{Dir.pwd}/deploy"
Expand All @@ -30,13 +33,12 @@
invoke :'bundle:install'

on :launch do
invoke :'sidekiq:install'
invoke :'sidekiq:start'
command %(sleep 3; kill -0 `cat #{fetch(:sidekiq_pid)}`)

invoke :'sidekiq:quiet'

invoke :'sidekiq:stop'
command %((kill -0 `cat #{fetch(:sidekiq_pid)}`) 2> /dev/null && exit 1 || exit 0)
end
end
end

0 comments on commit 7ef2370

Please sign in to comment.