gitlab-ci-lint 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +17 -0
- data/.gitignore +60 -0
- data/.rspec +3 -0
- data/.rspec_status +0 -0
- data/CHANGELOG.md +0 -0
- data/Dockerfile +0 -0
- data/Gemfile +15 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/Rakefile +31 -0
- data/bin/gitlab_ci_lint +11 -0
- data/docker-compose.yml +0 -0
- data/docs/annotations/docker.md +49 -0
- data/docs/annotations/rake.md +44 -0
- data/docs/annotations/structure.md +33 -0
- data/file.log +2 -0
- data/gitlab.gemspec +33 -0
- data/lib/gitlab/ci/lint.rb +50 -0
- data/lib/gitlab/ci/lint/client.rb +0 -0
- data/lib/gitlab/ci/lint/reader/yml.rb +19 -0
- data/lib/gitlab/ci/lint/settings/arguments.rb +27 -0
- data/lib/gitlab/ci/lint/settings/colors.rb +17 -0
- data/lib/gitlab/ci/lint/settings/configuration.rb +24 -0
- data/lib/gitlab/ci/lint/settings/log.rb +52 -0
- data/lib/gitlab/ci/lint/version.rb +7 -0
- data/spec/gitlab/ci/lint/spec.rb +5 -0
- data/spec/spec_helper.rb +14 -0
- data/values.yml +8 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbc8c0ce3294d33e6c86fc6c57d93eb23e307748f8f43272e862730291146ecf
|
4
|
+
data.tar.gz: fb8b2550005db49dfdded165edfe4f1ed4d67104d6d80055e5eb00efd13bdaf2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c621acb83df88e18a69810f4d10dfc039cc71806735b5847ec653fea5d91e6aefebd1439b65d579397b1488a852b67afbabf7cee4c3d993293680112a5119ae4
|
7
|
+
data.tar.gz: 1df71baac7d2b68d723af888e27652e050d0215955812a87efeaff717406c0ce81439778918ae3ff8a395e20f0043bd19dd17d974623b02d4699c74c868b14c6
|
data/.editorconfig
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# http://editorconfig.org
|
2
|
+
|
3
|
+
root = true
|
4
|
+
|
5
|
+
[*]
|
6
|
+
indent_style = space
|
7
|
+
indent_size = 2
|
8
|
+
insert_final_newline = true
|
9
|
+
trim_trailing_whitespace = true
|
10
|
+
end_of_line = lf
|
11
|
+
charset = utf-8
|
12
|
+
|
13
|
+
[*.yaml,*.yml]
|
14
|
+
indent_size = 2
|
15
|
+
|
16
|
+
[CHANGELOG.md]
|
17
|
+
indent_size = false
|
data/.gitignore
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
.env
|
42
|
+
|
43
|
+
Gemfile.lock
|
44
|
+
|
45
|
+
## Environment normalization:
|
46
|
+
/.bundle/
|
47
|
+
/vendor/bundle
|
48
|
+
/lib/bundler/man/
|
49
|
+
|
50
|
+
# for a library or gem, you might want to ignore these files since the code is
|
51
|
+
# intended to run in multiple environments; otherwise, check them in:
|
52
|
+
# Gemfile.lock
|
53
|
+
# .ruby-version
|
54
|
+
# .ruby-gemset
|
55
|
+
|
56
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
57
|
+
.rvmrc
|
58
|
+
|
59
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
60
|
+
# .rubocop-https?--*
|
data/.rspec
ADDED
data/.rspec_status
ADDED
File without changes
|
data/CHANGELOG.md
ADDED
File without changes
|
data/Dockerfile
ADDED
File without changes
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem "bundler"
|
9
|
+
gem "rake"
|
10
|
+
gem "rspec"
|
11
|
+
gem "httparty"
|
12
|
+
gem "OptionParser"
|
13
|
+
gem "yaml"
|
14
|
+
gem "colorize"
|
15
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 lpmatos
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# GitLab CI Linter
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
# Base description
|
10
|
+
desc "Default description."
|
11
|
+
|
12
|
+
# Declare a Default Task.
|
13
|
+
task default: [:spec, :helper]
|
14
|
+
|
15
|
+
# Create a Default Task.
|
16
|
+
task :helper do
|
17
|
+
puts "This is a Helper Task... If you need other thing, please, check the documentation."
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create Principal Task with namespace
|
21
|
+
namespace :main do
|
22
|
+
# A Short description about this Task.
|
23
|
+
desc "Base Rakefile to Ruby."
|
24
|
+
# Create Task Install
|
25
|
+
task :install do
|
26
|
+
puts "Installing Packages with Bundle..."
|
27
|
+
`bundle install`
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# To list your tasks - rake --tasks
|
data/bin/gitlab_ci_lint
ADDED
data/docker-compose.yml
ADDED
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Docker Commands
|
2
|
+
|
3
|
+
This is a list with some Docker command. I hope that help you! 😊
|
4
|
+
|
5
|
+
## Exec
|
6
|
+
|
7
|
+
Enter inside the container.
|
8
|
+
|
9
|
+
```bash
|
10
|
+
docker exec -it <CONTAINER_NAME> <COMMAND>
|
11
|
+
```
|
12
|
+
|
13
|
+
## Cleaning
|
14
|
+
|
15
|
+
Clean your Docker environment.
|
16
|
+
|
17
|
+
```bash
|
18
|
+
docker system prune -af
|
19
|
+
```
|
20
|
+
|
21
|
+
* Stop all containers.
|
22
|
+
|
23
|
+
```bash
|
24
|
+
docker stop $(docker ps -aq)
|
25
|
+
```
|
26
|
+
|
27
|
+
* Remove all containers.
|
28
|
+
|
29
|
+
```bash
|
30
|
+
docker rm $(docker ps -aq)
|
31
|
+
```
|
32
|
+
|
33
|
+
* Remove all images.
|
34
|
+
|
35
|
+
```bash
|
36
|
+
docker rmi $(docker images -a)
|
37
|
+
```
|
38
|
+
|
39
|
+
* Remove all volumes.
|
40
|
+
|
41
|
+
```bash
|
42
|
+
docker volume prune -f
|
43
|
+
```
|
44
|
+
|
45
|
+
* Remove all network.
|
46
|
+
|
47
|
+
```bash
|
48
|
+
docker network prune -f
|
49
|
+
```
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Rake
|
2
|
+
|
3
|
+
O Rake é um popular corredor de tarefas em Ruby.
|
4
|
+
|
5
|
+
## What's a task?
|
6
|
+
|
7
|
+
Uma tarefá pode ser:
|
8
|
+
|
9
|
+
* Executar testes.
|
10
|
+
* Estatísticas de coleta e geração de relatórios.
|
11
|
+
* Fazer backup do banco de dados.
|
12
|
+
|
13
|
+
Esses são pequenos exemplos de tarefas que, sem o Rake, seriam espalhadas por todo seu projeto em arquivos diferentes.
|
14
|
+
|
15
|
+
## Description
|
16
|
+
|
17
|
+
O que é Rake? Basicamente o Rake é um gerenciador de tarefas e dependência descrito em Ruby.
|
18
|
+
|
19
|
+
Podemos compará-lo como sendo uma alternativa ao Makefile, porém com a sintaxe em Ruby.
|
20
|
+
|
21
|
+
O Rake irá centralizar o acesso ás nossas tarefas. Ele também facilita algumas coisas, como encontrar arquivos que correspondam a um determinado padrão e que foram modificados recentemente.
|
22
|
+
|
23
|
+
## Observation
|
24
|
+
|
25
|
+
Não confunda Rake com Rack, apesar de serem nomes semelhantes, representam coisas completamente diferentes.
|
26
|
+
|
27
|
+
* Rake:
|
28
|
+
* É um corredor de tarfas.
|
29
|
+
* Rack:
|
30
|
+
* Ajuda servidores e estruturas em Ruby a trabalharem em conjunto.
|
31
|
+
|
32
|
+
## Who Uses Rake?
|
33
|
+
|
34
|
+
O cara mais famoso é o Rails. Se você já fez alguma coisa com o Rails, provavelmente está familiarizado com o rake db:migrate. O rake entra em ação aqui. Desde a versão 5.0 o Rails permite chamar a maioria dos comandos rake.
|
35
|
+
|
36
|
+
## Rake Task Exemple
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
desc "Description task."
|
40
|
+
|
41
|
+
task :apple do
|
42
|
+
puts "Eat more apples!"
|
43
|
+
end
|
44
|
+
```
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Structure of a Gem
|
2
|
+
|
3
|
+
Each Gem has a:
|
4
|
+
|
5
|
+
* Name.
|
6
|
+
* Version.
|
7
|
+
* Plataform.
|
8
|
+
|
9
|
+
For exemple, the rake gem has a 0.8.7 version (from May, 2009). Rake's plataform is ruby, which means it works on any plataform Ruby runs on.
|
10
|
+
|
11
|
+
Plataforms are based on the CPU architecture, operating system type and sometimes the operating system version. The plataform indicates the gem only works with a Ruby built for the same plataform.
|
12
|
+
|
13
|
+
Inside gems are the following components:
|
14
|
+
|
15
|
+
* Code (including tests and supporting utilities).
|
16
|
+
* Documentation.
|
17
|
+
* gemspec.
|
18
|
+
|
19
|
+
Each gem follows the same standard strucutre of code organization:
|
20
|
+
|
21
|
+
```txt
|
22
|
+
% tree freewill
|
23
|
+
freewill/
|
24
|
+
├── bin/
|
25
|
+
│ └── freewill
|
26
|
+
├── lib/
|
27
|
+
│ └── freewill.rb
|
28
|
+
├── test/
|
29
|
+
│ └── test_freewill.rb
|
30
|
+
├── README
|
31
|
+
├── Rakefile
|
32
|
+
└── freewill.gemspec
|
33
|
+
```
|
data/file.log
ADDED
data/gitlab.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gitlab/ci/lint/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gitlab-ci-lint"
|
8
|
+
spec.version = Gitlab::Ci::Lint::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ["Lucca Pessoa da Silva Matos"]
|
11
|
+
spec.email = "luccapsm@gmail.com"
|
12
|
+
spec.summary = %q{Validate your gitlab-ci.yml files}
|
13
|
+
spec.description = "Gitlab CI Lint"
|
14
|
+
spec.homepage = "https://github.com/lpmatos/gitlab-ci-lint"
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
all_files = `git ls-files`.split("\n")
|
20
|
+
test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
spec.files = all_files - test_files
|
22
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
23
|
+
spec.bindir = "bin"
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.license = 'MIT'
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "httparty", "~> 0.18.0"
|
30
|
+
spec.add_development_dependency "OptionParser", "~> 0.5.1"
|
31
|
+
spec.add_development_dependency "yaml", "~> 0.1.0"
|
32
|
+
spec.add_development_dependency "colorize", "~> 0.8.1"
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module Ci
|
3
|
+
module Lint
|
4
|
+
require File.expand_path("lint/reader/yml", File.dirname(__FILE__))
|
5
|
+
require File.expand_path("lint/settings/arguments", File.dirname(__FILE__))
|
6
|
+
require File.expand_path("lint/settings/configuration", File.dirname(__FILE__))
|
7
|
+
require File.expand_path("lint/settings/log", File.dirname(__FILE__))
|
8
|
+
require File.expand_path("lint/client", File.dirname(__FILE__))
|
9
|
+
|
10
|
+
def self.validate gitlab_ci_config
|
11
|
+
unless gitlab_ci_config
|
12
|
+
$stderr.puts('Error: You must specify the path to a .gitlab-ci.yml')
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
gitlab_ci_config = File.absolute_path(gitlab_ci_config)
|
16
|
+
unless File.readable?(gitlab_ci_config)
|
17
|
+
$stderr.puts("Error: Could not find file at '#{gitlab_ci_config}'")
|
18
|
+
return 1
|
19
|
+
end
|
20
|
+
begin
|
21
|
+
configuration = Configuration.new
|
22
|
+
logger = Log.instance
|
23
|
+
yml_reader = ReaderYMLFile.new(gitlab_ci_config)
|
24
|
+
options = command_line_parser()
|
25
|
+
values = yml_reader.get_content
|
26
|
+
gitlab = values["gitlab"]
|
27
|
+
|
28
|
+
gitlab_endpoint = options["endpoint"] ?
|
29
|
+
options["endpoint"] : ((!gitlab["endpoint"].to_s.empty? && !gitlab["endpoint"].nil?) ?
|
30
|
+
gitlab["endpoint"] : configuration.gitlab_endpoint)
|
31
|
+
|
32
|
+
gitlab_token = options["token"] ?
|
33
|
+
options["token"] : ((!gitlab["token"].to_s.empty? && !gitlab["token"].nil?) ?
|
34
|
+
gitlab["token"] : configuration.gitlab_token)
|
35
|
+
|
36
|
+
logger.info("Starting...")
|
37
|
+
|
38
|
+
puts "\nEndpoint: #{gitlab_endpoint}"
|
39
|
+
puts "Token: #{gitlab_token}\n"
|
40
|
+
rescue StandardError => e
|
41
|
+
$stderr.puts("Invalid: #{gitlab_ci_config}")
|
42
|
+
$stderr.puts(" * #{e}")
|
43
|
+
return 1
|
44
|
+
end
|
45
|
+
$stdout.puts("OK: #{gitlab_ci_config}")
|
46
|
+
return 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Ci
|
5
|
+
class ReaderYMLFile
|
6
|
+
attr_reader :file
|
7
|
+
def initialize file
|
8
|
+
@file = file
|
9
|
+
end
|
10
|
+
def get_content
|
11
|
+
begin
|
12
|
+
return eval(YAML.load_file(@file).inspect)
|
13
|
+
rescue ArgumentError => error
|
14
|
+
puts "Could not parse the YAML File: #{error.message}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
def program_name
|
4
|
+
return File.basename(__FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def help
|
8
|
+
string = """Command Line Helper to the Program - #{program_name()}
|
9
|
+
Usage Exemple: ruby example.rb [options]
|
10
|
+
Options:
|
11
|
+
-h | --helper HELPER.
|
12
|
+
-e | --endpoint GITLAB ENDPOINT.
|
13
|
+
-t | --token GITLAB PRIVATE TOKEN.\n
|
14
|
+
"""
|
15
|
+
return puts string
|
16
|
+
end
|
17
|
+
|
18
|
+
def command_line_parser
|
19
|
+
options = {}
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: example.rb [options]"
|
22
|
+
opts.on("-h", "--helper") { |value| help() }
|
23
|
+
opts.on("-e", "--endpoint GITLAB ENDPOINT", "GitLab Endpoint") { |value| options["endpoint"] = value }
|
24
|
+
opts.on("-t", "--token GITLAB PRIVATE TOKEN", "GitLab Private Token") { |value| options["token"] = value }
|
25
|
+
end.parse!
|
26
|
+
return options
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Colors
|
2
|
+
COLORS = {"default" => "38", "black" => "30", "red" => "31",
|
3
|
+
"green" => "32", "brown" => "33", "blue" => "34", "purple" => "35",
|
4
|
+
"cyan" => "36", "gray" => "37", "dark gray" => "1;30",
|
5
|
+
"light red" => "1;31", "light green" => "1;32", "yellow" => "1;33",
|
6
|
+
"light blue" => "1;34", "light purple" => "1;35", "light cyan" => "1;36",
|
7
|
+
"white" => "1;37"}
|
8
|
+
BACKGROUD_COLORS = {"default" => "0", "black" => "40", "red" => "41",
|
9
|
+
"green" => "42", "brown" => "43", "blue" => "44",
|
10
|
+
"purple" => "45", "cyan" => "46", "gray" => "47",
|
11
|
+
"dark gray" => "100", "light red" => "101", "light green" => "102",
|
12
|
+
"yellow" => "103", "light blue" => "104", "light purple" => "105",
|
13
|
+
"light cyan" => "106", "white" => "107"}
|
14
|
+
def self.colorize(message, color="default", backgroud_color="default")
|
15
|
+
return "\033[#{BACKGROUD_COLORS[backgroud_color]};#{COLORS[color]}m#{message}\033[0m"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module Ci
|
3
|
+
class Configuration
|
4
|
+
attr_reader :gitlab_ci_file, :gitlab_ci_path, :gitlab_endpoint,
|
5
|
+
:gitlab_token, :log_file
|
6
|
+
def initialize
|
7
|
+
@gitlab_ci_file = ENV["GITLAB_CI_FILE"]
|
8
|
+
@gitlab_ci_path = ENV["GITLAB_CI_PATH"]
|
9
|
+
@gitlab_endpoint = ENV["GITLAB_ENDPOINT"]
|
10
|
+
@gitlab_token = ENV["GITLAB_TOKEN"]
|
11
|
+
@log_file = ENV["LOG_FILE"]
|
12
|
+
end
|
13
|
+
def variables
|
14
|
+
return {
|
15
|
+
"gitlab_ci_file" => @gitlab_ci_file,
|
16
|
+
"gitlab_ci_path" => @gitlab_ci_path,
|
17
|
+
"gitlab_endpoint" => @gitlab_endpoint,
|
18
|
+
"gitlab_token" => @gitlab_token,
|
19
|
+
"log_file" => @log_file
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "logger"
|
2
|
+
require "singleton"
|
3
|
+
require_relative "./colors.rb"
|
4
|
+
|
5
|
+
class MultiIO
|
6
|
+
def initialize(*targets)
|
7
|
+
@targets = targets
|
8
|
+
end
|
9
|
+
def write(*args)
|
10
|
+
@targets.each {|target| target.write(*args)}
|
11
|
+
end
|
12
|
+
def close
|
13
|
+
@targets.each(&:close)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
class Log < Colors
|
19
|
+
include Singleton
|
20
|
+
attr_accessor :logger
|
21
|
+
def initialize(log_file="./file.log")
|
22
|
+
@logger = Logger.new MultiIO.new(STDOUT,
|
23
|
+
File.open(File.exist?(log_file) ? log_file : "./file.log", "a"))
|
24
|
+
@logger.level = Logger::INFO
|
25
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
26
|
+
datetime = "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}]"
|
27
|
+
case severity
|
28
|
+
when "INFO"
|
29
|
+
colorized_severity = self.class.colorize("#{severity}", "black", "green")
|
30
|
+
self.class.colorize("#{colorized_severity} - #{datetime} - #{msg}\n", "black", "green")
|
31
|
+
when "ERROR"
|
32
|
+
colorized_severity = self.class.colorize("#{severity}", "black", "red")
|
33
|
+
"#{colorized_severity} - #{datetime} - #{msg}\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def set_level(level)
|
38
|
+
@logger.level = level
|
39
|
+
end
|
40
|
+
def info(message, color=:green)
|
41
|
+
@logger.info(message)
|
42
|
+
end
|
43
|
+
def debug(message, color=:green)
|
44
|
+
@logger.debug(message)
|
45
|
+
end
|
46
|
+
def error(message, color=:green)
|
47
|
+
@logger.error(message)
|
48
|
+
end
|
49
|
+
def warn(message)
|
50
|
+
@logger.warn(message)
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "gitlab/ci/lint"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
data/values.yml
ADDED
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitlab-ci-lint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucca Pessoa da Silva Matos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.18.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.18.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: OptionParser
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.5.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yaml
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: colorize
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.8.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.8.1
|
111
|
+
description: Gitlab CI Lint
|
112
|
+
email: luccapsm@gmail.com
|
113
|
+
executables:
|
114
|
+
- gitlab_ci_lint
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".editorconfig"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rspec_status"
|
122
|
+
- CHANGELOG.md
|
123
|
+
- Dockerfile
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/gitlab_ci_lint
|
129
|
+
- docker-compose.yml
|
130
|
+
- docs/annotations/docker.md
|
131
|
+
- docs/annotations/rake.md
|
132
|
+
- docs/annotations/structure.md
|
133
|
+
- file.log
|
134
|
+
- gitlab.gemspec
|
135
|
+
- lib/gitlab/ci/lint.rb
|
136
|
+
- lib/gitlab/ci/lint/client.rb
|
137
|
+
- lib/gitlab/ci/lint/reader/yml.rb
|
138
|
+
- lib/gitlab/ci/lint/settings/arguments.rb
|
139
|
+
- lib/gitlab/ci/lint/settings/colors.rb
|
140
|
+
- lib/gitlab/ci/lint/settings/configuration.rb
|
141
|
+
- lib/gitlab/ci/lint/settings/log.rb
|
142
|
+
- lib/gitlab/ci/lint/version.rb
|
143
|
+
- spec/gitlab/ci/lint/spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- values.yml
|
146
|
+
homepage: https://github.com/lpmatos/gitlab-ci-lint
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata:
|
150
|
+
homepage_uri: https://github.com/lpmatos/gitlab-ci-lint
|
151
|
+
source_code_uri: https://github.com/lpmatos/gitlab-ci-lint
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubygems_version: 3.1.2
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Validate your gitlab-ci.yml files
|
171
|
+
test_files: []
|