gitlab-labkit 0.37.0 → 0.40.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.copier-answers.yml +16 -0
  3. data/.editorconfig +28 -0
  4. data/.gitlab-ci-asdf-versions.yml +5 -0
  5. data/.gitlab-ci.yml +32 -37
  6. data/.gitleaks.toml +10 -0
  7. data/.mise.toml +8 -0
  8. data/.pre-commit-config.yaml +38 -0
  9. data/.releaserc.json +19 -0
  10. data/.rubocop.yml +1 -58
  11. data/.rubocop_todo.yml +399 -77
  12. data/.tool-versions +3 -1
  13. data/.yamllint.yaml +11 -0
  14. data/CODEOWNERS +4 -0
  15. data/Dangerfile +7 -1
  16. data/LICENSE +1 -3
  17. data/README.md +6 -5
  18. data/Rakefile +14 -24
  19. data/config/covered_experiences/schema.json +35 -0
  20. data/config/covered_experiences/testing_sample.yml +4 -0
  21. data/gitlab-labkit.gemspec +13 -8
  22. data/lib/gitlab-labkit.rb +3 -1
  23. data/lib/labkit/context.rb +1 -0
  24. data/lib/labkit/covered_experience/README.md +134 -0
  25. data/lib/labkit/covered_experience/error.rb +9 -0
  26. data/lib/labkit/covered_experience/experience.rb +198 -0
  27. data/lib/labkit/covered_experience/null.rb +22 -0
  28. data/lib/labkit/covered_experience/registry.rb +105 -0
  29. data/lib/labkit/covered_experience.rb +69 -0
  30. data/lib/labkit/logging/json_logger.rb +11 -0
  31. data/lib/labkit/metrics/README.md +98 -0
  32. data/lib/labkit/metrics/client.rb +90 -0
  33. data/lib/labkit/metrics/null.rb +20 -0
  34. data/lib/labkit/metrics/rack_exporter.rb +12 -0
  35. data/lib/labkit/metrics/registry.rb +69 -0
  36. data/lib/labkit/metrics.rb +19 -0
  37. data/lib/labkit/rspec/README.md +121 -0
  38. data/lib/labkit/rspec/matchers/covered_experience_matchers.rb +198 -0
  39. data/lib/labkit/rspec/matchers.rb +10 -0
  40. data/renovate.json +7 -0
  41. data/scripts/install-asdf-plugins.sh +13 -0
  42. data/scripts/prepare-dev-env.sh +68 -0
  43. data/scripts/update-asdf-version-variables.sh +30 -0
  44. metadata +115 -34
  45. data/.ruby-version +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc40f1e37b87feea515d17caacf51c043e334fdd2cb2ae12689425dac2c2abaa
4
- data.tar.gz: 872361b6e95fbd14768ed454afd9ab5aeff18136d62ac7e46d0b636a2ea7877d
3
+ metadata.gz: 570e79f377fc9cfa11a87177437e6f66a6ed78c94958ad999744034922011e31
4
+ data.tar.gz: a58252e9bb1792ac0e6ca7e65d565f49803e917eb845de065ffb4921b1bf405c
5
5
  SHA512:
6
- metadata.gz: b75ee05daa1bcfe02e939a7573326c3850ce412b5b753fee6b6139ca323329def13d94a603651a58150e1905fd0c6a9cb6004f6c24190302bb34d9a9d06c1bbc
7
- data.tar.gz: 0bc7e7d9f5d877626691418da58d7ba4c660cd09533d44c0d6295a8edefb40f193ddfe865e10b434b266a6be42cfed10d6953f273b3a5bae0663c411e7ccda94
6
+ metadata.gz: eb4718ca04e0c5769180e3e23e3e658ea914a60c12142efc6f26bfc8f25b9a29d467c1c8fb582f23827c4e6cf3c9d72e65d7a7a469ab37465eb479f650e8269a
7
+ data.tar.gz: 90c9bff31da38826e4d60d6ac623f97257a78fbea63ea86aba8a15dd22df69e069ed628af48fc5f4695d58f1157c098f22a8e9676f97e8345522073349603bf5
@@ -0,0 +1,16 @@
1
+ # This project was initially generated with
2
+ # https://gitlab.com/gitlab-com/gl-infra/common-template-copier
3
+ # See the project for instructions on how to update the project
4
+ #
5
+ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
6
+ _commit: v1.35.1
7
+ _src_path: https://gitlab.com/gitlab-com/gl-infra/common-template-copier.git
8
+ ee_licensed: false
9
+ golang: false
10
+ helm: false
11
+ initial_codeowners: '@reprazent @andrewn @mkaeppler @ayufan'
12
+ jsonnet: false
13
+ project_name: labkit-ruby
14
+ ruby: true
15
+ rubygem: true
16
+ terraform: false
data/.editorconfig ADDED
@@ -0,0 +1,28 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+ indent_size = 2
11
+ indent_style = space
12
+ insert_final_newline = true
13
+ insert_final_newline = true
14
+ trim_trailing_whitespace = true
15
+
16
+ [.copier-*.yml]
17
+ insert_final_newline = unset
18
+ indent_size = unset
19
+
20
+ [*.md]
21
+ indent_size = unset
22
+
23
+ [{Makefile,**.mk}]
24
+ # Use tabs for indentation (Makefiles require tabs)
25
+ indent_style = tab
26
+
27
+ [*.rego]
28
+ indent_style = tab
@@ -0,0 +1,5 @@
1
+ # DO NOT MANUALLY EDIT; Run ./scripts/update-asdf-version-variables.sh to update this
2
+ variables:
3
+ GL_ASDF_RUBY_VERSION: "3.4.5"
4
+ GL_ASDF_SHELLCHECK_VERSION: "0.10.0"
5
+ GL_ASDF_SHFMT_VERSION: "3.12"
data/.gitlab-ci.yml CHANGED
@@ -1,57 +1,52 @@
1
- variables:
2
- RUBY_VERSION: "3.1.5"
3
-
4
- default:
5
- image: "ruby:${RUBY_VERSION}"
1
+ stages:
2
+ - validate
3
+ - release
4
+ - renovate_bot
6
5
 
6
+ # Prevent double-pipelines for branch pipelines vs. merge request pipelines
7
7
  workflow:
8
8
  rules:
9
- # For merge requests, create a pipeline.
10
- - if: '$CI_MERGE_REQUEST_IID'
11
- # For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
12
- - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
13
- # For tags, create a pipeline.
14
- - if: '$CI_COMMIT_TAG'
9
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
10
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
11
+ when: never
12
+ - if: $CI_COMMIT_BRANCH
13
+ - if: $CI_COMMIT_TAG
15
14
 
16
15
  include:
17
- - component: ${CI_SERVER_FQDN}/gitlab-org/components/danger-review/danger-review@1.4.1
18
- inputs:
19
- job_image: "ruby:${RUBY_VERSION}"
16
+ - local: .gitlab-ci-asdf-versions.yml
17
+
18
+ # This template should be included in all Infrastructure projects.
19
+ # It includes standard checks, gitlab-scanners, validations and release processes
20
+ # common to all projects using this template library.
21
+ # see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/templates/standard.md
22
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/standard-build@v2.78
23
+
24
+ # Runs rspec tests and rubocop on the project
25
+ # see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/templates/ruby.md
26
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/ruby-build@v2.78
27
+
28
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/danger@v2.78
20
29
 
21
30
  .test_template: &test_definition
31
+ extends: .with_bundle
22
32
  image: ruby:${RUBY_VERSION}
23
- stage: test
33
+ stage: validate
24
34
  script:
25
35
  - gem install bundler --no-document
26
36
  - bundle config --local path vendor
27
37
  - bundle install
28
38
  - bundle exec rake verify build install
29
- cache:
30
- key: ${CI_JOB_IMAGE}
31
- paths:
32
- - vendor/ruby
33
- ruby:
39
+
40
+ ruby-versions:
34
41
  <<: *test_definition
35
42
  parallel:
36
43
  matrix:
37
- - RUBY_VERSION: ["3.0", "3.1", "3.2"]
38
-
39
- static-analysis:
40
- before_script:
41
- - bundle install
42
- script:
43
- - rake verify
44
+ - RUBY_VERSION: ["3.2", "3.3"]
44
45
 
45
46
  deploy:
46
- stage: deploy
47
+ rules:
48
+ - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
49
+ extends: .with_bundle
50
+ stage: release
47
51
  script:
48
52
  - tools/deploy-rubygem.sh
49
- only:
50
- - tags
51
-
52
- release:
53
- stage: deploy
54
- script:
55
- - tools/update-changelog.rb "${CI_COMMIT_TAG}"
56
- only:
57
- - tags
data/.gitleaks.toml ADDED
@@ -0,0 +1,10 @@
1
+ title = "project-scoped gitleaks config"
2
+
3
+ [extend]
4
+ # useDefault will extend the base configuration with the default gitleaks config:
5
+ # https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml
6
+ useDefault = true
7
+
8
+ # See https://github.com/zricethezav/gitleaks#configuration
9
+ # for details of extending this configuration for allowlists,
10
+ # etc
data/.mise.toml ADDED
@@ -0,0 +1,8 @@
1
+ [settings]
2
+ legacy_version_file = false
3
+
4
+ [tools]
5
+ # Please continue to use `.tool-versions` to specify tool versions, rather than adding them directly here.
6
+
7
+ [plugins]
8
+ # Use this section to configure the source of any custom mise/asdf plugin
@@ -0,0 +1,38 @@
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+ ---
4
+ # Use exclude to exclude specific files
5
+ # exclude: '^fixtures/'
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v5.0.0 # renovate:managed
9
+ hooks:
10
+ - id: trailing-whitespace
11
+ - id: end-of-file-fixer
12
+ - id: check-yaml
13
+ - id: check-case-conflict
14
+ - id: check-symlinks
15
+ - id: check-json
16
+ - id: detect-private-key
17
+ - id: mixed-line-ending
18
+ args: ["--fix=lf"]
19
+ - id: no-commit-to-branch
20
+ args: [--branch, main]
21
+ - id: pretty-format-json
22
+ args: [--autofix, --no-sort-keys]
23
+
24
+ # pre-commit tasks from common-ci-tasks
25
+ # Documentation available at
26
+ # https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/docs/pre-commit.md
27
+ - repo: https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks
28
+ rev: v2.85 # renovate:managed
29
+
30
+ hooks:
31
+ - id: shellcheck # Run shellcheck for changed Shell files
32
+ - id: shfmt # Run shellcheck for changed Shell files
33
+ - id: update-asdf-version-variables # Update .gitlab-ci-asdf-versions.yml if .tool-versions has changed
34
+
35
+ # - id: gitlint # Checks your git commit messages for style
36
+ - id: gitleaks # Detect hardcoded secrets using Gitleaks
37
+ - id: editorconfig # Validate text files against .editorconfig
38
+ - id: yamllint # Validate YAML files using yamllint
data/.releaserc.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "branches": ["master"],
3
+ "plugins": [
4
+ [
5
+ "@semantic-release/commit-analyzer",
6
+ {
7
+ "preset": "conventionalcommits"
8
+ }
9
+ ],
10
+ [
11
+ "@semantic-release/release-notes-generator",
12
+ {
13
+ "preset": "conventionalcommits"
14
+ }
15
+ ],
16
+ "@gitlab/truncated-tags",
17
+ "@semantic-release/gitlab"
18
+ ]
19
+ }
data/.rubocop.yml CHANGED
@@ -5,61 +5,4 @@ inherit_gem:
5
5
  - rubocop-default.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.7
9
-
10
- Style/HashSyntax:
11
- EnforcedStyle: no_mixed_keys
12
-
13
- Style/SymbolLiteral:
14
- Enabled: No
15
-
16
- Style/TrailingCommaInArguments:
17
- Enabled: No # Delegated to rufo
18
-
19
- Style/TrailingCommaInHashLiteral:
20
- Enabled: No # Delegated to rufo
21
-
22
- Style/FrozenStringLiteralComment:
23
- EnforcedStyle: always
24
-
25
- Style/TrailingCommaInArrayLiteral:
26
- EnforcedStyleForMultiline: comma
27
-
28
- Style/StringLiterals:
29
- EnforcedStyle: double_quotes
30
-
31
- Style/StringLiteralsInInterpolation:
32
- EnforcedStyle: double_quotes
33
-
34
- Style/Lambda:
35
- Enabled: false
36
-
37
- Layout/LineLength:
38
- Enabled: false
39
-
40
- Layout/SpaceInLambdaLiteral:
41
- Enabled: No
42
-
43
- Layout/SpaceInsideBlockBraces:
44
- Enabled: No
45
-
46
- Layout/FirstParameterIndentation:
47
- Enabled: No
48
-
49
- RSpec/ExampleWording:
50
- Enabled: false
51
- CustomTransform:
52
- be: is
53
- have: has
54
- not: does not
55
- IgnoredWords: []
56
-
57
- Lint/HashCompareByIdentity: # (new in 0.93)
58
- Enabled: true
59
- Lint/RedundantSafeNavigation: # (new in 0.93)
60
- Enabled: true
61
- Style/ClassEqualityComparison: # (new in 0.93)
62
- Enabled: true
63
-
64
- CodeReuse/ActiveRecord:
65
- Enabled: false
8
+ NewCops: enable