From 7ef23701ebb20a13c3052fa88637bac32b31332e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 18 Jun 2020 16:39:22 +0100 Subject: [PATCH] add github action --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ .ruby-version | 1 + .travis.yml | 9 --------- Gemfile | 2 ++ README.md | 4 ++-- test/deploy_test.rb | 22 ++-------------------- test_env/config/deploy.rb | 6 ++++-- 7 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 .ruby-version delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2c2f006 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..f6ab44e --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.6.6 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index aa82ef4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: ruby -cache: bundler -rvm: - - "2.2.5" - - "2.3.1" - -before_install: - - ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa - - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys diff --git a/Gemfile b/Gemfile index 12ea392..2d44788 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,6 @@ source "https://www.rubygems.org" gem "rake" +ruby "2.6.6" + gemspec diff --git a/README.md b/README.md index 51fa970..053a3a1 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/test/deploy_test.rb b/test/deploy_test.rb index eb9d360..727221f 100644 --- a/test/deploy_test.rb +++ b/test/deploy_test.rb @@ -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 @@ -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 diff --git a/test_env/config/deploy.rb b/test_env/config/deploy.rb index 8625831..8e1ab83 100644 --- a/test_env/config/deploy.rb +++ b/test_env/config/deploy.rb @@ -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" @@ -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