Browse Source

More clarity on ENV variables

develop
Christian Aust 5 months ago
parent
commit
d18de8683d
  1. 13
      README.md
  2. 3
      env.sample.txt
  3. 2
      lib/sanity/tests/bamboo.rb
  4. 2
      lib/sanity/tests/bitbucket.rb
  5. 10
      spec/sanity/tests/bamboo_spec.rb
  6. 10
      spec/sanity/tests/bitbucket_spec.rb

13
README.md

@ -80,18 +80,23 @@ If `include` is given, only the given test methods are executed. This is a per-s
If `exclude` is given, the given test methods are not executed. This is a per-suite setting.
## Secrets handling
Bamboo and Bitbucket sanity checks need a user token for access authentication. Create a file `.env` from the template `env.sample.txt` and fill in the token values.
## Execution
To run the docker image as provided, use this sequence:
1. Create an empty directory
2. Create a file `targets.json` there (see below for examples)
3. Run `docker run -v $(pwd):/app sanity:latest`
4. Test results will be in directory `./run`.
2. Create `.env` file
3. Create a file `targets.json` there (see below for examples)
4. Run `docker run -v $(pwd):/app sanity:latest`
5. Test results will be in directory `./run`.
Or run locally by
1. Create .env file with BITBUCKET_TOKEN and BAMBOO_TOKEN
1. Create .env file
2. Create a file `targets.json` (see below for examples)
3. Run `ruby run.rb targets.json`
4. Test results will be in directory `./run`.

3
env.sample.txt

@ -0,0 +1,3 @@
# copy this to .env
BAMBOO_TOKEN=foobar
BITBUCKET_TOKEN=foobar

2
lib/sanity/tests/bamboo.rb

@ -34,8 +34,6 @@ module Sanity
end
end
private
def token
ENV['BAMBOO_TOKEN']
end

2
lib/sanity/tests/bitbucket.rb

@ -74,8 +74,6 @@ module Sanity
end
end
private
def token
ENV['BITBUCKET_TOKEN']
end

10
spec/sanity/tests/bamboo_spec.rb

@ -11,6 +11,16 @@ RSpec.describe Sanity::Tests::Bamboo do
end
end
describe '#token' do
before do
allow(ENV).to receive(:[]).with('BAMBOO_TOKEN').and_return('foo_bar')
end
it 'delegates to ENV[BAMBOO_TOKEN]' do
expect(subject.token).to eq('foo_bar')
end
end
describe '#test_master_build_successful' do
before do
allow(RestClient::Request).to receive(:execute).and_yield(response)

10
spec/sanity/tests/bitbucket_spec.rb

@ -13,6 +13,16 @@ RSpec.describe Sanity::Tests::Bitbucket do
end
end
describe '#token' do
before do
allow(ENV).to receive(:[]).with('BITBUCKET_TOKEN').and_return('foo_bar')
end
it 'delegates to ENV[BITBUCKET_TOKEN]' do
expect(subject.token).to eq('foo_bar')
end
end
describe '#test_branching_model_uses_develop_and_production' do
before do
allow(RestClient::Request).to receive(:execute).and_yield(response)

Loading…
Cancel
Save