Skip to content

Commit

Permalink
Update gitlab template
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hollinger committed May 3, 2018
1 parent ea98eb1 commit 36a2357
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 54 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Gitlab CI uses a .gitlab-ci.yml file in the root of your repository tell Gitlab

Key | Description |
| :------------- |:--------------|
| override |Defines whether your local `.sync.yml` will ignore the default values in pdk-templates. Defaults to `false`|
| stages |Defines a job stage for when the CI/CD jobs will be executed in the pipeline.|
| env |Allows you to set any environment variables for the travis build. Currently includes setting the Puppet gem version.|
| variables |Allows you to set any environment variables for the travis build. Currently includes setting the Puppet gem version.|
| bunder\_args |Define any arguments you want to pass through to bundler. The default is `--without system_tests` which avoids installing unnessesary gems.|
| jobs |Define the actual Gitlab CI jobs that will be executed. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/README.html) docs for specifics. Default jobs are created for `rubocop`, `syntax`, `metadata_lint`, and `rspec-puppet` tests on ruby versions `2.1.9` and `2.4.1`.|

Expand Down
100 changes: 50 additions & 50 deletions config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -553,56 +553,56 @@ Gemfile:
# - gem: beaker-rspec
# from_env: BEAKER_RSPEC_VERSION
.gitlab-ci.yml:
stages:
- syntax
- unit
jobs:
rubocop_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake rubocop
syntax_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake syntax lint
metadata_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake metadata_lint
rspec_puppet_2.1.9:
stage: unit
image: ruby:2.1.9
script:
- bundle update
- bundle exec rake spec
rubocop_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake rubocop
syntax_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake syntax lint
metadata_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake metadata_lint
rspec_puppet_2.4.1:
stage: unit
image: ruby:2.4.1
script:
- bundle update
- bundle exec rake spec
variables:
PUPPET_GEM_VERSION: "~> 4.0"
CHECK: spec
bundler_args: --without system_tests
defaults:
stages:
- syntax
- unit
variables:
PUPPET_GEM_VERSION: "~> 5.0"
bundler_args: --without system_tests
jobs:
rubocop_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake rubocop
syntax_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake syntax lint
metadata_2.1.9:
stage: syntax
image: ruby:2.1.9
script:
- bundle exec rake metadata_lint
rspec_puppet_2.1.9:
stage: unit
image: ruby:2.1.9
script:
- bundle update
- bundle exec rake spec
rubocop_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake rubocop
syntax_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake syntax lint
metadata_2.4.1:
stage: syntax
image: ruby:2.4.1
script:
- bundle exec rake metadata_lint
rspec_puppet_2.4.1:
stage: unit
image: ruby:2.4.1
script:
- bundle update
- bundle exec rake spec
spec/default_facts.yml:
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
Expand Down
22 changes: 19 additions & 3 deletions moduleroot/.gitlab-ci.yml.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
---
<% if @configs['override'] && @configs.has_key?('custom') -%>
<% configs = @configs['custom'] -%>
<% elsif @configs['defaults'] && !@configs.has_key?('custom') -%>
<% configs = @configs['defaults'] -%>
<% else -%>
<% require 'deep_merge/core' -%>
<% defaults = @configs['defaults'].dup -%>
<% configs = DeepMerge::deep_merge!(defaults, @configs['custom']) -%>
<% end -%>
stages:
<% @configs['stages'].each do |stage| -%>
<% configs['stages'].each do |stage| -%>
- <%= stage %>
<% end -%>
<% if configs.has_key?('variables') -%>
variables:
<% configs['variables'].each do |variable, value| -%>
<%= variable %>: <%= value %>
<% end -%>
<% end -%>

before_script:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem --version
- bundle -v
- bundle install <%= @configs['bundler_args'] %>
- bundle install <%= configs['bundler_args'] %>
<% @configs['jobs'].each do |job, params| -%>
<% configs['jobs'].each do |job, params| -%>
<%= job %>:
<%- params.keys.sort.each do |key| -%>
<%- if params[key].is_a?(Array) -%>
Expand Down

0 comments on commit 36a2357

Please sign in to comment.