code-engine-tasks 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0afbe9dc72c13a1216b539a9d1c1aa5845b42182bfc57fd701ec2512860d84ff
4
+ data.tar.gz: 0ecda8ab04be69e5e4e7625151cee45eba0e3befcc4406773057d69be4235fa3
5
+ SHA512:
6
+ metadata.gz: 3659ea84d50a033e404d0e2dd8ca0009f09bc947e514f3e5875493027891ee7faf10f60046298f1225ac7a9ecc29b56f76dc6deaa0c1eb91cc5f079b5e073d82
7
+ data.tar.gz: 0a099ae7370c262d147151e7acc13a7a23bcc87b4115e88c3dd6da370b5f68f601f305921beb586536f63001c8a5c5903412e23c5934a2ed6ece477da36fc206
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+ AllCops:
5
+ TargetRubyVersion: 3.2
6
+ NewCops: enable
7
+ Style/StringLiterals:
8
+ Enabled: true
9
+ EnforcedStyle: double_quotes
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+ Layout/LineLength:
14
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rubocop", "~> 1.21"
10
+ gem "rubocop-rake"
11
+ gem "rubocop-rspec"
data/Gemfile.lock ADDED
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ code-engine-tasks (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ parallel (1.22.1)
13
+ parser (3.2.0.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.6.2)
18
+ rexml (3.2.5)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.0)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.3)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ rubocop (1.43.0)
33
+ json (~> 2.3)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.24.1, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.24.1)
43
+ parser (>= 3.1.1.0)
44
+ rubocop-capybara (2.17.1)
45
+ rubocop (~> 1.41)
46
+ rubocop-rake (0.6.0)
47
+ rubocop (~> 1.0)
48
+ rubocop-rspec (2.18.1)
49
+ rubocop (~> 1.33)
50
+ rubocop-capybara (~> 2.17)
51
+ ruby-progressbar (1.11.0)
52
+ unicode-display_width (2.4.2)
53
+
54
+ PLATFORMS
55
+ x86_64-darwin-21
56
+
57
+ DEPENDENCIES
58
+ code-engine-tasks!
59
+ rake (~> 13.0)
60
+ rspec (~> 3.0)
61
+ rubocop (~> 1.21)
62
+ rubocop-rake
63
+ rubocop-rspec
64
+
65
+ BUNDLED WITH
66
+ 2.4.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Steffen Uhlig
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,64 @@
1
+ # CodeEngine Rake Tasks
2
+
3
+ A collection of Rake tasks for working with IBM Cloud Code Engine projects
4
+
5
+ # Installation
6
+
7
+ 1. Add the gem to your project:
8
+
9
+ ```command
10
+ $ bundle add code-engine-tasks
11
+ ```
12
+
13
+ 1. Require the gem in your `Rakefile`:
14
+
15
+ ```ruby
16
+ require 'code_engine/tasks'
17
+ ```
18
+
19
+ # Prerequisites
20
+
21
+ The following envrionment variables need to be set:
22
+
23
+ ```command
24
+ export CE_ACCOUNT=XXXXXXXX1234YYYYYYYY5678ZZZZZZZZ
25
+ export CE_PROJECT=presentations
26
+ export CE_APP=concourse-resource-presentation
27
+ export CE_REGION=eu-de
28
+ ```
29
+
30
+ Optionally, `CE_RESOURCE_GROUP` can be set; it defaults to `default`.
31
+
32
+ How to get these values:
33
+
34
+ * `CE_ACCOUNT` - running `ibmcloud account list` and use the "Account GUID" of the account the project resides in
35
+ * `CE_REGION` - the region where your Code Engine app should run in (use `rake ce:regions` or check [the list](https://cloud.ibm.com/docs/codeengine?topic=codeengine-regions) for possible values)
36
+ * `CE_PROJECT` - the name of your Code Engine project. Find existing ones with `ibmcloud ce project list` or provide the name for a new one, which will be created.
37
+ * `CE_APP` - the name of your Code Engine app. Find existing ones with `ibmcloud ce application list` or provide the name for a new one, which will be created.
38
+
39
+ # Usage
40
+
41
+ > All Rake tasks have documentation; use `rake --tasks` to show it.
42
+
43
+ If the app does not already exist, create a new one with
44
+
45
+ ```command
46
+ $ rake ce:app:create
47
+ ```
48
+
49
+ Subsequent updates of the app can be performed with
50
+
51
+ ```command
52
+ $ rake ce:app:update
53
+ ```
54
+
55
+ The URL of the app can be shown with
56
+
57
+ ```command
58
+ $ rake ce:app:url
59
+ ```
60
+
61
+ # TODO
62
+
63
+ - cli tool to generate a boilerplate project (`ce init --type static-web-app`)
64
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+ RuboCop::RakeTask.new
10
+
11
+ task default: %i[spec rubocop]
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/code_engine/tasks/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "code-engine-tasks"
7
+ spec.version = CodeEngine::Tasks::VERSION
8
+ spec.authors = ["Steffen Uhlig"]
9
+ spec.email = ["Steffen.Uhlig@de.ibm.com"]
10
+
11
+ spec.summary = "Rake tasks for working with IBM Cloud Code Engine"
12
+ spec.description = "A collection of Rake tasks for working with IBM Cloud Code Engine projects."
13
+ spec.homepage = "https://github.com/suhlig/code-engine-tasks"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ spec.metadata["rubygems_mfa_required"] = "true"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CodeEngine
4
+ module Tasks
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "tasks/version"
4
+
5
+ module CodeEngine
6
+ # Rake tasks
7
+ module Tasks
8
+ end
9
+ end
10
+
11
+ CE_ACCOUNT = ENV.fetch("CE_ACCOUNT")
12
+ CE_REGION = ENV.fetch("CE_REGION")
13
+ CE_PROJECT = ENV.fetch("CE_PROJECT")
14
+ CE_APP = ENV.fetch("CE_APP")
15
+ CE_RESOURCE_GROUP = ENV.fetch("CE_RESOURCE_GROUP", "default")
16
+
17
+ namespace :ce do
18
+ namespace :account do
19
+ desc "Target IBM Cloud account '#{CE_ACCOUNT}'"
20
+ task :target do
21
+ sh "ibmcloud target -g #{CE_RESOURCE_GROUP} -r #{CE_REGION} -c #{CE_ACCOUNT}"
22
+ end
23
+ end
24
+
25
+ desc "List regions where CE is available"
26
+ task :regions do
27
+ sh <<~HEREDOC.tr("\n", "").squeeze(" ").strip
28
+ ibmcloud catalog service codeengine --output json
29
+ | jq --raw-output
30
+ ' .[]
31
+ | select(.name == "codeengine")
32
+ | .children
33
+ | select(.[].kind == "plan")
34
+ | .[].children
35
+ | select(.[].kind == "deployment")
36
+ | .[].metadata.deployment.location'
37
+ | sort -u
38
+ HEREDOC
39
+ end
40
+
41
+ namespace :project do
42
+ desc "Create CE project '#{CE_PROJECT}'"
43
+ task :create do
44
+ sh "ibmcloud ce project create --name #{CE_PROJECT}"
45
+ end
46
+
47
+ desc "Fail if CE project '#{CE_PROJECT}' does not exist"
48
+ task exists: %i[account:target] do
49
+ sh "ibmcloud ce project get --name #{CE_PROJECT}", %i[out err] => "/dev/null"
50
+ rescue StandardError
51
+ abort "Error: The check for CE project #{CE_PROJECT} failed. You can create it with `rake ce:project:create`."
52
+ end
53
+ end
54
+
55
+ namespace :app do
56
+ desc "Create CE app '#{CE_APP}' in project '#{CE_PROJECT}'"
57
+ task create: %i[project:exists] do
58
+ sh "ibmcloud ce project target --name #{CE_PROJECT}"
59
+ sh "ibmcloud ce application create --name #{CE_APP} --build-source ."
60
+ end
61
+
62
+ desc "Show URL of CE app '#{CE_APP}' in project '#{CE_PROJECT}'"
63
+ task url: %i[app:exists] do
64
+ sh "ibmcloud ce application get --name #{CE_APP} -o json | jq --raw-output .status.url"
65
+ end
66
+
67
+ desc "Fail if CE app '#{CE_APP}' does not exist"
68
+ task exists: %i[project:exists] do
69
+ sh "ibmcloud ce application get --name #{CE_APP}", %i[out err] => "/dev/null"
70
+ rescue StandardError
71
+ abort "Error: The check for CE app '#{CE_APP}' failed. You can create it with `rake ce:app:create`."
72
+ end
73
+
74
+ desc "Update CE app '#{CE_APP}'"
75
+ task update: %i[app:exists] do
76
+ sh "ibmcloud ce application update --name #{CE_APP} --build-source ."
77
+ end
78
+ end
79
+ end
80
+
81
+ at_exit do
82
+ warn "\nCheck the messages above for errors.\n" if $! && !$!.success?
83
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code-engine-tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Steffen Uhlig
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A collection of Rake tasks for working with IBM Cloud Code Engine projects.
14
+ email:
15
+ - Steffen.Uhlig@de.ibm.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".rubocop.yml"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.markdown
26
+ - Rakefile
27
+ - code-engine-tasks.gemspec
28
+ - lib/code_engine/tasks.rb
29
+ - lib/code_engine/tasks/version.rb
30
+ homepage: https://github.com/suhlig/code-engine-tasks
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ homepage_uri: https://github.com/suhlig/code-engine-tasks
35
+ source_code_uri: https://github.com/suhlig/code-engine-tasks
36
+ rubygems_mfa_required: 'true'
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.4.1
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Rake tasks for working with IBM Cloud Code Engine
56
+ test_files: []