mirror of
https://gitlab.com/components/sast.git
synced 2025-06-29 15:08:29 +02:00
Add .gitlab-ci.yml and test Ruby app
This commit is contained in:
parent
4150356e21
commit
85795eaed6
17 changed files with 240 additions and 8 deletions
47
.gitlab-ci.yml
Normal file
47
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,47 @@
|
|||
include:
|
||||
- component: gitlab.com/$CI_PROJECT_PATH@$CI_COMMIT_SHA
|
||||
|
||||
stages: [test, release]
|
||||
|
||||
# ensure-jobs-added:
|
||||
# image: badouralix/curl-jq
|
||||
# script:
|
||||
# - |
|
||||
# route="https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs"
|
||||
# count=`curl --silent --header "PRIVATE-TOKEN: $API_TOKEN" $route | jq 'map(select(.name | contains("component-job-"))) | length'`
|
||||
# if [ "$count" != "2" ]; then
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# Ensure that a project description exists, because it will be important to display
|
||||
# the resource in the catalog.
|
||||
check-description:
|
||||
image: badouralix/curl-jq
|
||||
script:
|
||||
- |
|
||||
route="https://gitlab.com/api/v4/projects/$CI_PROJECT_ID"
|
||||
desc=`curl --silent $route | jq '.description'`
|
||||
if [ "$desc" = "null" ]; then
|
||||
echo "Description not set. Please set a projet description"
|
||||
exit 1
|
||||
else
|
||||
echo "Description set"
|
||||
fi
|
||||
|
||||
# Ensure that a `README.md` exists in the root directory as it represents the
|
||||
# documentation for the whole components repository.
|
||||
check-readme:
|
||||
image: busybox
|
||||
script: ls README.md || (echo "Please add a README.md file" && exit 1)
|
||||
|
||||
# If we are tagging a release with a specific convention ("v" + number) and all
|
||||
# previous checks succeeded, we proceed with creating a release automatically.
|
||||
create-release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG =~ /\d+/
|
||||
script: echo "Creating release $CI_COMMIT_TAG"
|
||||
release:
|
||||
tag_name: $CI_COMMIT_TAG
|
||||
description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH"
|
|
@ -1,4 +1,4 @@
|
|||
## SAST (Static Application Security Testing)
|
||||
# SAST (Static Application Security Testing)
|
||||
|
||||
Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/sast/
|
||||
|
||||
|
@ -40,10 +40,3 @@ include:
|
|||
| `search_max_depth` | `4` | Defines how many directory levels the search for programming languages should span |
|
||||
| `run_kubesec_sast` | `"false"` | Set it to `"true"` to run `kubesec-sast` job |
|
||||
| `include_experimental` | `"false"` | Set it to `"true"` to enable [experimental analyzers](https://docs.gitlab.com/ee/user/application_security/sast/#experimental-features) |
|
||||
|
||||
### Variables
|
||||
|
||||
| Variable | Default value | Description |
|
||||
| -------- | ------------- | ----------- |
|
||||
|
||||
### ToDos
|
||||
|
|
11
src/ruby_gem/.gitignore
vendored
Normal file
11
src/ruby_gem/.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/.bundle/
|
||||
/.yardoc
|
||||
/_yardoc/
|
||||
/coverage/
|
||||
/doc/
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/tmp/
|
||||
|
||||
# rspec failure tracking
|
||||
.rspec_status
|
10
src/ruby_gem/.gitlab-ci.yml
Normal file
10
src/ruby_gem/.gitlab-ci.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
default:
|
||||
image: ruby:3.0.5
|
||||
|
||||
before_script:
|
||||
- gem install bundler -v 2.4.12
|
||||
- bundle install
|
||||
|
||||
example_job:
|
||||
script:
|
||||
- bundle exec rake
|
3
src/ruby_gem/.rspec
Normal file
3
src/ruby_gem/.rspec
Normal file
|
@ -0,0 +1,3 @@
|
|||
--format documentation
|
||||
--color
|
||||
--require spec_helper
|
13
src/ruby_gem/.rubocop.yml
Normal file
13
src/ruby_gem/.rubocop.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
AllCops:
|
||||
TargetRubyVersion: 2.6
|
||||
|
||||
Style/StringLiterals:
|
||||
Enabled: true
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Style/StringLiteralsInInterpolation:
|
||||
Enabled: true
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Layout/LineLength:
|
||||
Max: 120
|
12
src/ruby_gem/Gemfile
Normal file
12
src/ruby_gem/Gemfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
# Specify your gem's dependencies in ruby_gem.gemspec
|
||||
gemspec
|
||||
|
||||
gem "rake", "~> 13.0"
|
||||
|
||||
gem "rspec", "~> 3.0"
|
||||
|
||||
gem "rubocop", "~> 1.21"
|
31
src/ruby_gem/README.md
Normal file
31
src/ruby_gem/README.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# RubyGem
|
||||
|
||||
TODO: Delete this and the text below, and describe your gem
|
||||
|
||||
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
||||
|
||||
## Installation
|
||||
|
||||
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
||||
|
||||
Install the gem and add to the application's Gemfile by executing:
|
||||
|
||||
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
||||
|
||||
If bundler is not being used to manage dependencies, install the gem by executing:
|
||||
|
||||
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Write usage instructions here
|
||||
|
||||
## Development
|
||||
|
||||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
||||
|
||||
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
||||
|
||||
## Contributing
|
||||
|
||||
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_gem.
|
12
src/ruby_gem/Rakefile
Normal file
12
src/ruby_gem/Rakefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "bundler/gem_tasks"
|
||||
require "rspec/core/rake_task"
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
require "rubocop/rake_task"
|
||||
|
||||
RuboCop::RakeTask.new
|
||||
|
||||
task default: %i[spec rubocop]
|
11
src/ruby_gem/bin/console
Executable file
11
src/ruby_gem/bin/console
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "bundler/setup"
|
||||
require "ruby_gem"
|
||||
|
||||
# You can add fixtures and/or initialization code here to make experimenting
|
||||
# with your gem easier. You can also use a different console, if you like.
|
||||
|
||||
require "irb"
|
||||
IRB.start(__FILE__)
|
8
src/ruby_gem/bin/setup
Executable file
8
src/ruby_gem/bin/setup
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
set -vx
|
||||
|
||||
bundle install
|
||||
|
||||
# Do any other automated setup that you need to do here
|
8
src/ruby_gem/lib/ruby_gem.rb
Normal file
8
src/ruby_gem/lib/ruby_gem.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "ruby_gem/version"
|
||||
|
||||
module RubyGem
|
||||
class Error < StandardError; end
|
||||
# Your code goes here...
|
||||
end
|
5
src/ruby_gem/lib/ruby_gem/version.rb
Normal file
5
src/ruby_gem/lib/ruby_gem/version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module RubyGem
|
||||
VERSION = "0.1.0"
|
||||
end
|
38
src/ruby_gem/ruby_gem.gemspec
Normal file
38
src/ruby_gem/ruby_gem.gemspec
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "lib/ruby_gem/version"
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "ruby_gem"
|
||||
spec.version = RubyGem::VERSION
|
||||
spec.authors = ["Fabio Pitino"]
|
||||
spec.email = ["fpitino@gitlab.com"]
|
||||
|
||||
spec.summary = "TODO: Write a short summary, because RubyGems requires one."
|
||||
spec.description = "TODO: Write a longer description or delete this line."
|
||||
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
||||
spec.required_ruby_version = ">= 2.6.0"
|
||||
|
||||
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
||||
|
||||
spec.metadata["homepage_uri"] = spec.homepage
|
||||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
||||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
||||
|
||||
# Specify which files should be added to the gem when it is released.
|
||||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||
spec.files = Dir.chdir(__dir__) do
|
||||
`git ls-files -z`.split("\x0").reject do |f|
|
||||
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
||||
end
|
||||
end
|
||||
spec.bindir = "exe"
|
||||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
||||
spec.require_paths = ["lib"]
|
||||
|
||||
# Uncomment to register a new dependency of your gem
|
||||
# spec.add_dependency "example-gem", "~> 1.0"
|
||||
|
||||
# For more information and examples about making a new gem, check out our
|
||||
# guide at: https://bundler.io/guides/creating_gem.html
|
||||
end
|
4
src/ruby_gem/sig/ruby_gem.rbs
Normal file
4
src/ruby_gem/sig/ruby_gem.rbs
Normal file
|
@ -0,0 +1,4 @@
|
|||
module RubyGem
|
||||
VERSION: String
|
||||
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
||||
end
|
11
src/ruby_gem/spec/ruby_gem_spec.rb
Normal file
11
src/ruby_gem/spec/ruby_gem_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe RubyGem do
|
||||
it "has a version number" do
|
||||
expect(RubyGem::VERSION).not_to be nil
|
||||
end
|
||||
|
||||
it "does something useful" do
|
||||
expect(false).to eq(true)
|
||||
end
|
||||
end
|
15
src/ruby_gem/spec/spec_helper.rb
Normal file
15
src/ruby_gem/spec/spec_helper.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "ruby_gem"
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Enable flags like --only-failures and --next-failure
|
||||
config.example_status_persistence_file_path = ".rspec_status"
|
||||
|
||||
# Disable RSpec exposing methods globally on `Module` and `main`
|
||||
config.disable_monkey_patching!
|
||||
|
||||
config.expect_with :rspec do |c|
|
||||
c.syntax = :expect
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue