hybrid_platforms_conductor 32.16.4 → 32.17.0

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: 0d7b0039bca37d75c4f4893286370ca04ab72861b2c219b8199531dab80464fc
4
- data.tar.gz: 4189e8181aad10e14ba60d325572ae85932718ff8d21506ad3374e07272b43f9
3
+ metadata.gz: f67bfa1f30b7c9dd212e403b33adf88b7955e8c8d5202cdb7d2ef4f9e35e87e5
4
+ data.tar.gz: e7f7da0c313fdfb841cacd570e030f678343f3a2fb7b3b31daa653c25318efa5
5
5
  SHA512:
6
- metadata.gz: 38bc2f04b0f5c165ad61a3f402a9312b9d7bb596e7c828e19090e9f292c0fde28f6b4d00043e28d0bf840d4c842446d4899197fd379c43fa86bc1a461a5d1adc
7
- data.tar.gz: c2188e0919f5c943905ff7384ab67c242169cd4182cdc61356b1be2c8bb7cc93a9e4fc88a9426fd2cb7a95b16ba9d477fbf253166ec8aa4a716f42fdd1e3e32b
6
+ metadata.gz: 12f526fc089214b09e21220d0a6bcf55083ee3c8b5dff2f23f3764a453de10c6b5a1f0695dc8b567888f903b0130180f56095bb5dff7f44c664dd57b272feabd
7
+ data.tar.gz: 86d6663b9af0159a551eae58c5803dc63099d8119472d137cb0d46ebee25156fd06e92f95dc6ef8fce948f3081cb0c9c3e015ae27dee781ba1d4e4aafa71f3e1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v32.17.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.16.4...v32.17.0) (2021-06-02 12:57:44)
2
+
3
+ ## Global changes
4
+ ### Patches
5
+
6
+ * [[Feature(test_github_ci)] [#61] Add the github_ci test plugin to check for CI/CD of projects on Github](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/a0082efe5c138ca88ca91a3c10f777f47fca5034)
7
+
8
+ ## Changes for test_github_ci
9
+ ### Features
10
+
11
+ * [[Feature(test_github_ci)] [#61] Add the github_ci test plugin to check for CI/CD of projects on Github](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/a0082efe5c138ca88ca91a3c10f777f47fca5034)
12
+
1
13
  # [v32.16.4](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.16.3...v32.16.4) (2021-06-01 13:25:19)
2
14
 
3
15
  ### Patches
data/docs/plugins.md CHANGED
@@ -182,6 +182,7 @@ Plugins shipped by default:
182
182
  * [`executables`](plugins/test/executables.md)
183
183
  * [`file_system_hdfs`](plugins/test/file_system_hdfs.md)
184
184
  * [`file_system`](plugins/test/file_system.md)
185
+ * [`github_ci`](plugins/test/github_ci.md)
185
186
  * [`hostname`](plugins/test/hostname.md)
186
187
  * [`idempotence`](plugins/test/idempotence.md)
187
188
  * [`ip`](plugins/test/ip.md)
@@ -12,7 +12,7 @@ Define a Bitbucket installation to be targeted.
12
12
  It takes the following parameters:
13
13
  * **url** (`String`): URL to the Bitbucket server
14
14
  * **project** (`String`): Project name from the Bitbucket server, storing repositories
15
- * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or :all for all [default: :all]
15
+ * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or `:all` for all [default: `:all`]
16
16
  * **checks** (`Hash<Symbol, Object>`): Checks definition to be perform on those repositories [default: {}]
17
17
  * **branch_permissions** (`Array< Hash<Symbol, Object> >`): List of branch permissions to check [optional]
18
18
  * **type** (`String`): Type of branch permissions to check. Examples of values are 'fast-forward-only', 'no-deletes', 'pull-request-only'.
@@ -0,0 +1,48 @@
1
+ # Test plugin: `github_ci`
2
+
3
+ The `github_ci` test plugin checks that the `master` branch of Github repositories has a successful CI result from its [Github Actions](https://github.com/features/actions).
4
+
5
+ ## Config DSL extension
6
+
7
+ ### `github_repos`
8
+
9
+ Define Github repositories to be targeted.
10
+
11
+ It takes the following parameters:
12
+ * **url** (`String`): URL to the Github API [default: `'https://api.github.com'`]
13
+ * **user** (`String`): User or organization name, storing repositories
14
+ * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or `:all` for all [default: `:all`]
15
+
16
+ Example:
17
+ ```ruby
18
+ github_repos(
19
+ # Github's user containing repositories
20
+ user: 'My-Github-User',
21
+ # List of repositories to check
22
+ repos: [
23
+ 'my-platform-repo',
24
+ 'my-chef-repo',
25
+ 'my-hpc-plugins'
26
+ ]
27
+ )
28
+ ```
29
+
30
+ ## Used credentials
31
+
32
+ | Credential | Usage
33
+ | --- | --- |
34
+ | `github` | Used to connect to the Github API. Password should be the Github API token. |
35
+
36
+ ## Used Metadata
37
+
38
+ | Metadata | Type | Usage
39
+ | --- | --- | --- |
40
+
41
+ ## Used environment variables
42
+
43
+ | Variable | Usage
44
+ | --- | --- |
45
+
46
+ ## External tools dependencies
47
+
48
+ None
@@ -12,7 +12,7 @@ It takes the following parameters:
12
12
  * **url** (`String`): URL to the Bitbucket server
13
13
  * **project** (`String`): Project name from the Bitbucket server, storing repositories
14
14
  * **jenkins_ci_url** (`String` or `nil`): Corresponding Jenkins CI URL, or nil if none.
15
- * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or :all for all [default: :all]
15
+ * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or `:all` for all [default: `:all`]
16
16
 
17
17
  Example:
18
18
  ```ruby
@@ -12,7 +12,7 @@ It takes the following parameters:
12
12
  * **url** (`String`): URL to the Bitbucket server
13
13
  * **project** (`String`): Project name from the Bitbucket server, storing repositories
14
14
  * **jenkins_ci_url** (`String` or `nil`): Corresponding Jenkins CI URL, or nil if none.
15
- * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or :all for all [default: :all]
15
+ * **repos** (`Array<String>` or `Symbol`): List of repository names from this project, or `:all` for all [default: `:all`]
16
16
 
17
17
  Example:
18
18
  ```ruby
@@ -0,0 +1,62 @@
1
+ require 'octokit'
2
+ require 'hybrid_platforms_conductor/credentials'
3
+
4
+ module HybridPlatformsConductor
5
+
6
+ module CommonConfigDsl
7
+
8
+ module Github
9
+
10
+ # Initialize the DSL
11
+ def init_github
12
+ # List of Github repositories definitions
13
+ # Array< Hash<Symbol, Object> >
14
+ # Each definition is just mapping the signature of #github_repos
15
+ @github_repos = []
16
+ end
17
+
18
+ # Register new Github repositories
19
+ #
20
+ # Parameters::
21
+ # * *url* (String): URL to the Github API [default: 'https://api.github.com']
22
+ # * *user* (String): User or organization name, storing repositories
23
+ # * *repos* (Array<String> or Symbol): List of repository names from this project, or :all for all [default: :all]
24
+ def github_repos(url: 'https://api.github.com', user:, repos: :all)
25
+ @github_repos << {
26
+ url: url,
27
+ user: user,
28
+ repos: repos
29
+ }
30
+ end
31
+
32
+ # Iterate over each Github repository
33
+ #
34
+ # Parameters::
35
+ # * Proc: Code called for each Github repository:
36
+ # * Parameters::
37
+ # * *github* (Octokit::Client): The client instance accessing the Github API
38
+ # * *repo_info* (Hash<Symbol, Object>): The repository info:
39
+ # * *name* (String): Repository name.
40
+ # * *slug* (String): Repository slug.
41
+ def for_each_github_repo
42
+ @github_repos.each do |repo_info|
43
+ Octokit.configure do |c|
44
+ c.api_endpoint = repo_info[:url]
45
+ end
46
+ Credentials.with_credentials_for(:github, @logger, @logger_stderr, url: repo_info[:url]) do |_github_user, github_token|
47
+ client = Octokit::Client.new(access_token: github_token)
48
+ (repo_info[:repos] == :all ? client.repositories(repo_info[:user]).map { |repo| repo[:name] } : repo_info[:repos]).each do |name|
49
+ yield client, {
50
+ name: name,
51
+ slug: "#{repo_info[:user]}/#{name}"
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,32 @@
1
+ require 'hybrid_platforms_conductor/common_config_dsl/github'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module Test
8
+
9
+ # Check that all repositories have a successful Github CI
10
+ class GithubCi < HybridPlatformsConductor::Test
11
+
12
+ self.extend_config_dsl_with CommonConfigDsl::Github, :init_github
13
+
14
+ # Check my_test_plugin.rb.sample documentation for signature details.
15
+ def test
16
+ @config.for_each_github_repo do |client, repo_info|
17
+ log_debug "Checking CI for Github repository #{repo_info[:slug]}"
18
+ last_status = client.repository_workflow_runs(repo_info[:slug])[:workflow_runs].
19
+ select { |run| run[:head_branch] == 'master' }.
20
+ sort_by { |run| run[:created_at] }.
21
+ last[:conclusion]
22
+ error "Last workflow status for repository #{repo_info[:slug]} is #{last_status}" unless last_status == 'success'
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '32.16.4'
3
+ VERSION = '32.17.0'
4
4
 
5
5
  end
@@ -0,0 +1,72 @@
1
+ describe HybridPlatformsConductor::TestsRunner do
2
+
3
+ context 'checking test plugins' do
4
+
5
+ context 'checking github_ci' do
6
+
7
+ it 'iterates over defined Github repos' do
8
+ with_repository do |repository|
9
+ platforms = <<~EOS
10
+ github_repos(
11
+ url: 'https://my_gh.my_domain.com',
12
+ user: 'GH-User1',
13
+ repos: [
14
+ 'repo1',
15
+ 'repo2'
16
+ ]
17
+ )
18
+ github_repos(
19
+ user: 'GH-User2',
20
+ repos: [
21
+ 'repo3',
22
+ 'repo4'
23
+ ]
24
+ )
25
+ EOS
26
+ with_platforms platforms do
27
+ repos = []
28
+ test_config.for_each_github_repo do |github, repo_info|
29
+ repos << {
30
+ github_url: github.api_endpoint,
31
+ repo_info: repo_info
32
+ }
33
+ end
34
+ expect(repos).to eq [
35
+ {
36
+ github_url: 'https://my_gh.my_domain.com/',
37
+ repo_info: {
38
+ name: 'repo1',
39
+ slug: 'GH-User1/repo1'
40
+ }
41
+ },
42
+ {
43
+ github_url: 'https://my_gh.my_domain.com/',
44
+ repo_info: {
45
+ name: 'repo2',
46
+ slug: 'GH-User1/repo2'
47
+ }
48
+ },
49
+ {
50
+ github_url: 'https://api.github.com/',
51
+ repo_info: {
52
+ name: 'repo3',
53
+ slug: 'GH-User2/repo3'
54
+ }
55
+ },
56
+ {
57
+ github_url: 'https://api.github.com/',
58
+ repo_info: {
59
+ name: 'repo4',
60
+ slug: 'GH-User2/repo4'
61
+ }
62
+ }
63
+ ]
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 32.16.4
4
+ version: 32.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0.16'
251
+ - !ruby/object:Gem::Dependency
252
+ name: octokit
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '4.21'
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '4.21'
251
265
  - !ruby/object:Gem::Dependency
252
266
  name: rspec
253
267
  requirement: !ruby/object:Gem::Requirement
@@ -345,6 +359,7 @@ extra_rdoc_files:
345
359
  - docs/plugins/provisioner/docker.md
346
360
  - docs/plugins/test/spectre.md
347
361
  - docs/plugins/test/bitbucket_conf.md
362
+ - docs/plugins/test/github_ci.md
348
363
  - docs/plugins/test/vulnerabilities.md
349
364
  - docs/plugins/test/deploy_removes_root_access.md
350
365
  - docs/plugins/test/private_ips.md
@@ -538,6 +553,7 @@ files:
538
553
  - docs/plugins/test/executables.md
539
554
  - docs/plugins/test/file_system.md
540
555
  - docs/plugins/test/file_system_hdfs.md
556
+ - docs/plugins/test/github_ci.md
541
557
  - docs/plugins/test/hostname.md
542
558
  - docs/plugins/test/idempotence.md
543
559
  - docs/plugins/test/ip.md
@@ -640,6 +656,7 @@ files:
640
656
  - lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb
641
657
  - lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb
642
658
  - lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb
659
+ - lib/hybrid_platforms_conductor/common_config_dsl/github.rb
643
660
  - lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb
644
661
  - lib/hybrid_platforms_conductor/config.rb
645
662
  - lib/hybrid_platforms_conductor/confluence.rb
@@ -690,6 +707,7 @@ files:
690
707
  - lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb
691
708
  - lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb
692
709
  - lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb
710
+ - lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb
693
711
  - lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb
694
712
  - lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb
695
713
  - lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb
@@ -819,6 +837,7 @@ files:
819
837
  - spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb
820
838
  - spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb
821
839
  - spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb
840
+ - spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb
822
841
  - spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb
823
842
  - spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb
824
843
  - spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb2.rb