ci_toolkit 1.3.17 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +13 -0
- data/.devcontainer/base.Dockerfile +43 -0
- data/.devcontainer/devcontainer.json +35 -0
- data/.vscode/settings.json +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/ci_toolkit/github_bot.rb +62 -0
- data/lib/ci_toolkit/github_pr.rb +2 -2
- data/lib/ci_toolkit.rb +1 -1
- metadata +6 -2
- data/lib/ci_toolkit/github_access.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c3a2dc78e17b33a1f5cec89d973abd60bc9c972ec8d5d99c7547fd1ec0591f1
|
4
|
+
data.tar.gz: 1ac3f0583f2e9acb470dde9ecc5154003350c444a9e86e5a113722df38cfdc50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37dfe3cb4c7f72b0489f0dbdc792ba6f7b5cc79af67b45d8b3256c1ed83dbef1cb3eb7597304015738e33cb80ee5a1138a501d46872640a7013088c5c6c04320
|
7
|
+
data.tar.gz: 7e6cd2c35898d510f419c6b915d29fdf0a6fcfd252b6bd34dd3d17f74dc411241a7547a839c809b9c8d1d2a1a8c20dbbe0dbc757b3aeff85a5a75a6b8254e3be
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
|
2
|
+
ARG VARIANT=2-bullseye
|
3
|
+
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
|
4
|
+
|
5
|
+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
|
6
|
+
ARG NODE_VERSION="none"
|
7
|
+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
8
|
+
|
9
|
+
# [Optional] Uncomment this line to install additional gems.
|
10
|
+
RUN gem install bundler
|
11
|
+
|
12
|
+
# [Optional] Uncomment this line to install global node packages.
|
13
|
+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
|
2
|
+
ARG VARIANT=2-bullseye
|
3
|
+
FROM ruby:${VARIANT}
|
4
|
+
|
5
|
+
# Copy library scripts to execute
|
6
|
+
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
|
7
|
+
|
8
|
+
# [Option] Install zsh
|
9
|
+
ARG INSTALL_ZSH="true"
|
10
|
+
# [Option] Upgrade OS packages to their latest versions
|
11
|
+
ARG UPGRADE_PACKAGES="true"
|
12
|
+
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
13
|
+
ARG USERNAME=vscode
|
14
|
+
ARG USER_UID=1000
|
15
|
+
ARG USER_GID=$USER_UID
|
16
|
+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
17
|
+
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
18
|
+
&& apt-get purge -y imagemagick imagemagick-6-common \
|
19
|
+
# Install common packages, non-root user, rvm, core build tools
|
20
|
+
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
|
21
|
+
&& bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
|
22
|
+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
23
|
+
|
24
|
+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
|
25
|
+
ARG NODE_VERSION="none"
|
26
|
+
ENV NVM_DIR=/usr/local/share/nvm
|
27
|
+
ENV NVM_SYMLINK_CURRENT=true \
|
28
|
+
PATH=${NVM_DIR}/current/bin:${PATH}
|
29
|
+
RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
|
30
|
+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
31
|
+
|
32
|
+
# Remove library scripts for final image
|
33
|
+
RUN rm -rf /tmp/library-scripts
|
34
|
+
|
35
|
+
# [Optional] Uncomment this section to install additional OS packages.
|
36
|
+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
37
|
+
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
38
|
+
|
39
|
+
# [Optional] Uncomment this line to install additional gems.
|
40
|
+
# RUN gem install <your-gem-names-here>
|
41
|
+
|
42
|
+
# [Optional] Uncomment this line to install global node packages.
|
43
|
+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
2
|
+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/ruby
|
3
|
+
{
|
4
|
+
"name": "Ruby",
|
5
|
+
"runArgs": ["--init"],
|
6
|
+
"build": {
|
7
|
+
"dockerfile": "Dockerfile",
|
8
|
+
"args": {
|
9
|
+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
|
10
|
+
// Append -bullseye or -buster to pin to an OS version.
|
11
|
+
// Use -bullseye variants on local on arm64/Apple Silicon.
|
12
|
+
"VARIANT": "3-bullseye",
|
13
|
+
// Options
|
14
|
+
"NODE_VERSION": "none"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
|
18
|
+
// Set *default* container specific settings.json values on container create.
|
19
|
+
"settings": {},
|
20
|
+
|
21
|
+
// Add the IDs of extensions you want installed when the container is created.
|
22
|
+
"extensions": [
|
23
|
+
"rebornix.Ruby"
|
24
|
+
],
|
25
|
+
|
26
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
27
|
+
// "forwardPorts": [],
|
28
|
+
|
29
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
30
|
+
"postCreateCommand": "bundle install",
|
31
|
+
|
32
|
+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
33
|
+
"remoteUser": "vscode"
|
34
|
+
|
35
|
+
}
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec/test/test-unit` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
23
23
|
|
24
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version
|
24
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version in `ci_toolkit.gemspec`, 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).
|
25
25
|
|
26
26
|
## Contributing
|
27
27
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "octokit"
|
4
|
+
require "jwt"
|
5
|
+
|
6
|
+
module CiToolkit
|
7
|
+
# Utility class that provides an access token that can be used with the Github API
|
8
|
+
class GithubBot
|
9
|
+
# Provides a jwt token for authentication. Sores the private key and app id for the bot
|
10
|
+
class Credentials
|
11
|
+
attr_reader :app_id
|
12
|
+
|
13
|
+
def initialize(app_id = ENV["CRVSH_BOT_GITHUB_APP_ID"], private_key = ENV["CRVSH_BOT_GITHUB_APP_PRIVATE_KEY"])
|
14
|
+
@app_id = app_id.to_i
|
15
|
+
@private_key = private_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def jwt_token
|
19
|
+
JWT.encode(
|
20
|
+
{
|
21
|
+
iat: Time.now.to_i,
|
22
|
+
exp: Time.now.to_i + (9 * 60),
|
23
|
+
iss: @app_id
|
24
|
+
},
|
25
|
+
OpenSSL::PKey::RSA.new(@private_key),
|
26
|
+
"RS256"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
# stack = Faraday::RackBuilder.new do |builder|
|
31
|
+
# builder.response :logger
|
32
|
+
# builder.use Octokit::Response::RaiseError
|
33
|
+
# builder.adapter Faraday.default_adapter
|
34
|
+
# end
|
35
|
+
# Octokit.middleware = stack
|
36
|
+
|
37
|
+
def initialize(
|
38
|
+
credentials = CiToolkit::GithubBot::Credentials.new,
|
39
|
+
client = Octokit::Client.new(bearer_token: credentials.jwt_token, auto_paginate: true)
|
40
|
+
)
|
41
|
+
@app_id = credentials.app_id
|
42
|
+
@client = client
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_token
|
46
|
+
return unless (installation_id = find_app_installation)
|
47
|
+
|
48
|
+
@client.create_app_installation_access_token(
|
49
|
+
installation_id,
|
50
|
+
{ accept: Octokit::Preview::PREVIEW_TYPES[:integrations] }
|
51
|
+
)[:token]
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def find_app_installation
|
57
|
+
@client.find_app_installations(
|
58
|
+
{ accept: Octokit::Preview::PREVIEW_TYPES[:integrations] }
|
59
|
+
).select { |installation| @app_id.equal?(installation[:app_id]) }.first[:id]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/ci_toolkit/github_pr.rb
CHANGED
@@ -16,7 +16,7 @@ module CiToolkit
|
|
16
16
|
@commit_sha = env.git_commit
|
17
17
|
@_client = client
|
18
18
|
@build_types = build_types
|
19
|
-
@
|
19
|
+
@bot = CiToolkit::GithubBot.new
|
20
20
|
end
|
21
21
|
|
22
22
|
def title
|
@@ -110,7 +110,7 @@ module CiToolkit
|
|
110
110
|
|
111
111
|
def client
|
112
112
|
@_client = Octokit::Client.new if @_client.nil?
|
113
|
-
@_client.access_token = @
|
113
|
+
@_client.access_token = @bot.create_token if @_client.access_token.nil?
|
114
114
|
|
115
115
|
@_client
|
116
116
|
end
|
data/lib/ci_toolkit.rb
CHANGED
@@ -4,7 +4,7 @@ require "ci_toolkit/bitrise_env"
|
|
4
4
|
require "ci_toolkit/build"
|
5
5
|
require "ci_toolkit/build_status"
|
6
6
|
require "ci_toolkit/duplicate_files_finder"
|
7
|
-
require "ci_toolkit/
|
7
|
+
require "ci_toolkit/github_bot"
|
8
8
|
require "ci_toolkit/github_pr"
|
9
9
|
require "ci_toolkit/git"
|
10
10
|
require "ci_toolkit/jira"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gero Keller
|
@@ -186,8 +186,12 @@ executables: []
|
|
186
186
|
extensions: []
|
187
187
|
extra_rdoc_files: []
|
188
188
|
files:
|
189
|
+
- ".devcontainer/Dockerfile"
|
190
|
+
- ".devcontainer/base.Dockerfile"
|
191
|
+
- ".devcontainer/devcontainer.json"
|
189
192
|
- ".rspec"
|
190
193
|
- ".rubocop.yml"
|
194
|
+
- ".vscode/settings.json"
|
191
195
|
- CHANGELOG.md
|
192
196
|
- CODE_OF_CONDUCT.md
|
193
197
|
- Gemfile
|
@@ -205,7 +209,7 @@ files:
|
|
205
209
|
- lib/ci_toolkit/build_status.rb
|
206
210
|
- lib/ci_toolkit/duplicate_files_finder.rb
|
207
211
|
- lib/ci_toolkit/git.rb
|
208
|
-
- lib/ci_toolkit/
|
212
|
+
- lib/ci_toolkit/github_bot.rb
|
209
213
|
- lib/ci_toolkit/github_pr.rb
|
210
214
|
- lib/ci_toolkit/jira.rb
|
211
215
|
- lib/ci_toolkit/pr_messenger.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "octokit"
|
4
|
-
require "jwt"
|
5
|
-
|
6
|
-
module CiToolkit
|
7
|
-
# Utility class that provides an access token that can be used with the Github API
|
8
|
-
class GithubAccess
|
9
|
-
# stack = Faraday::RackBuilder.new do |builder|
|
10
|
-
# builder.response :logger
|
11
|
-
# builder.use Octokit::Response::RaiseError
|
12
|
-
# builder.adapter Faraday.default_adapter
|
13
|
-
# end
|
14
|
-
# Octokit.middleware = stack
|
15
|
-
|
16
|
-
def initialize(app_id = ENV["CRVSH_BOT_GITHUB_APP_ID"], private_key = ENV["CRVSH_BOT_GITHUB_APP_PRIVATE_KEY"])
|
17
|
-
@app_id = app_id.to_i
|
18
|
-
@private_key = private_key
|
19
|
-
@client = Octokit::Client.new(bearer_token: jwt_token, auto_paginate: true)
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_token
|
23
|
-
return unless (installation_id = find_app_installation)
|
24
|
-
|
25
|
-
@client.create_app_installation_access_token(
|
26
|
-
installation_id,
|
27
|
-
{ accept: Octokit::Preview::PREVIEW_TYPES[:integrations] }
|
28
|
-
)[:token]
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def find_app_installation
|
34
|
-
@client.find_app_installations(
|
35
|
-
{ accept: Octokit::Preview::PREVIEW_TYPES[:integrations] }
|
36
|
-
).select { |installation| installation[:app_id] == @app_id }.first[:id]
|
37
|
-
end
|
38
|
-
|
39
|
-
def jwt_token
|
40
|
-
JWT.encode(
|
41
|
-
{
|
42
|
-
iat: Time.now.to_i,
|
43
|
-
exp: Time.now.to_i + (9 * 60),
|
44
|
-
iss: @app_id
|
45
|
-
},
|
46
|
-
OpenSSL::PKey::RSA.new(@private_key),
|
47
|
-
"RS256"
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|