allure-report-publisher 0.2.1 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 676e5c29b0fb534f66b54f22f06e5a9c7c3f429d7c2923fd6285139234cd563d
4
- data.tar.gz: f68177fdde3a101fb501b47fb82897f7b48ba8e5669a1d1ee5f4a631364505a4
3
+ metadata.gz: c8d8f37477b030841d60ed2c4888ae199474c6f01a72474f5a7456ec17681eb6
4
+ data.tar.gz: 7d71a7f33c78fbf236acd2dccbf1fffbee130636b3998c2c1e3e71a6ed71b3c0
5
5
  SHA512:
6
- metadata.gz: 826a881f81782358f580c4c5565c62d8b3dd06156bf224174d58149053c74a5d1e9456040c3dd6a136151ba0c091cf0fe74bcd3e945112dbe3a60eba4e05d6ba
7
- data.tar.gz: 50da6a0a16eeb2bd24b1473003515c9fbd58fc28dfc171994129d9a13a796a5fbd2cef76a46358f7736385c6c67fa4dc097abd6f06ed494bc5c27e48b03c236f
6
+ metadata.gz: 268f1a1e09b5fbdd19d2458d4741548484a65f9a86427101dff8b65abebb087249c689775749ab662a1533ea9c2394e3b4b23409d8d2e1578b987fb42a2f62e7
7
+ data.tar.gz: 19e92ffbda0b812657fae9fdd416309bbf1c69ed2543a094f624b6ad557a1d65b65908bbfbede9f3885684eaaf000edeef010aff2ad756d0c2e351dab41a32bd
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # allure-report-publisher
2
+
1
3
  [![Gem Version](https://img.shields.io/gem/v/allure-report-publisher?color=red)](https://rubygems.org/gems/allure-report-publisher)
2
4
  [![Gem Pulls](https://img.shields.io/gem/dt/allure-report-publisher)](https://rubygems.org/gems/allure-report-publisher)
3
5
  [![Docker Image Version (latest semver)](https://img.shields.io/docker/v/andrcuns/allure-report-publisher?color=blue&label=docker&sort=semver)](https://hub.docker.com/r/andrcuns/allure-report-publisher)
@@ -7,31 +9,25 @@
7
9
  [![Maintainability](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/maintainability)](https://codeclimate.com/github/andrcuns/allure-report-publisher/maintainability)
8
10
  [![Test Coverage](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/test_coverage)](https://codeclimate.com/github/andrcuns/allure-report-publisher/test_coverage)
9
11
 
10
- # allure-report-publisher
11
-
12
12
  Upload your report to a file storage of your choice.
13
13
 
14
14
  ![Demo](demo.gif)
15
15
 
16
- ## Installation
16
+ # Installation
17
17
 
18
- ### Rubygems
18
+ ## Rubygems
19
19
 
20
20
  ```shell
21
21
  gem install allure-report-uploader
22
22
  ```
23
23
 
24
- ### Docker
24
+ ## Docker
25
25
 
26
26
  ```shell
27
27
  docker pull andrcuns/allure-report-publisher:latest
28
28
  ```
29
29
 
30
- ## Usage
31
-
32
- allure-report-publisher will automatically detect if used in CI environment and add relevant executor info and history
33
-
34
- - `--update-pr=(comment|description)`: requires `GITHUB_AUTH_TOKEN` or `GITLAB_AUTH_TOKEN` in order to update pull request with links to allure reports
30
+ # Usage
35
31
 
36
32
  ```shell
37
33
  $ (allure-report-publisher|docker run --rm andrcuns/allure-report-publisher:latest) upload --help
@@ -54,6 +50,7 @@ Options:
54
50
  --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description)
55
51
  --[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
56
52
  --[no-]color # Toggle color output, default: false
53
+ --[no-]ignore-missing-results # Ignore missing allure results, default: false
57
54
  --help, -h # Print this help
58
55
 
59
56
  Examples:
@@ -61,11 +58,15 @@ Examples:
61
58
  allure-report-publisher upload gcs --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --prefix=my-project/prs
62
59
  ```
63
60
 
64
- ### AWS S3
61
+ # Storage providers
62
+
63
+ Multiple cloud storage providers are supported
64
+
65
+ ## AWS S3
65
66
 
66
67
  Requires environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` or credentials file `~/.aws/credentials`
67
68
 
68
- ### Google Cloud Storage
69
+ ## Google Cloud Storage
69
70
 
70
71
  Requires on of the following environment variables.
71
72
 
@@ -86,20 +87,77 @@ credentials.json contents:
86
87
  - `GOOGLE_CLOUD_KEYFILE_JSON`
87
88
  - `GCLOUD_KEYFILE_JSON`
88
89
 
89
- ## Development
90
+ # CI
91
+
92
+ `allure-report-publisher` will automatically detect if used in CI environment and add relevant executor info and history.
93
+
94
+ Following CI providers are supported:
95
+
96
+ - Github Actions
97
+ - Gitlab CI
98
+
99
+ ## Pull requests
100
+
101
+ It is possible to update pull requests with urls to published reports.
102
+
103
+ - `--update-pr=(comment|description)`: post report urls in pr description or as a comment
104
+
105
+ Example:
106
+
107
+ ---
108
+
109
+ `# Allure report`
110
+
111
+ `allure-report-publisher` generated test report for [1b756f48](https://github.com/andrcuns/allure-report-publisher/commit/HEAD)!
112
+
113
+ **rspec**: 📝 [test report](https://storage.googleapis.com/allure-test-reports/allure-report-publisher/refs/heads/main/index.html)
114
+
115
+ ---
116
+
117
+ ## Github Actions
118
+
119
+ Additional configuration is done via environment variables
120
+
121
+ Authentication for PR updates:
122
+
123
+ - `GITHUB_AUTH_TOKEN`: github auth token with api access
124
+
125
+ Following environment variables can override default CI values:
126
+
127
+ - `ALLURE_JOB_NAME`: overrides default `GITHUB_JOB` value which is used as name for report url section
128
+
129
+ ## Gitlab CI
130
+
131
+ Additional configuration is done via environment variables
132
+
133
+ Authentication for MR updates:
134
+
135
+ - `GITLAB_AUTH_TOKEN`: gitlab access token with api access
136
+
137
+ Following environment variables can override default CI values:
138
+
139
+ - `ALLURE_JOB_NAME`: overrides default `CI_JOB_NAME` value which is used as name for report url section
140
+
141
+ In case merge request triggers a downstream pipeline yet you want to update original merge request, overriding following environment variables might be useful:
142
+
143
+ - `ALLURE_PROJECT_PATH`: overrides default `CI_PROJECT_PATH` value
144
+ - `ALLURE_MERGE_REQUEST_IID`: overrides default `CI_MERGE_REQUEST_IID` value
145
+ - `ALLURE_COMMIT_SHA`: overrides default `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` or `CI_COMMIT_SHA` values
146
+
147
+ # Development
90
148
 
91
149
  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.
92
150
 
93
151
  To install this gem onto your local machine, run `bundle exec rake install`.
94
152
 
95
- ## Contributing
153
+ # Contributing
96
154
 
97
155
  Bug reports and pull requests are welcome on GitHub at <https://github.com/andrcuns/allure-report-publisher>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/andrcuns/allure-report-publisher/blob/main/CODE_OF_CONDUCT.md).
98
156
 
99
- ## License
157
+ # License
100
158
 
101
159
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
102
160
 
103
- ## Code of Conduct
161
+ # Code of Conduct
104
162
 
105
163
  Everyone interacting in the allure-report-publisher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrcuns/allure-report-publisher/blob/main/CODE_OF_CONDUCT.md).
@@ -31,6 +31,10 @@ module Publisher
31
31
  type: :boolean,
32
32
  default: false,
33
33
  desc: "Toggle color output"
34
+ option :ignore_missing_results,
35
+ type: :boolean,
36
+ default: false,
37
+ desc: "Ignore missing allure results"
34
38
 
35
39
  example [
36
40
  "s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket",
@@ -38,10 +42,11 @@ module Publisher
38
42
  ]
39
43
 
40
44
  def call(**args)
41
- validate_args(args)
42
- validate_result_files(args[:results_glob])
43
45
  Helpers.pastel(force_color: args[:color] || nil)
44
46
 
47
+ validate_args(args)
48
+ validate_result_files(args[:results_glob], args[:ignore_missing_results])
49
+
45
50
  uploader = uploaders(args[:type]).new(**args.slice(:results_glob, :bucket, :prefix, :copy_latest, :update_pr))
46
51
 
47
52
  log("Generating allure report")
@@ -82,8 +87,11 @@ module Publisher
82
87
  #
83
88
  # @param [String] results_glob
84
89
  # @return [void]
85
- def validate_result_files(results_glob)
86
- Dir.glob(results_glob).empty? && error("Glob '#{results_glob}' did not match any files!")
90
+ def validate_result_files(results_glob, ignore)
91
+ return unless Dir.glob(results_glob).empty?
92
+
93
+ log("Glob '#{results_glob}' did not match any files!", ignore ? :yellow : :red)
94
+ exit(ignore ? 0 : 1)
87
95
  end
88
96
  end
89
97
  end
@@ -16,7 +16,7 @@ module Publisher
16
16
  #
17
17
  # @return [Boolean]
18
18
  def pr?
19
- ENV["CI_PIPELINE_SOURCE"] == "merge_request_event"
19
+ (allure_project && allure_mr_iid) || ENV["CI_PIPELINE_SOURCE"] == "merge_request_event"
20
20
  end
21
21
 
22
22
  # Get executor info
@@ -74,59 +74,90 @@ module Publisher
74
74
  # @return [Gitlab::Client]
75
75
  def client
76
76
  @client ||= begin
77
- raise("Missing GITLAB_AUTH_TOKEN environment variable!") unless ENV["GITLAB_AUTH_TOKEN"]
77
+ raise("Missing GITLAB_AUTH_TOKEN environment variable!") unless env("GITLAB_AUTH_TOKEN")
78
78
 
79
79
  ::Gitlab::Client.new(
80
80
  endpoint: "#{server_url}/api/v4",
81
- private_token: ENV["GITLAB_AUTH_TOKEN"]
81
+ private_token: env("GITLAB_AUTH_TOKEN")
82
82
  )
83
83
  end
84
84
  end
85
85
 
86
+ # Custom repository name
87
+ #
88
+ # @return [String]
89
+ def allure_project
90
+ @allure_project ||= env("ALLURE_PROJECT_PATH")
91
+ end
92
+
93
+ # Custom mr iid name
94
+ #
95
+ # @return [String]
96
+ def allure_mr_iid
97
+ @allure_mr_iid ||= env("ALLURE_MERGE_REQUEST_IID")
98
+ end
99
+
100
+ # Custom sha
101
+ #
102
+ # @return [String]
103
+ def allure_sha
104
+ @allure_sha ||= env("ALLURE_COMMIT_SHA")
105
+ end
106
+
107
+ # Gitlab project path
108
+ #
109
+ # @return [String]
110
+ def project
111
+ @project ||= allure_project || env("CI_MERGE_REQUEST_PROJECT_PATH") || env("CI_PROJECT_PATH")
112
+ end
113
+
86
114
  # Merge request iid
87
115
  #
88
116
  # @return [Integer]
89
117
  def mr_iid
90
- @mr_iid ||= ENV["CI_MERGE_REQUEST_IID"]
118
+ @mr_iid ||= allure_mr_iid || env("CI_MERGE_REQUEST_IID")
91
119
  end
92
120
 
93
121
  # Server url
94
122
  #
95
123
  # @return [String]
96
124
  def server_url
97
- @server_url ||= ENV["CI_SERVER_URL"]
125
+ @server_url ||= env("CI_SERVER_URL")
98
126
  end
99
127
 
100
128
  # Build url
101
129
  #
102
130
  # @return [String]
103
131
  def build_url
104
- @build_url ||= ENV["CI_PIPELINE_URL"]
132
+ @build_url ||= env("CI_PIPELINE_URL")
105
133
  end
106
134
 
107
135
  # Job name
108
136
  #
109
137
  # @return [String]
110
138
  def build_name
111
- @build_name ||= ENV[ALLURE_JOB_NAME] || ENV["CI_JOB_NAME"]
112
- end
113
-
114
- # Gitlab repository
115
- #
116
- # @return [String]
117
- def project
118
- @project ||= ENV["CI_PROJECT_PATH"]
139
+ @build_name ||= env(ALLURE_JOB_NAME) || env("CI_JOB_NAME")
119
140
  end
120
141
 
121
142
  # Commit sha url
122
143
  #
123
144
  # @return [String]
124
145
  def sha_url
125
- sha = ENV["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] || ENV["CI_COMMIT_SHA"]
146
+ sha = allure_sha || env("CI_MERGE_REQUEST_SOURCE_BRANCH_SHA") || env("CI_COMMIT_SHA")
126
147
  short_sha = sha[0..7]
127
148
 
128
149
  "[#{short_sha}](#{server_url}/#{project}/-/merge_requests/#{mr_iid}/diffs?commit_id=#{sha})"
129
150
  end
151
+
152
+ # Return non empty environment variable value
153
+ #
154
+ # @param [String] name
155
+ # @return [String, nil]
156
+ def env(name)
157
+ return unless ENV[name] && !ENV[name].empty?
158
+
159
+ ENV[name]
160
+ end
130
161
  end
131
162
  end
132
163
  end
@@ -65,7 +65,7 @@ module Publisher
65
65
  #
66
66
  # @return [String]
67
67
  def heading
68
- @heading ||= "# Allure report\n`allure-report-publisher` generated allure report for #{sha_url}!"
68
+ @heading ||= "# Allure report\n`allure-report-publisher` generated test report for #{sha_url}!"
69
69
  end
70
70
 
71
71
  # Return updated jobs section
@@ -83,14 +83,14 @@ module Publisher
83
83
  #
84
84
  # @return [String]
85
85
  def job_entry
86
- @job_entry ||= "**#{build_name}**: 📝 [allure report](#{report_url})<br />"
86
+ @job_entry ||= "**#{build_name}**: 📝 [test report](#{report_url})<br />"
87
87
  end
88
88
 
89
89
  # Job entry pattern
90
90
  #
91
91
  # @return [RegExp]
92
92
  def job_entry_pattern
93
- @job_entry_pattern ||= %r{^\*\*#{build_name}\*\*:.*\[allure report\]\(.*\)<br />$}
93
+ @job_entry_pattern ||= %r{^\*\*#{build_name}\*\*:.*\[test report\]\(.*\)<br />$}
94
94
  end
95
95
  end
96
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-report-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.93.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.95.0
22
+ version: 1.97.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.93.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.95.0
32
+ version: 1.97.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-cli
35
35
  requirement: !ruby/object:Gem::Requirement