Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
deb66d8
Add Rubocop
william-lee-epigenesys Jun 4, 2026
f7163e6
Run rubocop -A to fix autocorrectable offences
william-lee-epigenesys Jun 4, 2026
6e7eb67
Move gem source development dependencies to gemspec
william-lee-epigenesys Jun 4, 2026
f26ad32
Clean up gemspec metadata and set required Ruby version
william-lee-epigenesys Jun 4, 2026
57cb8d0
Update year in LICENSE
william-lee-epigenesys Jun 4, 2026
aa09098
Add missing newline
william-lee-epigenesys Jun 4, 2026
3efd33e
Add ignoreRevsFile
william-lee-epigenesys Jun 4, 2026
9cd5d3b
Add explicit require statements in each file
william-lee-epigenesys Jun 4, 2026
0356427
Always run Ruby workflow on PRs
william-lee-epigenesys Jun 4, 2026
90967a0
Set fail-fast to false to ensure all jobs in the matrix are run
william-lee-epigenesys Jun 4, 2026
9b98b99
Set minimum byebug version to 11 to support Ruby < 3.2
william-lee-epigenesys Jun 4, 2026
dd3b089
Add irb as development dependency
william-lee-epigenesys Jun 5, 2026
e2c04f7
Configure aruba_helper to use built-in fixture system instead of runn…
william-lee-epigenesys Jun 5, 2026
81bd625
Configure relying on capistrano config files to use aruba
william-lee-epigenesys Jun 5, 2026
c571ea3
Update spec_helper and enforce double verification
william-lee-epigenesys Jun 5, 2026
9e79a75
Configure user.name and user.email for aruba
william-lee-epigenesys Jun 5, 2026
de41ee4
Add rubocop step to checks
william-lee-epigenesys Jun 5, 2026
59eaa10
Fix input for composite action
william-lee-epigenesys Jun 5, 2026
4c4303c
Fix syntax for using composite action
william-lee-epigenesys Jun 5, 2026
72b9300
Run checkout before using setup composite action
william-lee-epigenesys Jun 5, 2026
9e81059
Set Ruby version for rubocop job to 4.0
william-lee-epigenesys Jun 5, 2026
6cf758f
Drop support for Ruby 3.0
william-lee-epigenesys Jun 8, 2026
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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f7163e62937564239dfcd655fec48d0f342e8044
21 changes: 21 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Setup
description: Performs common setup steps
inputs:
ruby-version:
description: Ruby version to ues
required: true
runs:
using: composite
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby-version }}
bundler: "2.5.23"
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Set Git name
shell: sh
run: git config --global user.name "GitHub CI"
- name: Set Git email
shell: sh
run: git config --global user.email "github-ci@epigenesys.org.uk"
44 changes: 26 additions & 18 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,37 @@ name: Ruby

on:
push:
branches: [ master ]
branches:
- master
pull_request:
branches: [ master ]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ['3.0', '3.1', '3.2', '3.3', '4.0']

ruby-version:
- "3.1"
- "3.2"
- "3.3"
- "4.0"
steps:
- uses: actions/checkout@v2
- name: Setup
uses: ./.github/actions/setup
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests
run: bundle exec rspec
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler: '2.5.23'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Set Git name
run: git config --global user.name "GitHub CI"
- name: Set Git email
run: git config --global user.email "github-ci@epigenesys.org.uk"
- name: Run tests
run: bundle exec rspec
- uses: actions/checkout@v2
- name: Setup
uses: ./.github/actions/setup
with:
ruby-version: 4.0
- name: Run rubocop
run: bundle exec rubocop
continue-on-error: true
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_gem:
epi-rubocop: rubocop.yml
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in epi_deploy.gemspec
gemspec

group :development do
gem "rspec", '~> 3.1'
gem "aruba", '~> 1.0.0'
gem 'byebug'

gem 'capistrano', '~> 3.6'
gem "epi-rubocop", require: false, group: :development, git: "https://github.com/epigenesys/epi-rubocop.git"
end
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 Epi Genesys Ltd
Copyright (c) 2026 Epi Genesys Ltd

MIT License

Expand Down
39 changes: 21 additions & 18 deletions epi_deploy.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'epi_deploy/version'
require_relative "lib/epi_deploy/version"

Gem::Specification.new do |gem|
gem.name = "epi_deploy"
gem.version = EpiDeploy::VERSION
gem.authors = ["Anthony Nettleship", "Shuo Chen", "Chris Hunt", "James Gregory", "William Lee"]
gem.email = ["anthony.nettleship@epigenesys.org.uk", "shuo.chen@epigenesys.org.uk", "chris.hunt@epigenesys.org.uk", "james.gregory@epigenesys.org.uk", "william.lee@epigenesys.org.uk"]
gem.description = "A gem to facilitate deployment across multiple git branches and evironments"
gem.summary = "eD"
gem.homepage = "https://www.epigenesys.org.uk"
gem.name = "epi_deploy"
gem.version = EpiDeploy::VERSION
gem.authors = ["Anthony Nettleship", "Shuo Chen", "Chris Hunt", "James Gregory", "William Lee"]
gem.email = ["anthony.nettleship@epigenesys.org.uk", "shuo.chen@epigenesys.org.uk", "chris.hunt@epigenesys.org.uk", "james.gregory@epigenesys.org.uk", "william.lee@epigenesys.org.uk"]
gem.summary = "A gem to facilitate deployment across multiple Git branches and environments using Capistrano"
gem.homepage = "https://github.com/epigenesys/epi_deploy"
gem.license = "MIT"

gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.files = Dir["bin/*", "lib/**", "LICENSE.txt", "README.md"]
gem.executables = Dir["bin/*"].map { |f| File.basename(f) }

gem.add_dependency('bundler', '>= 2.5.23')
gem.add_dependency('git', '~> 1.5')
gem.add_dependency('slop', '~> 3.6')
gem.required_ruby_version = ">= 3.1"

gem.add_dependency "git", "~> 1.5"
gem.add_dependency "slop", "~> 3.6"
gem.add_dependency "bundler", ">= 2.5.23", "< 5"

gem.add_development_dependency "rspec", "~> 3.1"
gem.add_development_dependency "aruba", "~> 1.0.0"
gem.add_development_dependency "byebug", "~> 11.0"
gem.add_development_dependency "capistrano", "~> 3.6"
gem.add_development_dependency "irb", "~> 1.0"
end
2 changes: 1 addition & 1 deletion lib/capistrano/epi_deploy.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Dir.glob(File.join(File.dirname(__FILE__), 'tasks', '*.rb')).each { |f| require f }
Dir.glob(File.join(File.dirname(__FILE__), "tasks", "*.rb")).each { |f| require f }
12 changes: 6 additions & 6 deletions lib/capistrano/tasks/branches.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../epi_deploy/config'
require_relative "../../epi_deploy/config"

Dir["config/initializers/version.rb", "config/epi_deploy.rb"].each do |file|
require File.join(Dir.pwd, file)
Expand All @@ -7,19 +7,19 @@
if EpiDeploy.use_timestamped_deploy_tags
namespace :epi_deploy do
task :set_branch do
branch = if ENV['BRANCH']
ENV['BRANCH']
elsif Object.const_defined?('LATEST_RELEASE_TAG')
branch = if ENV["BRANCH"]
ENV["BRANCH"]
elsif Object.const_defined?("LATEST_RELEASE_TAG")
LATEST_RELEASE_TAG
end

if branch.nil?
raise 'Cannot determine commit to deploy as BRANCH environment variable is not set and LATEST_RELEASE_TAG constant in version.rb could not be found'
raise "Cannot determine commit to deploy as BRANCH environment variable is not set and LATEST_RELEASE_TAG constant in version.rb could not be found"
end

set :branch, branch
end
end

before 'deploy:starting', 'epi_deploy:set_branch'
before "deploy:starting", "epi_deploy:set_branch"
end
8 changes: 4 additions & 4 deletions lib/capistrano/tasks/multi_customers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
customer_settings_file = "config/customers/customer_settings/#{fetch(:current_customer)}.yml"
customer_settings_path = release_path.join(customer_settings_file)
if test("[ -f '#{customer_settings_path}' ]")
execute :ln, '-s', customer_settings_path, release_path.join("config/customer_settings.yml")
execute :ln, "-s", customer_settings_path, release_path.join("config/customer_settings.yml")
else
warn "Not symlinking customer configuration as #{customer_settings_file} not found"
end
Expand Down Expand Up @@ -42,7 +42,7 @@
def iterate_over_customers
Dir.glob("config/deploy/#{fetch(:stage)}.*.rb").sort.each_with_index do |file, index|
# Extract the variables required
stage_and_customer = File.basename file, '.rb'
stage_and_customer = File.basename file, ".rb"
customer = stage_and_customer[/\.(.+)$/, 1]

# Insert a blank line between each run
Expand All @@ -53,5 +53,5 @@ def iterate_over_customers
end
end

task deploy_all: 'deploy_all:deploy'
after 'deploy:updating', 'epi_deploy:symlink_customer_configs'
task deploy_all: "deploy_all:deploy"
after "deploy:updating", "epi_deploy:symlink_customer_configs"
2 changes: 1 addition & 1 deletion lib/epi_deploy.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require "epi_deploy/version"
require "epi_deploy/version"
40 changes: 21 additions & 19 deletions lib/epi_deploy/app_version.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module EpiDeploy
class AppVersion

attr_accessor :version_file_path, :version, :latest_release_tag

def initialize(current_dir = Dir.pwd)
self.version_file_path = File.join(current_dir, 'config/initializers/version.rb')
self.version_file_path = File.join(current_dir, "config/initializers/version.rb")
end

def load
Expand All @@ -15,12 +16,12 @@ def load
end
else
self.version = 0
self.latest_release_tag = ''
self.latest_release_tag = ""
end
end

def save!
File.open version_file_path, 'w' do |f|
File.open version_file_path, "w" do |f|
f.write "APP_VERSION = '#{version}'\n"
f.write "LATEST_RELEASE_TAG = '#{latest_release_tag}'\n"
end
Expand All @@ -37,21 +38,22 @@ def self.open(current_dir = Dir.pwd)
end

private
def version_file_exists?
File.exist? version_file_path
end

def extract_version_number(contents)
contents.match(/APP_VERSION\s*=\s*'(?<version>\d+).*'/)[:version].to_i
end

def extract_latest_release_tag(contents)
if (match = contents.match(/LATEST_RELEASE_TAG\s*=\s*'(?<tag>[A-Za-z0-9_-]+)'/))
match[:tag]
else
''
end
def version_file_exists?
File.exist? version_file_path
end

def extract_version_number(contents)
contents.match(/APP_VERSION\s*=\s*'(?<version>\d+).*'/)[:version].to_i
end

def extract_latest_release_tag(contents)
if (match = contents.match(/LATEST_RELEASE_TAG\s*=\s*'(?<tag>[A-Za-z0-9_-]+)'/))
match[:tag]
else
""
end

end

end
end
end
47 changes: 24 additions & 23 deletions lib/epi_deploy/cli.rb
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
require 'slop'
require "slop"

require_relative 'command'
require_relative "command"
require_relative "config"

module EpiDeploy
class Cli

def run!
load_config

Slop.parse strict: true do
banner "Usage: bundle exec epi_deploy <command>"

command "release" do
description "Create a new release with optional deploy"

on :d=, :deploy=, "Deploy to specified environment(s)", argument: :optional, as: Array, delimiter: ":"

banner 'Usage: bundle exec epi_deploy <command>'

command 'release' do
description 'Create a new release with optional deploy'

on :d=, :deploy=, 'Deploy to specified environment(s)', argument: :optional, as: Array, delimiter: ':'

run do |options, args|
command = EpiDeploy::Command.new(options, args)
command.release
end
end
command 'deploy' do
description 'Deploys an existing release'
on :r=, :ref=, 'Git reference to deploy', argument: :optional

command "deploy" do
description "Deploys an existing release"

on :r=, :ref=, "Git reference to deploy", argument: :optional

run do |options, args|
command = EpiDeploy::Command.new(options, args)
command.deploy
end
end

run do |options, args|
Kernel.abort "\x1B[31mValid commands are 'release' and 'deploy'.\x1B[0m"
end

end
rescue Slop::InvalidOptionError, Slop::InvalidArgumentError, RuntimeError => e
Kernel.abort "\x1B[31m#{e.message}\x1B[0m"
end

private

def load_config
config_path = File.join(Dir.pwd, 'config/epi_deploy.rb')
if File.exist?(config_path)
require config_path
end
def load_config
config_path = File.join(Dir.pwd, "config/epi_deploy.rb")
if File.exist?(config_path)
require config_path
end
end

end
end
end
Loading
Loading