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

CIIZ-522/replace-panolint-with-panolint-ruby #332

Merged
merged 1 commit into from
Nov 15, 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
3 changes: 2 additions & 1 deletion .overcommit/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ source "https://rubygems.org"

gem "bundler"
gem "overcommit"
gem "panolint", github: "panorama-ed/panolint", branch: "main"
gem "panolint-ruby", git: "https://github.com/panorama-ed/panolint-ruby.git",
branch: "main"
48 changes: 7 additions & 41 deletions .overcommit/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
GIT
remote: https://github.com/panorama-ed/panolint.git
revision: a79ae364ad049052299858978a6bb69dad425b63
remote: https://github.com/panorama-ed/panolint-ruby.git
revision: bdbdbd49aa97990c2bc98dc8fdadc3c91c3b9591
branch: main
specs:
panolint (0.1.7)
brakeman (>= 4.8, < 6.0)
rubocop (>= 0.83, < 2.0)
rubocop-performance (~> 1.5)
rubocop-rails (~> 2.5)
rubocop-rake (~> 0.5)
rubocop-rspec (~> 2.0)
panolint-ruby (0)
rubocop (= 1.57.2)
rubocop-performance (= 1.19.1)
rubocop-rspec (= 2.25.0)

GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.4)
brakeman (5.4.1)
childprocess (4.1.0)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
iniparse (1.5.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
minitest (5.20.0)
mutex_m (0.2.0)
overcommit (0.60.0)
childprocess (>= 0.6.3, < 5)
iniparse (~> 1.4)
Expand All @@ -49,7 +25,6 @@ GEM
ast (~> 2.4.1)
racc
racc (1.7.3)
rack (3.0.8)
rainbow (3.1.1)
regexp_parser (2.8.2)
rexml (3.2.6)
Expand All @@ -73,20 +48,11 @@ GEM
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.22.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)

PLATFORMS
Expand All @@ -95,7 +61,7 @@ PLATFORMS
DEPENDENCIES
bundler
overcommit
panolint!
panolint-ruby!

BUNDLED WITH
2.3.26
6 changes: 2 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
inherit_gem:
panolint: rubocop.yml

Rails:
Enabled: false
panolint-ruby: panolint-ruby-rubocop.yml

24 changes: 14 additions & 10 deletions check_command_whitelist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,32 @@
"buildkite-agent pipeline upload ./buildkite/pipeline.yml"
].freeze

unless KNOWN_REPOSITORY_PREFIXES.any? { |prefix| ENV["BUILDKITE_REPO"].start_with?(prefix) }
puts "The requested repository (#{ENV["BUILDKITE_REPO"]}) cannot be cloned "\
unless KNOWN_REPOSITORY_PREFIXES.any? do |prefix|
ENV["BUILDKITE_REPO"].start_with?(prefix)
end
puts "The requested repository (#{ENV.fetch('BUILDKITE_REPO',
nil)}) cannot be cloned "\
"to this buildkite instance. If you actually need to use this repo "\
"please modify the agent bootstrapping script to allow cloning it."
exit 4
end

# Search for pipeline files in root and subdirectories
pipeline_paths = [File.join(
ENV["BUILDKITE_BUILD_CHECKOUT_PATH"],
ENV.fetch("BUILDKITE_BUILD_CHECKOUT_PATH", nil),
"buildkite",
"pipeline.yml"
)] + Dir.glob(File.join(
ENV["BUILDKITE_BUILD_CHECKOUT_PATH"],
"**",
"buildkite",
"pipeline.yml"
))
ENV.fetch("BUILDKITE_BUILD_CHECKOUT_PATH", nil),
"**",
"buildkite",
"pipeline.yml"
))

unless pipeline_paths.any? { |path| File.exist?(path) }
puts "All projects in the repository must have a 'buildkite/pipeline.yml' file "\
"that specifies the commands allowed to run on the buildkite server!"
puts "All projects in the repository must have a 'buildkite/pipeline.yml' "\
"file that specifies the commands allowed to run on the buildkite "\
"server!"
exit 1
end

Expand Down
10 changes: 5 additions & 5 deletions spec/check_command_whitelist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def execute_script(buildkite_command)

def setup_pipeline_file(path, content)
FileUtils.mkdir_p(path)
File.open("#{path}/pipeline.yml", "w+") do |file|
file.write(content)
end
File.write("#{path}/pipeline.yml", content)
end

subject do
Expand Down Expand Up @@ -196,7 +194,8 @@ def setup_pipeline_file(path, content)
end

let!(:subdir_pipeline_file) do
setup_pipeline_file("#{repo_path}/some_subdir/buildkite", subdir_pipeline_content)
setup_pipeline_file("#{repo_path}/some_subdir/buildkite",
subdir_pipeline_content)
end

let(:root_pipeline_content) do
Expand All @@ -219,7 +218,8 @@ def setup_pipeline_file(path, content)
it "passes for commands in any pipeline.yml" do
[root_command, subdir_command].each do |cmd|
status, output, _err = execute_script(cmd)
expect(status).to eq(0), "Command was: '#{cmd}'\nOutput was: \n#{output}"
expect(status).to eq(0),
"Command was: '#{cmd}'\nOutput was: \n#{output}"
end
end
end
Expand Down