drone-ci 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 32b1b7687a34f96c1f5fb7d9874e812d863a6908d4a71c0fe8ba9f7caf43be87
4
+ data.tar.gz: 968b4778d5e9bbf0313c9d4cffe0065ef6bff6df0e6fd5f868424942e2002429
5
+ SHA512:
6
+ metadata.gz: e2724927033b7b82438f18dcdf80577a07be0aad50f72ba6f0ff0b1c1d62f91e3b215e8337a119b88d284442c614d5ae10fa3b8e266d149c4c667ba259d13718
7
+ data.tar.gz: 2323cdc13b445b43b510dd3538bced63c77487606b6057b77ec3bb400860f213d77b9d6ad6dfa70f7540c62ceb4dbca19a06478798b643464eb41814047cf857
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "master" ]
20
+ schedule:
21
+ - cron: '35 6 * * 3'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,50 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write
14
+ packages: write
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Set up Ruby 2.6
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6.x
22
+
23
+ - name: Publish to GPR
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
31
+ env:
32
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
33
+ OWNER: ${{ github.repository_owner }}
34
+ - name: Publish to Release Assets
35
+ uses: softprops/action-gh-release@v1
36
+ if: startsWith(github.ref, 'refs/tags/')
37
+ with:
38
+ files: |
39
+ *.gem
40
+ LICENSE.txt
41
+ # - name: Publish to RubyGems
42
+ # run: |
43
+ # mkdir -p $HOME/.gem
44
+ # touch $HOME/.gem/credentials
45
+ # chmod 0600 $HOME/.gem/credentials
46
+ # printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
47
+ # gem build *.gemspec
48
+ # gem push *.gem
49
+ # env:
50
+ # GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .bundle
2
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ AllCops:
3
+ NewCops: enable
4
+
5
+ Lint/Debugger:
6
+ Exclude:
7
+ - bin/drone-ci
8
+
9
+ Naming/FileName:
10
+ Exclude:
11
+ - lib/drone-ci.rb
12
+
13
+ Style/AccessorGrouping:
14
+ EnforcedStyle: separated
15
+
16
+ Gemspec/DuplicatedAssignment:
17
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source ENV.fetch('RUBYGEMS_MIRROR', 'https://rubygems.org')
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+ Copyright © 2022 Chris Olstrom <chris@olstrom.com>
4
+ Copyright © 2022 SUSE LLC
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the “Software”), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # drone-ci - A Ruby Interface to the Drone CI API
2
+
3
+ ## Overview
4
+
5
+ `drone-ci` is a Ruby Gem that provides a client for Drone CI servers.
6
+
7
+ ## Why does this exist?
8
+
9
+ Because I couldn't find one that existed. There's Go and JavaScript libraries, but Ruby deserves some love too.
10
+
11
+ ## How do I obtain this majestic tool?
12
+
13
+ If you're using `bundler`, add the following to your `Gemfile`:
14
+
15
+ ```ruby
16
+ gem 'drone-ci', '~> 0.1'
17
+ ```
18
+
19
+ Otherwise, install it the usual way:
20
+
21
+ ```shell
22
+ gem install drone-ci
23
+ ```
24
+
25
+ ## How do I use it?
26
+
27
+ `drone-ci` is primarily intended as a library, so you'll probably want to use it that way.
28
+
29
+ ```ruby
30
+ #! /usr/bin/env ruby
31
+
32
+ require 'drone-ci'
33
+ require 'json'
34
+
35
+ drone = DroneCI::Client.new(server: "https://drone-server-goes-here", token: "access token goes here")
36
+ STDOUT.puts JSON.pretty_generate drone.user_info.body
37
+ ```
38
+
39
+ Which would output something this this:
40
+
41
+ ```json
42
+ {
43
+ "id": 191,
44
+ "login": "colstrom",
45
+ "email": "chris@olstrom.com",
46
+ "machine": false,
47
+ "admin": true,
48
+ "active": true,
49
+ "avatar": "https://avatars.githubusercontent.com/u/469456?v=4",
50
+ "syncing": false,
51
+ "synced": 1662068210,
52
+ "created": 1659728463,
53
+ "updated": 1659728463,
54
+ "last_login": 1660781210
55
+ }
56
+ ```
57
+
58
+ If you don't pass in a server or a token, `drone-ci` will read `DRONE_SERVER` and `DRONE_TOKEN` from the environment. These are the same environment variables used by the Drone CLI.
59
+
60
+ ### Exploration Mode
61
+
62
+ If you simply run the `drone-ci` command (installed with the gem), it will drop you into an interactive session where you can explore the API of your Drone server.
63
+
64
+ ## License
65
+
66
+ `drone-ci` is available under the [MIT License](https://tldrlegal.com/license/mit-license). See `LICENSE.txt` for the full text.
data/bin/drone-ci ADDED
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup' if ENV['HACKING']
5
+ require 'irb'
6
+ require 'irb/completion'
7
+
8
+ require_relative '../lib/drone-ci'
9
+
10
+ drone = DroneCI::Client.new
11
+
12
+ binding.irb
data/drone-ci.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'drone-ci'
5
+ gem.homepage = 'https://github.com/colstrom/drone-ci'
6
+ gem.summary = 'Ruby Interface to the Drone CI API'
7
+
8
+ gem.licenses = ['MIT']
9
+ gem.authors = ['Chris Olstrom']
10
+ gem.email = 'chris@olstrom.com'
11
+
12
+ # gem.cert_chain = ['trust/certificates/colstrom.pem']
13
+ # gem.signing_key = File.expand_path ENV.fetch 'GEM_SIGNING_KEY'
14
+
15
+ if ENV['HACKING']
16
+ gem.version = '0.0.0-pre'
17
+ gem.files = Dir.glob('**')
18
+ gem.executables = Dir.glob('bin/*')
19
+ else
20
+ gem.required_ruby_version = '>= 3.0.0'
21
+ gem.version = `git describe --tags --always`.chomp
22
+ gem.files = `git ls-files -z`.split("\x0")
23
+ gem.executables = `git ls-files -z -- bin/*`.split("\x0").map { |f| File.basename(f) }
24
+ end
25
+
26
+ gem.require_paths = ['lib']
27
+
28
+ gem.add_runtime_dependency 'faraday', '~> 2.5', '>= 2.5.2'
29
+ gem.add_runtime_dependency 'faraday-retry', '~> 2.0'
30
+ gem.add_runtime_dependency 'httpx', '~> 0.21.0'
31
+ gem.add_runtime_dependency 'octokit', '~> 5.4'
32
+
33
+ gem.add_development_dependency 'pry', '~> 0.14.1'
34
+ gem.add_development_dependency 'pry-doc', '~> 1.3'
35
+ gem.add_development_dependency 'rubocop', '~> 1.35'
36
+ gem.add_development_dependency 'solargraph', '~> 0.45.0'
37
+ gem.add_development_dependency 'yard', '~> 0.9.28'
38
+ gem.metadata['rubygems_mfa_required'] = 'true'
39
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module BuildsAPI
5
+ # https://docs.drone.io/api/builds/build_approve/
6
+ def build_approve(owner, repo, build)
7
+ api.post("repos/#{owner}/#{repo}/builds/#{build}/approve")
8
+ end
9
+
10
+ # https://docs.drone.io/api/builds/build_create/
11
+ def build_create(namespace, name, branch: nil, commit: nil, **params)
12
+ api.post("repos/#{namespace}/#{name}/builds") do |request|
13
+ { branch: branch, commit: commit }.merge(params).compact.transform_keys(&:to_s).each do |key, value|
14
+ request.params[key] = value
15
+ end
16
+ end
17
+ end
18
+
19
+ # https://docs.drone.io/api/builds/build_decline/
20
+ def build_decline(owner, repo, build)
21
+ api.post("repos/#{owner}/#{repo}/builds/#{build}/decline")
22
+ end
23
+
24
+ # https://docs.drone.io/api/builds/build_info/
25
+ def build_info(owner, repo, build)
26
+ api.get("repos/#{owner}/#{repo}/builds/#{build}")
27
+ end
28
+
29
+ # https://docs.drone.io/api/builds/build_list/
30
+ def build_list(owner, repo)
31
+ api.get("repos/#{owner}/#{repo}/builds")
32
+ end
33
+
34
+ # https://docs.drone.io/api/builds/build_logs/
35
+ def build_logs(owner, repo, build, stage, step)
36
+ api.get("repos/#{owner}/#{repo}/builds/#{build}/logs/#{stage}/#{step}")
37
+ end
38
+
39
+ # https://docs.drone.io/api/builds/build_promote/
40
+ def build_promote(owner, repo, build, target:, **params)
41
+ api.post("repos/#{owner}/#{repo}/builds/#{build}") do |request|
42
+ { target: target }.merge(params).compact.transform_keys(&:to_s).each do |key, value|
43
+ request.params[key] = value
44
+ end
45
+ end
46
+ end
47
+
48
+ # https://docs.drone.io/api/builds/build_start/
49
+ def build_start(owner, repo, build)
50
+ api.post("repos/#{owner}/#{repo}/builds/#{build}")
51
+ end
52
+
53
+ alias build_restart build_start
54
+
55
+ # https://docs.drone.io/api/builds/build_stop/
56
+ def build_stop(owner, repo, build)
57
+ api.delete("repos/#{owner}/#{repo}/builds/#{build}")
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module CronAPI
5
+ # https://docs.drone.io/api/cron/cron_create/
6
+ def cron_create(owner, repo, **body)
7
+ api.post("repos/#{owner}/#{repo}/cron", body)
8
+ end
9
+
10
+ # https://docs.drone.io/api/cron/cron_delete/
11
+ def cron_delete(owner, repo, name)
12
+ api.delete("repos/#{owner}/#{repo}/cron/#{name}")
13
+ end
14
+
15
+ # https://docs.drone.io/api/cron/cron_info/
16
+ def cron_info(owner, repo, name)
17
+ api.get("repos/#{owner}/#{repo}/cron/#{name}")
18
+ end
19
+
20
+ # https://docs.drone.io/api/cron/cron_list/
21
+ def cron_list(owner, repo)
22
+ api.get("repos/#{owner}/#{repo}/cron")
23
+ end
24
+
25
+ # https://docs.drone.io/api/cron/cron_trigger/
26
+ def cron_trigger(owner, repo, name)
27
+ api.post("repos/#{owner}/#{repo}/cron/#{name}")
28
+ end
29
+
30
+ # https://docs.drone.io/api/cron/cron_update/
31
+ def cron_update(owner, repo, name, **body)
32
+ api.patch("repos/#{owner}/#{repo}/cron/#{name}", body)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module ReposAPI
5
+ # https://docs.drone.io/api/repos/repo_chown/
6
+ def repo_chown(owner, repo)
7
+ api.post("repos/#{owner}/#{repo}/chown")
8
+ end
9
+
10
+ # https://docs.drone.io/api/repos/repo_delete/
11
+ def repo_delete(owner, repo)
12
+ api.delete("repos/#{owner}/#{repo}")
13
+ end
14
+
15
+ alias repo_disable repo_delete
16
+
17
+ # https://docs.drone.io/api/repos/repo_create/
18
+ def repo_create(owner, _name)
19
+ api.post("repos/#{owner}/#{repo}")
20
+ end
21
+
22
+ alias repo_enable repo_create
23
+
24
+ # https://docs.drone.io/api/repos/repo_info/
25
+ def repo_info(owner, repo)
26
+ api.get("repos/#{owner}/#{repo}")
27
+ end
28
+
29
+ # https://docs.drone.io/api/repos/repo_list/
30
+ # the docs are wrong, they say this is at api/user/repos, but the source code says...
31
+ # https://github.com/harness/drone/blob/2d45d90cdd5cf2ec0e8dbcce2ea6bc340ce1e67e/handler/api/api.go#L173-L182
32
+ def repo_list(_owner)
33
+ api.get('repos')
34
+ end
35
+
36
+ # https://docs.drone.io/api/repos/repo_repair/
37
+ def repo_repair(owner, repo)
38
+ api.post("repos/#{owner}/#{repo}/repair")
39
+ end
40
+
41
+ # https://docs.drone.io/api/repos/repo_update/
42
+ def repo_update(owner, repo, **body)
43
+ api.patch("repos/#{owner}/#{repo}", body)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module SecretsAPI
5
+ # https://docs.drone.io/api/secrets/secret_create/
6
+ def secret_create(owner, repo, **body)
7
+ api.post("repos/#{owner}/#{repo}/secrets", body)
8
+ end
9
+
10
+ # https://docs.drone.io/api/secrets/secret_delete/
11
+ def secret_delete(owner, repo, secret)
12
+ api.post("repos/#{owner}/#{repo}/secrets/#{secret}")
13
+ end
14
+
15
+ # https://docs.drone.io/api/secrets/secret_info/
16
+ def secret_info(owner, repo, secret)
17
+ api.get("repos/#{owner}/#{repo}/secrets/#{secret}")
18
+ end
19
+
20
+ # https://docs.drone.io/api/secrets/secret_list/
21
+ def secret_list(owner, repo)
22
+ api.get("repos/#{owner}/#{repo}/secrets")
23
+ end
24
+
25
+ # https://docs.drone.io/api/secrets/secret_update/
26
+ def secret_update(owner, repo, secret, **body)
27
+ api.patch("repos/#{owner}/#{repo}/secrets/#{secret}", body)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module TemplatesAPI
5
+ # https://docs.drone.io/api/templates/template_create/
6
+ def template_create(namespace, **body)
7
+ api.post("templates/#{namespace}", body)
8
+ end
9
+
10
+ # https://docs.drone.io/api/templates/template_delete/
11
+ def template_delete(namespace, name)
12
+ api.delete("templates/#{namespace}/#{name}")
13
+ end
14
+
15
+ # https://docs.drone.io/api/templates/template_info/
16
+ def template_info(namespace, name)
17
+ api.get("templates/#{namespace}/#{name}")
18
+ end
19
+
20
+ # https://docs.drone.io/api/templates/template_list/
21
+ def template_list(namespace)
22
+ api.get("templates/#{namespace}")
23
+ end
24
+
25
+ # https://docs.drone.io/api/templates/template_update/
26
+ def template_update(namespace, name, **body)
27
+ api.patch("templates/#{namespace}/#{name}", body)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module UserAPI
5
+ # https://docs.drone.io/api/user/user_builds/
6
+ def user_builds
7
+ api.get('user/builds')
8
+ end
9
+
10
+ # https://docs.drone.io/api/user/user_info/
11
+ def user_info
12
+ api.get('user')
13
+ end
14
+
15
+ # https://docs.drone.io/api/user/user_repos/
16
+ def user_repos(latest: nil)
17
+ api.get('user/repos') do |request|
18
+ { latest: latest }.compact.each do |key, value|
19
+ request.params[key] = value
20
+ end
21
+ end
22
+ end
23
+
24
+ # https://docs.drone.io/api/user/user_sync/
25
+ def user_sync
26
+ api.post('user/repos')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DroneCI
4
+ module UsersAPI
5
+ # https://docs.drone.io/api/users/users_create/
6
+ def users_create(**body)
7
+ api.post('users', body)
8
+ end
9
+
10
+ # https://docs.drone.io/api/users/users_delete/
11
+ def users_delete(login)
12
+ api.delete("users/#{login}")
13
+ end
14
+
15
+ # https://docs.drone.io/api/users/users_info/
16
+ def users_info(login)
17
+ api.get("users/#{login}")
18
+ end
19
+
20
+ # https://docs.drone.io/api/users/users_list/
21
+ def users_list
22
+ api.get('users')
23
+ end
24
+
25
+ # https://docs.drone.io/api/users/users_update/
26
+ def users_update(login, **body)
27
+ api.patch("users/#{login}", body)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api/builds'
4
+ require_relative 'api/cron'
5
+ require_relative 'api/repos'
6
+ require_relative 'api/secrets'
7
+ require_relative 'api/templates'
8
+ require_relative 'api/user'
9
+ require_relative 'api/users'
10
+
11
+ module DroneCI
12
+ module API
13
+ include BuildsAPI
14
+ include CronAPI
15
+ include ReposAPI
16
+ include SecretsAPI
17
+ include TemplatesAPI
18
+ include UserAPI
19
+ include UsersAPI
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httpx/adapters/faraday'
4
+ require 'faraday'
5
+ require 'faraday/retry'
6
+
7
+ require_relative 'api'
8
+
9
+ module DroneCI
10
+ class Client
11
+ include API
12
+
13
+ def initialize(**options)
14
+ @api = options.fetch(:client) do
15
+ server = options.fetch(:server) { ENV.fetch('DRONE_SERVER') }
16
+ token = options.fetch(:token) { ENV.fetch('DRONE_TOKEN') }
17
+ Faraday.new(server) do |client|
18
+ client.adapter :httpx
19
+ client.headers = {
20
+ 'Authorization' => "Bearer #{token}"
21
+ }.merge(options.fetch(:headers, {}))
22
+ client.path_prefix = '/api'
23
+ client.request :json
24
+ client.request :retry
25
+ client.response :json
26
+ yield client if block_given?
27
+ end
28
+ end
29
+ end
30
+
31
+ attr_reader :api
32
+ end
33
+ end
data/lib/drone-ci.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'drone-ci/api'
4
+ require_relative 'drone-ci/client'
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drone-ci
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Olstrom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.5'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.5.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.5'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.5.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday-retry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: httpx
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.21.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.21.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: octokit
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '5.4'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.4'
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.14.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.14.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: pry-doc
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.3'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.3'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.35'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.35'
117
+ - !ruby/object:Gem::Dependency
118
+ name: solargraph
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 0.45.0
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.45.0
131
+ - !ruby/object:Gem::Dependency
132
+ name: yard
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.9.28
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 0.9.28
145
+ description:
146
+ email: chris@olstrom.com
147
+ executables:
148
+ - drone-ci
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - ".github/dependabot.yml"
153
+ - ".github/workflows/codeql-analysis.yml"
154
+ - ".github/workflows/gem-push.yml"
155
+ - ".gitignore"
156
+ - ".rubocop.yml"
157
+ - Gemfile
158
+ - LICENSE.txt
159
+ - README.md
160
+ - bin/drone-ci
161
+ - drone-ci.gemspec
162
+ - lib/drone-ci.rb
163
+ - lib/drone-ci/api.rb
164
+ - lib/drone-ci/api/builds.rb
165
+ - lib/drone-ci/api/cron.rb
166
+ - lib/drone-ci/api/repos.rb
167
+ - lib/drone-ci/api/secrets.rb
168
+ - lib/drone-ci/api/templates.rb
169
+ - lib/drone-ci/api/user.rb
170
+ - lib/drone-ci/api/users.rb
171
+ - lib/drone-ci/client.rb
172
+ homepage: https://github.com/colstrom/drone-ci
173
+ licenses:
174
+ - MIT
175
+ metadata:
176
+ rubygems_mfa_required: 'true'
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: 3.0.0
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubygems_version: 3.3.11
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: Ruby Interface to the Drone CI API
196
+ test_files: []