Skip to content

Commit

Permalink
Update docker specs to use shared libraries (#929)
Browse files Browse the repository at this point in the history
Update docker specs to use shared libraries
  • Loading branch information
Iristyle committed May 29, 2019
2 parents 6ddc440 + bd0b88f commit 6dc6148
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ matrix:
- stage: r10k tests
rvm: jruby
- stage: r10k container tests
language: generic
language: ruby
rvm: 2.5.5
env:
- DOCKER_COMPOSE_VERSION=1.24.0
script:
- cd docker && make lint && make build && make test
- |
set -ex
sudo rm /usr/local/bin/docker-compose
curl --location https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname --kernel-name`-`uname --machine` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
cd docker
make lint
make build
make test
set +x
2 changes: 1 addition & 1 deletion docker/.rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--require ./r10k/spec/spec_helper
--require pupperware/spec_helper
--format RspecJunitFormatter
--out TEST-rspec.xml
--format documentation
4 changes: 4 additions & 0 deletions docker/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ end

gem 'rspec'
gem 'rspec_junit_formatter'
gem 'pupperware',
:git => 'https://github.com/puppetlabs/pupperware.git',
:ref => 'master',
:glob => 'gem/*.gemspec'
22 changes: 10 additions & 12 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ build_date := $(shell date -u +%FT%T)
hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
hadolint_command := hadolint --ignore DL3008 --ignore DL3018 --ignore DL4000 --ignore DL4001
hadolint_container := hadolint/hadolint:latest
pwd := $(shell pwd)
export BUNDLE_PATH = $(pwd)/.bundle/gems
export BUNDLE_BIN = $(pwd)/.bundle/bin
export GEMFILE = $(pwd)/Gemfile

ifeq ($(IS_NIGHTLY),true)
dockerfile := Dockerfile.nightly
version := puppet6-nightly
else
version = $(shell echo $(git_describe) | sed 's/-.*//')
dockerfile := Dockerfile
endif

version = $(shell echo $(git_describe) | sed 's/-.*//')
dockerfile := Dockerfile

prep:
ifneq ($(IS_NIGHTLY),true)
@git fetch --unshallow ||:
@git fetch origin 'refs/tags/*:refs/tags/*'
endif

lint:
ifeq ($(hadolint_available),0)
Expand All @@ -45,8 +41,10 @@ ifeq ($(IS_LATEST),true)
endif

test: prep
@bundle install --path .bundle/gems
@PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/r10k:$(version) bundle exec rspec r10k/spec
@bundle install --path $$BUNDLE_PATH --gemfile $$GEMFILE
@PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/r10k:$(version) \
bundle exec --gemfile $$GEMFILE \
rspec r10k/spec

push-image: prep
@docker push $(NAMESPACE)/r10k:$(version)
Expand Down
17 changes: 12 additions & 5 deletions docker/r10k/spec/dockerfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
SPEC_DIRECTORY = File.dirname(__FILE__)

describe 'r10k container' do
include Helpers

include Pupperware::SpecHelpers
def run_r10k(command)
run_command("docker run --rm \
run_command("docker run --detach \
--volume #{File.join(SPEC_DIRECTORY, 'fixtures')}:/test \
#{@image} #{command} \
--puppetfile /test/Puppetfile")
Expand All @@ -33,12 +32,20 @@ def run_r10k(command)

it 'should validate the Puppetfile' do
result = run_r10k('puppetfile check')
expect(result[:status].exitstatus).to eq(0)
container = result[:stdout].chomp
wait_on_container_exit(container)
expect(get_container_exit_code(container)).to eq(0)
emit_log(container)
teardown_container(container)
end

it 'should install the Puppetfile' do
result = run_r10k('puppetfile install')
expect(result[:status].exitstatus).to eq(0)
container = result[:stdout].chomp
wait_on_container_exit(container)
expect(get_container_exit_code(container)).to eq(0)
expect(Dir.exist?(File.join(SPEC_DIRECTORY, 'fixtures', 'modules', 'ntp'))).to eq(true)
emit_log(container)
teardown_container(container)
end
end
22 changes: 0 additions & 22 deletions docker/r10k/spec/spec_helper.rb

This file was deleted.

0 comments on commit 6dc6148

Please sign in to comment.