flakyci_rspec 0.1.1

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: 35ac67f4173089d08a0143a146ec07d7c66be8549efc09c069ecdf07d99e5c39
4
+ data.tar.gz: c23ae3890bf1698a0b5b5b40503ba2bb5030cb07f30a76a03552895c4cb811d9
5
+ SHA512:
6
+ metadata.gz: ce0984f9e925cd35959421e6b713abe29e752af3246822b9dedf6a241fa43afe55139f59a115c893abfda6157ff9361438f04e07fc16d18bd2fa16faad3f7306
7
+ data.tar.gz: 5acc329f107bb82646551e8d7b2025f1073829dc5bd5fc0a995b0ae1178dbee146704d5c4d92b344f2382b8dca5ce11b04edc69fedb5c486fb051f0174c4c1ef
@@ -0,0 +1,42 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Publish
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.6
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ version: 2.6.x
20
+
21
+ - name: Publish to GPR
22
+ run: |
23
+ mkdir -p $HOME/.gem
24
+ touch $HOME/.gem/credentials
25
+ chmod 0600 $HOME/.gem/credentials
26
+ printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27
+ gem build *.gemspec
28
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
29
+ env:
30
+ GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
31
+ OWNER: username
32
+
33
+ - name: Publish to RubyGems
34
+ run: |
35
+ mkdir -p $HOME/.gem
36
+ touch $HOME/.gem/credentials
37
+ chmod 0600 $HOME/.gem/credentials
38
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
39
+ gem build *.gemspec
40
+ gem push *.gem
41
+ env:
42
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rake", "~> 12.0"
4
+ gem "rspec", "~> 3.0"
5
+ gem "http"
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.7.0)
5
+ public_suffix (>= 2.0.2, < 5.0)
6
+ diff-lcs (1.3)
7
+ domain_name (0.5.20190701)
8
+ unf (>= 0.0.5, < 1.0.0)
9
+ ffi (1.12.2)
10
+ ffi-compiler (1.0.1)
11
+ ffi (>= 1.0.0)
12
+ rake
13
+ http (4.4.1)
14
+ addressable (~> 2.3)
15
+ http-cookie (~> 1.0)
16
+ http-form_data (~> 2.2)
17
+ http-parser (~> 1.2.0)
18
+ http-cookie (1.0.3)
19
+ domain_name (~> 0.5)
20
+ http-form_data (2.3.0)
21
+ http-parser (1.2.1)
22
+ ffi-compiler (>= 1.0, < 2.0)
23
+ public_suffix (4.0.4)
24
+ rake (12.3.3)
25
+ rspec (3.9.0)
26
+ rspec-core (~> 3.9.0)
27
+ rspec-expectations (~> 3.9.0)
28
+ rspec-mocks (~> 3.9.0)
29
+ rspec-core (3.9.1)
30
+ rspec-support (~> 3.9.1)
31
+ rspec-expectations (3.9.1)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.9.0)
34
+ rspec-mocks (3.9.1)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.9.0)
37
+ rspec-support (3.9.2)
38
+ unf (0.1.4)
39
+ unf_ext
40
+ unf_ext (0.0.7.7)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ http
47
+ rake (~> 12.0)
48
+ rspec (~> 3.0)
49
+
50
+ BUNDLED WITH
51
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Flakyci.com
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.md ADDED
@@ -0,0 +1,40 @@
1
+ # FlakyciRspec
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/flakyci_rspec`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'flakyci_rspec'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install flakyci_rspec
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/flakyci_rspec.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flakyci_rspec"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "flakyci_rspec"
3
+ spec.version = "0.1.1"
4
+ spec.authors = ["flakyci"]
5
+ spec.email = ["contact@flakyci.com"]
6
+
7
+ spec.summary = "FlakyCI helps you fight test flakiness"
8
+ spec.description = "FlakyCI helps you fight test flakiness"
9
+ spec.homepage = "https://www.flakyci.com/"
10
+ spec.license = "MIT"
11
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+
13
+ spec.metadata["homepage_uri"] = spec.homepage
14
+ spec.metadata["source_code_uri"] = "https://github.com/flakyci/flakyci_rspec"
15
+ spec.metadata["changelog_uri"] = "https://github.com/flakyci/flakyci_rspec"
16
+
17
+ spec.add_runtime_dependency('rspec')
18
+ spec.add_runtime_dependency('http')
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+ require 'flakyci_rspec/environments'
3
+ require "http"
4
+
5
+ MUTATION = "
6
+ mutation exUnitResults($build: RspecBuild!, $project_key: UUID4!, $version: Int!) {
7
+ rspecResults(build: $build, projectKey: $project_key, version: $version){
8
+ slug
9
+ text
10
+ }
11
+ }
12
+ "
13
+
14
+ class FlakyciRspec
15
+ RSpec::Core::Formatters.register self, :seed, :dump_summary, :close
16
+
17
+ def initialize(_output)
18
+ @output = ''
19
+ @env = Environments.new()
20
+ end
21
+
22
+ def seed(seed)
23
+ @seed = seed.seed
24
+ end
25
+
26
+ def dump_summary(notification)
27
+ results = notification.examples.map do |example|
28
+ location = example.location.split(':')
29
+
30
+ {
31
+ module: example.example_group,
32
+ name: example.description,
33
+ line: location[1],
34
+ file: location[0],
35
+ status: example.execution_result.status,
36
+ time: (example.execution_result.run_time * 1000).round
37
+ }
38
+ end
39
+ build = @env.get_env()
40
+ build[:suite] = {
41
+ seed: @seed,
42
+ results: results
43
+ }
44
+ print(project_key())
45
+ variables = {
46
+ build: build,
47
+ version: 1,
48
+ project_key: project_key()
49
+ }
50
+ res = HTTP.post(url(), :json => {query: MUTATION, variables: variables})
51
+ res = JSON.parse(res)
52
+ if res["errors"]
53
+ print(res["errors"][0]["message"])
54
+ end
55
+ end
56
+
57
+ def close(_notification)
58
+ @output
59
+ end
60
+
61
+ def project_key
62
+ ENV["FLAKYCI_KEY"]
63
+ end
64
+
65
+ def url
66
+ ENV["FLAKYCI_URL"] || "https://www.flakyci.com/api"
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ require 'flakyci_rspec/environments/local'
2
+ require 'flakyci_rspec/environments/drone'
3
+ require 'flakyci_rspec/environments/github'
4
+ require 'flakyci_rspec/environments/gitlab'
5
+ require 'flakyci_rspec/environments/circle_ci'
6
+ require 'flakyci_rspec/environments/travis_ci'
7
+ require 'flakyci_rspec/environments/codeship'
8
+
9
+ class Environments
10
+ def initialize
11
+ @env = init_env()
12
+ end
13
+ def get_env
14
+ @env.get_infos()
15
+ end
16
+
17
+ def init_env
18
+ if Github.is_github?()
19
+ Environments::Github.new()
20
+ elsif CircleCi.is_circle_ci?()
21
+ Environments::CircleCi.new()
22
+ elsif TravisCi.is_travis_ci?()
23
+ Environments::TravisCi.new()
24
+ elsif Codeship.is_codeship?()
25
+ Environments::Codeship.new()
26
+ elsif Drone.is_drone?()
27
+ Environments::Drone.new()
28
+ elsif Gitlab.is_gitlab?()
29
+ Environments::Gitlab.new()
30
+ else
31
+ Environments::Local.new()
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ class Environments::CircleCi
2
+
3
+ def get_infos()
4
+ {
5
+ sha: sha(),
6
+ build_id: build_id(),
7
+ ref: get_ref(),
8
+ build_name: build_name(),
9
+ env_name: "circle ci"
10
+ }
11
+ end
12
+
13
+ def sha()
14
+ ENV["CIRCLE_SHA1"]
15
+ end
16
+
17
+ def get_ref()
18
+ ENV["CIRCLE_BRANCH"]
19
+ end
20
+
21
+ def build_id()
22
+ ENV["CIRCLE_BUILD_NUM"]
23
+ end
24
+
25
+ def build_name()
26
+ ENV["CIRCLE_JOB"]
27
+ end
28
+
29
+ def self.is_circle_ci?()
30
+ ENV["CIRCLE_SHA1"] != nil
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ class Environments::Codeship
2
+
3
+
4
+ def get_infos()
5
+ {
6
+ sha: sha(),
7
+ build_id: build_id(),
8
+ ref: get_ref(),
9
+ build_name: build_name(),
10
+ env_name: "codeship"
11
+ }
12
+ end
13
+
14
+ def sha()
15
+ ENV["CI_COMMIT_ID"]
16
+ end
17
+
18
+ def get_ref()
19
+ ENV["CI_BRANCH"]
20
+ end
21
+
22
+ def build_id()
23
+ ENV["CI_BUILD_NUMBER"]
24
+ end
25
+
26
+ def build_name()
27
+ ENV["CI_NAME"]
28
+ end
29
+
30
+ def self.is_codeship?()
31
+ ENV["CI_NAME"] != "codeship"
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ class Environments::Drone
2
+
3
+ def get_infos()
4
+ {
5
+ sha: sha(),
6
+ build_id: build_id(),
7
+ ref: get_ref(),
8
+ build_name: build_name(),
9
+ env_name: "drone-ci"
10
+ }
11
+ end
12
+
13
+ def sha()
14
+ ENV["DRONE_COMMIT_SHA"]
15
+ end
16
+
17
+ def get_ref()
18
+ ENV["DRONE_COMMIT_REF"].tr("refs/heads/", "")
19
+ end
20
+
21
+ def build_id()
22
+ ENV["DRONE_BUILD_NUMBER"]
23
+ end
24
+
25
+ def build_name()
26
+ ENV["DRONE_STAGE_NAME"] || "drone"
27
+ end
28
+
29
+ def self.is_drone?()
30
+ ENV["DRONE"] == "true"
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ class Environments::Github
2
+
3
+ def get_infos()
4
+ {
5
+ sha: sha(),
6
+ build_id: build_id(),
7
+ ref: get_ref(),
8
+ build_name: build_name(),
9
+ env_name: "github"
10
+ }
11
+ end
12
+
13
+ def sha()
14
+ ENV["GITHUB_SHA"]
15
+ end
16
+
17
+ def get_ref()
18
+ ENV["GITHUB_REF"].tr("refs/heads/", "")
19
+ end
20
+
21
+ def build_id()
22
+ ENV["GITHUB_RUN_ID"]
23
+ end
24
+
25
+ def build_name()
26
+ ENV["GITHUB_WORKFLOW"]
27
+ end
28
+
29
+ def self.is_github?()
30
+ ENV["GITHUB_SHA"] != nil
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ class Environments::Gitlab
2
+
3
+ def get_infos()
4
+ {
5
+ sha: sha(),
6
+ build_id: build_id(),
7
+ ref: get_ref(),
8
+ build_name: build_name(),
9
+ env_name: "gitlab"
10
+ }
11
+ end
12
+
13
+ def sha()
14
+ ENV["CI_COMMIT_SHA"]
15
+ end
16
+
17
+ def get_ref()
18
+ ENV["CI_COMMIT_REF_NAME"]
19
+ end
20
+
21
+ def build_id()
22
+ ENV["CI_PIPELINE_ID"]
23
+ end
24
+
25
+ def build_name()
26
+ ENV["CI_JOB_NAME"]
27
+ end
28
+
29
+ def self.is_gitlab?()
30
+ ENV["CI_COMMIT_SHA"] != nil
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Environments
4
+ class Local
5
+ def get_infos
6
+ {
7
+ sha: sha,
8
+ build_id: build_id,
9
+ ref: get_ref,
10
+ build_name: build_name,
11
+ env_name: 'local'
12
+ }
13
+ end
14
+
15
+ def sha
16
+ `git rev-parse --short HEAD`.strip!
17
+ end
18
+
19
+ def get_ref
20
+ `git rev-parse --abbrev-ref HEAD`.strip!
21
+ end
22
+
23
+ def build_id
24
+ Time.now.to_i.to_s
25
+ end
26
+
27
+ def build_name
28
+ 'local'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ class Environments::TravisCi
2
+
3
+ def get_infos()
4
+ {
5
+ sha: sha(),
6
+ build_id: build_id(),
7
+ ref: get_ref(),
8
+ build_name: build_name(),
9
+ env_name: "travis-ci"
10
+ }
11
+ end
12
+
13
+ def is_travis?
14
+ ENV["TRAVIS"] == "true"
15
+ end
16
+
17
+ def sha()
18
+ sha = ENV["TRAVIS_PULL_REQUEST_SHA"]
19
+ if sha == ""
20
+ "unknown"
21
+ else
22
+ sha
23
+ end
24
+ end
25
+
26
+ def get_ref()
27
+ ENV["TRAVIS_BRANCH"]
28
+ end
29
+
30
+ def build_id()
31
+ ENV["TRAVIS_BUILD_ID"]
32
+ end
33
+
34
+ def build_name()
35
+ ENV["TRAVIS_JOB_NAME"]
36
+ end
37
+
38
+ def self.is_travis_ci?()
39
+ ENV["TRAVIS"] == "true"
40
+ end
41
+ end
File without changes
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flakyci_rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - flakyci
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: http
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: FlakyCI helps you fight test flakiness
42
+ email:
43
+ - contact@flakyci.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".github/workflows/gempush.yml"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - flakyci_rspec.gemspec
60
+ - lib/flakyci_rspec.rb
61
+ - lib/flakyci_rspec/environments.rb
62
+ - lib/flakyci_rspec/environments/circle_ci.rb
63
+ - lib/flakyci_rspec/environments/codeship.rb
64
+ - lib/flakyci_rspec/environments/drone.rb
65
+ - lib/flakyci_rspec/environments/github.rb
66
+ - lib/flakyci_rspec/environments/gitlab.rb
67
+ - lib/flakyci_rspec/environments/local.rb
68
+ - lib/flakyci_rspec/environments/travis_ci.rb
69
+ - lib/flakyci_rspec/formatter.rb
70
+ homepage: https://www.flakyci.com/
71
+ licenses:
72
+ - MIT
73
+ metadata:
74
+ homepage_uri: https://www.flakyci.com/
75
+ source_code_uri: https://github.com/flakyci/flakyci_rspec
76
+ changelog_uri: https://github.com/flakyci/flakyci_rspec
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.3.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.1.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: FlakyCI helps you fight test flakiness
96
+ test_files: []