Skip to content

Commit 612d8af

Browse files
authored
Merge pull request puppetlabs#43 from puppetlabs/CONT-704-Implement_reusable_workflows
(CONT-704) - Implement reusable workflows
2 parents 9f93612 + b8a108b commit 612d8af

File tree

12 files changed

+142
-49
lines changed

12 files changed

+142
-49
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "ci"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
workflow_dispatch:
8+
9+
jobs:
10+
spec:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
ruby_version:
15+
- "2.5"
16+
- "2.7"
17+
puppet_gem_version:
18+
- '~> 6.0'
19+
- '~> 7.0'
20+
runs_on:
21+
- "ubuntu-latest"
22+
- "windows-latest"
23+
name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})"
24+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
25+
secrets: "inherit"
26+
with:
27+
ruby_version: ${{ matrix.ruby_version }}
28+
puppet_gem_version: ${{ matrix.puppet_gem_version }}
29+
runs_on: ${{ matrix.runs_on }}

.github/workflows/labeller.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: community-labeller
2+
3+
on:
4+
issues:
5+
types:
6+
- "opened"
7+
pull_request_target:
8+
types:
9+
- "opened"
10+
11+
jobs:
12+
label:
13+
runs-on: "ubuntu-latest"
14+
steps:
15+
16+
- uses: "puppetlabs/community-labeller@v0"
17+
name: "Label issues or pull requests"
18+
with:
19+
label_name: "community"
20+
label_color: '5319e7'
21+
org_membership: "puppetlabs"
22+
token: ${{ secrets.IAC_COMMUNITY_LABELER }}

.github/workflows/main.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/nightly.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "nightly"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
spec:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby_version:
14+
- "2.5"
15+
- "2.7"
16+
puppet_gem_version:
17+
- '~> 6.0'
18+
- '~> 7.0'
19+
runs_on:
20+
- "ubuntu-latest"
21+
- "windows-latest"
22+
name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})"
23+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
24+
secrets: "inherit"
25+
with:
26+
ruby_version: ${{ matrix.ruby_version }}
27+
puppet_gem_version: ${{ matrix.puppet_gem_version }}
28+
runs_on: ${{ matrix.runs_on }}

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: "The target for the release. This can be a commit sha or a branch."
8+
required: false
9+
default: "main"
10+
11+
jobs:
12+
release:
13+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release.yml@main"
14+
with:
15+
target: "${{ github.event.inputs.target }}"
16+
secrets: "inherit"

.github/workflows/release_prep.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "release prep"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: "The target for the release. This can be a commit sha or a branch."
8+
required: false
9+
default: "main"
10+
version:
11+
description: "Version of gem to be released."
12+
required: true
13+
14+
jobs:
15+
release_prep:
16+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main"
17+
with:
18+
target: "${{ github.event.inputs.target }}"
19+
version: "${{ github.events.inputs.version }}"
20+
secrets: "inherit"

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Silencing rubocop warnings until https://tickets.puppetlabs.com/browse/CONT-725
2+
# is completed
3+
AllCops:
4+
DisabledByDefault: true

Gemfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ if RUBY_VERSION =~ /^1\.?9/
1717
gem 'ffi', '<= 1.9.14'
1818
end
1919

20-
gem 'rspec', *location_for(ENV['RSPEC_GEM_VERSION'] || '~> 3.0')
21-
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 7.0')
22-
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'] || '~> 4.0')
20+
gem 'rspec', *location_for(!ENV['RSPEC_GEM_VERSION']&.empty? ? ENV['RSPEC_GEM_VERSION'] : '~> 3.0')
21+
gem 'puppet', *location_for(!ENV['PUPPET_GEM_VERSION']&.empty? ? ENV['PUPPET_GEM_VERSION'] : '~> 7.0')
22+
gem 'facter', *location_for(!ENV['FACTER_GEM_VERSION']&.empty? ? ENV['FACTER_GEM_VERSION'] : '~> 4.0')
2323
gem 'pry', :group => :development
2424

2525
if RUBY_VERSION =~ /^1\.?/
@@ -38,8 +38,9 @@ if RUBY_VERSION =~ /^1\.?9/
3838
elsif RUBY_VERSION =~ /^1\.?8/
3939
gem 'json_pure', '< 2.0.0'
4040
else
41-
gem 'rubocop'
42-
gem 'rubocop-rspec', '~> 1.6' if (RUBY_VERSION >= '2.3.0' || RUBY_VERSION >= '23')
41+
gem "rubocop", '= 1.6.1', require: false
42+
gem "rubocop-performance", '= 1.9.1', require: false
43+
gem "rubocop-rspec", '= 2.0.1', require: false
4344
gem 'sync' if (RUBY_VERSION >= '2.7.0')
4445
end
4546

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'rake'
22
require 'rspec/core/rake_task'
3+
require 'rubocop/rake_task'
34
require 'bundler/gem_tasks'
45
require 'fileutils'
56
require 'puppet'
@@ -89,3 +90,7 @@ task :test do
8990
Rake::Task['test:teardown'].invoke
9091
end
9192
end
93+
94+
RuboCop::RakeTask.new(:rubocop) do |task|
95+
task.options = %w[-D -S -E]
96+
end

lib/rspec-puppet/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#frozen_string_literal: true
2+
3+
module RSpecPuppet
4+
VERSION ||= '2.12.0'
5+
end

rspec-puppet.gemspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
lib = File.expand_path('lib', __dir__)
2+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3+
require 'rspec-puppet/version'
4+
15
Gem::Specification.new do |s|
26
s.name = 'rspec-puppet'
3-
s.version = '2.12.0'
7+
s.version = RSpecPuppet::VERSION
48
s.homepage = 'https://github.com/puppetlabs/rspec-puppet/'
59
s.summary = 'RSpec tests for your Puppet manifests'
610
s.description = 'RSpec tests for your Puppet manifests'

spec/classes/test_registry_spec.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
require 'spec_helper'
22

33
describe 'test::registry', :if => Puppet.version.to_f >= 4.0 do
4-
let(:facts) do
5-
{
6-
:operatingsystem => 'windows',
7-
}
8-
end
9-
4+
let(:facts) { {:os => { :name => 'windows' } } }
5+
106
it { should compile.with_all_deps }
117
end

0 commit comments

Comments
 (0)