percy-client 0.4.1 → 0.5.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 +4 -4
 - data/lib/percy/client/environment.rb +7 -0
 - data/lib/percy/client/version.rb +1 -1
 - data/spec/lib/percy/client/environment_spec.rb +41 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e75bc0f2c8c81c6760bd43294b467c232a257c2c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c99b03e4396aa30c6e012ed1e5c629bd44761f14
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f5f5412f33c7f120d0c12a2450fba57220c2a7a6a393977c5d8642346b02b265732b77fc8915257a3708dd94063715582b71c86654001355d8acecf41769a8f0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7808a2f4b246321aa6eb42e44999eda094e05d6479823facaf85e2d0a6a7d31ddc785cae0cfaa750d5d4a2c3d0432700dcddeb698932cacecfed56413d7e1b42
         
     | 
| 
         @@ -20,6 +20,7 @@ module Percy 
     | 
|
| 
       20 
20 
     | 
    
         
             
                    return :jenkins if ENV['JENKINS_URL'] && ENV['ghprbPullId']  # Pull Request Builder plugin.
         
     | 
| 
       21 
21 
     | 
    
         
             
                    return :circle if ENV['CIRCLECI']
         
     | 
| 
       22 
22 
     | 
    
         
             
                    return :codeship if ENV['CI_NAME'] && ENV['CI_NAME'] == 'codeship'
         
     | 
| 
      
 23 
     | 
    
         
            +
                    return :drone if ENV['DRONE'] == 'true'
         
     | 
| 
       23 
24 
     | 
    
         
             
                  end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
26 
     | 
    
         
             
                  # @return [Hash] All commit data from the current commit. Might be empty if commit data could
         
     | 
| 
         @@ -65,6 +66,8 @@ module Percy 
     | 
|
| 
       65 
66 
     | 
    
         
             
                      ENV['CIRCLE_SHA1']
         
     | 
| 
       66 
67 
     | 
    
         
             
                    when :codeship
         
     | 
| 
       67 
68 
     | 
    
         
             
                      ENV['CI_COMMIT_ID']
         
     | 
| 
      
 69 
     | 
    
         
            +
                    when :drone
         
     | 
| 
      
 70 
     | 
    
         
            +
                      ENV['DRONE_COMMIT']
         
     | 
| 
       68 
71 
     | 
    
         
             
                    end
         
     | 
| 
       69 
72 
     | 
    
         
             
                  end
         
     | 
| 
       70 
73 
     | 
    
         | 
| 
         @@ -89,6 +92,8 @@ module Percy 
     | 
|
| 
       89 
92 
     | 
    
         
             
                      ENV['CIRCLE_BRANCH']
         
     | 
| 
       90 
93 
     | 
    
         
             
                    when :codeship
         
     | 
| 
       91 
94 
     | 
    
         
             
                      ENV['CI_BRANCH']
         
     | 
| 
      
 95 
     | 
    
         
            +
                    when :drone
         
     | 
| 
      
 96 
     | 
    
         
            +
                      ENV['DRONE_BRANCH']
         
     | 
| 
       92 
97 
     | 
    
         
             
                    else
         
     | 
| 
       93 
98 
     | 
    
         
             
                      _raw_branch_output
         
     | 
| 
       94 
99 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -146,6 +151,8 @@ module Percy 
     | 
|
| 
       146 
151 
     | 
    
         
             
                      end
         
     | 
| 
       147 
152 
     | 
    
         
             
                    when :codeship
         
     | 
| 
       148 
153 
     | 
    
         
             
                      # Unfortunately, codeship always returns 'false' for CI_PULL_REQUEST. For now, return nil.
         
     | 
| 
      
 154 
     | 
    
         
            +
                    when :drone
         
     | 
| 
      
 155 
     | 
    
         
            +
                      ENV['CI_PULL_REQUEST']
         
     | 
| 
       149 
156 
     | 
    
         
             
                    end
         
     | 
| 
       150 
157 
     | 
    
         
             
                  end
         
     | 
| 
       151 
158 
     | 
    
         | 
    
        data/lib/percy/client/version.rb
    CHANGED
    
    
| 
         @@ -32,6 +32,13 @@ RSpec.describe Percy::Client::Environment do 
     | 
|
| 
       32 
32 
     | 
    
         
             
                ENV['CI_BRANCH'] = nil
         
     | 
| 
       33 
33 
     | 
    
         
             
                ENV['CI_PULL_REQUEST'] = nil
         
     | 
| 
       34 
34 
     | 
    
         
             
                ENV['CI_COMMIT_ID'] = nil
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                # Unset Drone vars.
         
     | 
| 
      
 37 
     | 
    
         
            +
                ENV['CI'] = nil
         
     | 
| 
      
 38 
     | 
    
         
            +
                ENV['DRONE'] = nil
         
     | 
| 
      
 39 
     | 
    
         
            +
                ENV['DRONE_COMMIT'] = nil
         
     | 
| 
      
 40 
     | 
    
         
            +
                ENV['DRONE_BRANCH'] = nil
         
     | 
| 
      
 41 
     | 
    
         
            +
                ENV['CI_PULL_REQUEST'] = nil
         
     | 
| 
       35 
42 
     | 
    
         
             
              end
         
     | 
| 
       36 
43 
     | 
    
         | 
| 
       37 
44 
     | 
    
         
             
              before(:each) do
         
     | 
| 
         @@ -273,6 +280,40 @@ RSpec.describe Percy::Client::Environment do 
     | 
|
| 
       273 
280 
     | 
    
         
             
                  end
         
     | 
| 
       274 
281 
     | 
    
         
             
                end
         
     | 
| 
       275 
282 
     | 
    
         
             
              end
         
     | 
| 
      
 283 
     | 
    
         
            +
              context 'in Drone' do
         
     | 
| 
      
 284 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 285 
     | 
    
         
            +
                  ENV['DRONE'] = 'true'
         
     | 
| 
      
 286 
     | 
    
         
            +
                  ENV['DRONE_COMMIT'] = 'drone-commit-sha'
         
     | 
| 
      
 287 
     | 
    
         
            +
                  ENV['DRONE_BRANCH'] = 'drone-branch'
         
     | 
| 
      
 288 
     | 
    
         
            +
                  ENV['CI_PULL_REQUEST'] = '123'
         
     | 
| 
      
 289 
     | 
    
         
            +
                end
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
                describe '#current_ci' do
         
     | 
| 
      
 292 
     | 
    
         
            +
                  it 'is :drone' do
         
     | 
| 
      
 293 
     | 
    
         
            +
                    expect(Percy::Client::Environment.current_ci).to eq(:drone)
         
     | 
| 
      
 294 
     | 
    
         
            +
                  end
         
     | 
| 
      
 295 
     | 
    
         
            +
                end
         
     | 
| 
      
 296 
     | 
    
         
            +
                describe '#branch' do
         
     | 
| 
      
 297 
     | 
    
         
            +
                  it 'reads from the CI environment' do
         
     | 
| 
      
 298 
     | 
    
         
            +
                    expect(Percy::Client::Environment.branch).to eq('drone-branch')
         
     | 
| 
      
 299 
     | 
    
         
            +
                  end
         
     | 
| 
      
 300 
     | 
    
         
            +
                end
         
     | 
| 
      
 301 
     | 
    
         
            +
                describe '#_commit_sha' do
         
     | 
| 
      
 302 
     | 
    
         
            +
                  it 'reads from the CI environment' do
         
     | 
| 
      
 303 
     | 
    
         
            +
                    expect(Percy::Client::Environment._commit_sha).to eq('drone-commit-sha')
         
     | 
| 
      
 304 
     | 
    
         
            +
                  end
         
     | 
| 
      
 305 
     | 
    
         
            +
                end
         
     | 
| 
      
 306 
     | 
    
         
            +
                describe '#pull_request_number' do
         
     | 
| 
      
 307 
     | 
    
         
            +
                  it 'reads from the CI environment' do
         
     | 
| 
      
 308 
     | 
    
         
            +
                    expect(Percy::Client::Environment.pull_request_number).to eq('123')
         
     | 
| 
      
 309 
     | 
    
         
            +
                  end
         
     | 
| 
      
 310 
     | 
    
         
            +
                end
         
     | 
| 
      
 311 
     | 
    
         
            +
                describe '#repo' do
         
     | 
| 
      
 312 
     | 
    
         
            +
                  it 'returns the current local repo name' do
         
     | 
| 
      
 313 
     | 
    
         
            +
                    expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
         
     | 
| 
      
 314 
     | 
    
         
            +
                  end
         
     | 
| 
      
 315 
     | 
    
         
            +
                end
         
     | 
| 
      
 316 
     | 
    
         
            +
              end
         
     | 
| 
       276 
317 
     | 
    
         
             
              describe 'local git repo methods' do
         
     | 
| 
       277 
318 
     | 
    
         
             
                describe '#commit' do
         
     | 
| 
       278 
319 
     | 
    
         
             
                  it 'returns current local commit data' do
         
     |