Skip to content
Open
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
56 changes: 1 addition & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is a generated file by the `rake build_matrix:github:generate` task.
# See `build_matrix.yml` for the build matrix.
# Generate this file with `rake build_matrix:github:generate`.
# Generated job count: 194
# Generated job count: 192
---
name: Ruby gem CI
'on':
Expand Down Expand Up @@ -184,33 +184,6 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/capistrano3.gemfile
ruby_3-5-0-preview1__code_ownership_ubuntu-latest:
name: Ruby 3.5.0-preview1 - code_ownership
needs: ruby_3-5-0-preview1_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.5.0-preview1
bundler-cache: true
- name: Install gem extension
run: "./script/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./script/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/code_ownership.gemfile
ruby_3-5-0-preview1__dry-monitor_ubuntu-latest:
name: Ruby 3.5.0-preview1 - dry-monitor
needs: ruby_3-5-0-preview1_ubuntu-latest
Expand Down Expand Up @@ -1704,33 +1677,6 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/capistrano3.gemfile
ruby_3-3-4__code_ownership_ubuntu-latest:
name: Ruby 3.3.4 - code_ownership
needs: ruby_3-3-4_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.4
bundler-cache: true
- name: Install gem extension
run: "./script/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./script/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/code_ownership.gemfile
ruby_3-3-4__dry-monitor_ubuntu-latest:
name: Ruby 3.3.4 - dry-monitor
needs: ruby_3-3-4_ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions build_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ matrix:
- gem: "capistrano2"
- gem: "capistrano3"
- gem: "code_ownership"
only:
ruby:
- "3.4.1"
# - "3.3.4"
- "3.2.5"
- "3.1.6"
- "3.0.7"
- "2.7.8"
- "jruby-9.4.7.0"
- gem: "dry-monitor"
only:
ruby:
Expand Down
1 change: 0 additions & 1 deletion lib/appsignal/hooks/code_ownership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class CodeOwnershipHook < Appsignal::Hooks::Hook

def dependencies_present?
defined?(::CodeOwnership) &&
Gem::Specification.find_by_name("code_ownership").version < Gem::Version.new("2.0") &&
Appsignal.config && Appsignal.config[:instrument_code_ownership]
end

Expand Down
43 changes: 20 additions & 23 deletions spec/lib/appsignal/integrations/code_ownership_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
end

it "handles missing config file" do
create_app_files
transaction = create_transaction

logs = capture_logs do
load File.join(support_dir, "code_ownership", "file_annotation_based.rb")
load File.join(tmp_dir, "app", "file_annotation_based.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -34,11 +35,12 @@
end

it "handles missing team config files" do
create_app_files
create_config_file
transaction = create_transaction

logs = capture_logs do
load File.join(support_dir, "code_ownership", "file_annotation_based.rb")
load File.join(tmp_dir, "app", "file_annotation_based.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -54,6 +56,7 @@

context "and config is set up correctly" do
before do
create_app_files
create_config_file
create_team_files
end
Expand All @@ -72,7 +75,7 @@
transaction = create_transaction

begin
load File.join(support_dir, "code_ownership", "file_annotation_based.rb")
load File.join(tmp_dir, "app", "file_annotation_based.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -86,7 +89,7 @@
transaction = create_transaction

begin
load File.join(support_dir, "code_ownership", "dir", "directory_based.rb")
load File.join(tmp_dir, "app", "dir", "directory_based.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -100,7 +103,7 @@
transaction = create_transaction

begin
load File.join(support_dir, "code_ownership", "glob", "glob_based.rb")
load File.join(tmp_dir, "app", "glob", "glob_based.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -114,7 +117,7 @@
transaction = create_transaction

logs = capture_logs do
load File.join(support_dir, "code_ownership", "no_owner.rb")
load File.join(tmp_dir, "app", "no_owner.rb")
rescue => error
transaction.add_error(error)
ensure
Expand All @@ -140,6 +143,13 @@

private

def create_app_files
FileUtils.cp_r(
File.join(support_dir, "code_ownership", "app"),
File.join(tmp_dir)
)
end

def create_config_file
FileUtils.mkdir(File.join(tmp_dir, "config"))
FileUtils.copy_file(
Expand All @@ -149,23 +159,10 @@ def create_config_file
end

def create_team_files
FileUtils.mkdir(File.join(tmp_dir, "config", "teams"))

%w[file directory].each do |team|
FileUtils.copy_file(
File.join(support_dir, "code_ownership", "config", "teams", "#{team}.yml"),
File.join(tmp_dir, "config", "teams", "#{team}.yml")
)
end

glob_team =
<<~CONFIG
name: GlobTeam
owned_globs:
- #{File.join(support_dir, "code_ownership", "glob", "*.rb")}
CONFIG

write_file(File.join(tmp_dir, "config", "teams", "glob.yml"), glob_team)
Comment on lines 151 to -168
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that everything is loaded from the same directory, there's no need for a dynamic owned_globs property, so I moved the glob_team config into the config/teams/glob.yml fixture.

FileUtils.cp_r(
File.join(support_dir, "code_ownership", "config", "teams"),
File.join(tmp_dir, "config")
)
end
end
end
2 changes: 2 additions & 0 deletions spec/support/code_ownership/config/teams/directory.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
name: DirectoryTeam
github:
team: '@AcmeOrg/dir-team'
2 changes: 2 additions & 0 deletions spec/support/code_ownership/config/teams/file.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
name: FileTeam
github:
team: '@AcmeOrg/file-team'
6 changes: 6 additions & 0 deletions spec/support/code_ownership/config/teams/glob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: GlobTeam
github:
team: '@AcmeOrg/glob-team'
owned_globs:
- "app/glob/*.rb"

Loading