simp-test 0.2.1 → 0.3.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a7452c216077fae5abd56d8ddb7a59eebbe5fc049dcaa4e84e951033880160f
4
- data.tar.gz: 1330cbc2f378886a7450eac4410c07d8d990a24324f016a83563adea523ca7ce
3
+ metadata.gz: b9487aa15fe2637c98a02a33941d7b9c1201b3ee2350cb6b0d6f8a3d73b03ea1
4
+ data.tar.gz: 423dfbd08bd5e74cad21f0bae8a8547955650ff1032b2353906ea5b21450c6ca
5
5
  SHA512:
6
- metadata.gz: 34c3d2ace990ca8e88254df4efae372507a983424b7025481a9820ae6ab27e4e39574b9a47763cc7611da46e8c673ce4381ecf51c8a81322c9ef4ad2960f0402
7
- data.tar.gz: 536c02e54798ed7d7234f9c9c8f5d9f5ace88ad828a5cf5aef3faa438ac57ad510005372dbe56b4fa0b72a06f11a07db512e81e4c7c7ee8cedbc39fc8aa95c99
6
+ metadata.gz: 6dc2e7f81f6f8f1ecbd55fe0498a246fbdbca9836b2b89057a73c148837019f63ba41a9a7090d44d7369b0bf263350685e8dfa7d894c8ee145b8ddb1e919b4fb
7
+ data.tar.gz: 54fa02608b2eb5c2845315740dd425486514d36e80339d1b5f6678adccb43d7721b2f4ba48d3019e4fdb1dc64a49e338baf2be41aeb23a829ac3008333965126
@@ -0,0 +1,5 @@
1
+ {
2
+ "gem_build_command": "bundle exec rake pkg:gem",
3
+ "gem_release_command": "gem push dist/*.gem",
4
+ "gem_pkg_dir": "dist"
5
+ }
@@ -38,24 +38,6 @@ jobs:
38
38
  bundle show
39
39
  bundle exec rake rubocop
40
40
 
41
- # releng-checks:
42
- # name: 'RELENG checks'
43
- # runs-on: ubuntu-18.04
44
- # steps:
45
- # - uses: actions/checkout@v2
46
- # - name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
47
- # uses: ruby/setup-ruby@v1
48
- # with:
49
- # ruby-version: 2.5
50
- # bundler-cache: true
51
- # - name: 'Tags and changelogs'
52
- # run: |
53
- # bundle exec rake pkg:check_version
54
- # bundle exec rake pkg:compare_latest_tag
55
- # bundle exec rake pkg:create_tag_changelog
56
- # - name: 'Test-build the Puppet module'
57
- # run: 'bundle exec pdk build --force'
58
-
59
41
  spec-tests:
60
42
  name: 'Spec tests'
61
43
  runs-on: ubuntu-18.04
@@ -1,9 +1,11 @@
1
1
  # Build & Deploy RubyGem & GitHub release when a SemVer tag is pushed
2
+ #
3
+ # This workflow's jobs are only triggered in repos under the `simp` organization
2
4
  # ------------------------------------------------------------------------------
3
5
  #
4
6
  # NOTICE: **This file is maintained with puppetsync**
5
7
  #
6
- # This file is updated automatically as part of an asset baseline.
8
+ # This file is updated automatically as part of a standardized asset baseline.
7
9
  #
8
10
  # The next baseline sync will overwrite any local changes to this file!
9
11
  #
@@ -21,6 +23,19 @@
21
23
  #
22
24
  # * The CHANGLOG text is altered to remove RPM-style date headers, which don't
23
25
  # render well as markdown on the GitHub release pages
26
+ #
27
+ # * By default, the gem is built and released using the standard rake tasks
28
+ # from "bundler/gem_tasks". To override these, create a JSON file at
29
+ # `.github/workflows.local.json`, using the format:
30
+ #
31
+ # {
32
+ # "gem_build_command": "bundle exec rake build",
33
+ # "gem_release_command": "bundle exec rake build release:rubygem_push",
34
+ # "gem_pkg_dir": "pkg"
35
+ # }
36
+ #
37
+ # All keys are optional.
38
+ #
24
39
  ---
25
40
  name: 'Tag: Release to GitHub & rubygems.org'
26
41
 
@@ -36,10 +51,12 @@ env:
36
51
  jobs:
37
52
  releng-checks:
38
53
  name: "RELENG checks"
54
+ if: github.repository_owner == 'simp'
39
55
  runs-on: ubuntu-18.04
40
56
  outputs:
41
57
  build_command: ${{ steps.commands.outputs.build_command }}
42
58
  release_command: ${{ steps.commands.outputs.release_command }}
59
+ pkg_dir: ${{ steps.commands.outputs.pkg_dir }}
43
60
  steps:
44
61
  - name: "Assert '${{ github.ref }}' is a tag"
45
62
  run: '[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || { echo "::error ::GITHUB_REF is not a tag: ${GITHUB_REF}"; exit 1 ; }'
@@ -53,27 +70,48 @@ jobs:
53
70
  # By default, these are the standard tasks from "bundler/gem_tasks"
54
71
  # To override them in the LOCAL_WORKFLOW_CONFIG_FILE
55
72
  GEM_BUILD_COMMAND='bundle exec rake build'
56
- GEM_RELEASE_COMMAND='gem push pkg/*.gem'
73
+ GEM_RELEASE_COMMAND='bundle exec rake build release:rubygem_push'
74
+ GEM_PKG_DIR='pkg'
75
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
76
+ grep -w '"gem_pkg_dir"' &> /dev/null; then
77
+ GEM_PKG_DIR="$(jq -r .gem_pkg_dir "$LOCAL_WORKFLOW_CONFIG_FILE" )"
78
+ fi
57
79
  if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
58
80
  grep -w '"gem_build_command"' &> /dev/null; then
59
- GEM_BUILD_COMMAND="$(jq .gem_build_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
81
+ GEM_BUILD_COMMAND="$(jq -r .gem_build_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
60
82
  fi
61
83
  if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
62
84
  grep -w '"gem_release_command"' &> /dev/null; then
63
- GEM_RELEASE_COMMAND="$(jq .gem_release_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
85
+ GEM_RELEASE_COMMAND="$(jq -r .gem_release_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
64
86
  fi
65
87
  echo "::set-output name=build_command::${GEM_BUILD_COMMAND}"
88
+ echo "::set-output name=pkg_dir::${GEM_PKG_DIR}"
66
89
  echo "::set-output name=release_command::${GEM_RELEASE_COMMAND}"
67
90
  - uses: ruby/setup-ruby@v1
68
91
  with:
69
92
  ruby-version: 2.5
70
93
  bundler-cache: true
71
94
  - name: Test build the package
72
- run: "${{ steps.commands.outputs.build_command }}"
95
+ env:
96
+ GEM_BUILD_COMMAND: ${{ steps.commands.outputs.build_command }}
97
+ run: "$GEM_BUILD_COMMAND"
98
+ - name: "Assert '${{ github.ref }}' matches the package version"
99
+ run: |
100
+ tag="${GITHUB_REF/refs\/tags\//}"
101
+ ls -lart
102
+ ls -lart ${{ steps.commands.outputs.pkg_dir }}
103
+ ls -lart ${{ steps.commands.outputs.pkg_dir }}/*.gem
104
+ [ -d "${{ steps.commands.outputs.pkg_dir }}" ] || \
105
+ { echo "::error ::No directory found at ${{ steps.commands.outputs.pkg_dir }}/" ; exit 3 ; }
106
+ ls -1 "${{ steps.commands.outputs.pkg_dir }}"/*.gem || \
107
+ { echo "::error ::No gem file found at ${{ steps.commands.outputs.pkg_dir }}/*.gem" ; exit 2 ; }
108
+ [ -f "${{ steps.commands.outputs.pkg_dir }}"/*-${tag}.gem ] || \
109
+ { echo "::error ::tag '${tag}' does not match package $(ls -1 ${{ steps.commands.outputs.pkg_dir }}/*.gem)"; exit 1 ; }
73
110
 
74
111
  create-github-release:
75
112
  name: Deploy GitHub Release
76
113
  needs: [ releng-checks ]
114
+ if: github.repository_owner == 'simp'
77
115
  runs-on: ubuntu-18.04
78
116
  steps:
79
117
  - name: Checkout code
@@ -117,6 +155,7 @@ jobs:
117
155
  deploy-rubygem:
118
156
  name: Deploy RubyGem Release
119
157
  needs: [ releng-checks ]
158
+ if: github.repository_owner == 'simp'
120
159
  runs-on: ubuntu-18.04
121
160
  env:
122
161
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
@@ -133,7 +172,12 @@ jobs:
133
172
  ruby-version: 2.5
134
173
  bundler-cache: true
135
174
  - name: Build RubyGem
136
- run: '$BUILD_COMMAND'
175
+ run: |
176
+ echo "Setting up file permissions..."
177
+ chmod -R go=u-w .
178
+
179
+ echo "Running '$BUILD_COMMAND'..."
180
+ $BUILD_COMMAND
137
181
 
138
182
  - name: Release RubyGem
139
183
  run: |
@@ -146,7 +190,5 @@ jobs:
146
190
  EOF
147
191
  chmod 0600 ~/.gem/credentials
148
192
 
149
- chmod -R go=u-w .
150
-
151
193
  echo "Running '$RELEASE_COMMAND'..."
152
194
  $RELEASE_COMMAND
data/Rakefile CHANGED
@@ -1,8 +1,145 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
1
+ require 'rake/clean'
2
+ require 'fileutils'
3
+ require 'find'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
6
+ @package='simp-test'
7
+ @rakefile_dir=File.dirname(__FILE__)
8
+
9
+ CLEAN.include "#{@package}-*.gem"
10
+ CLEAN.include 'pkg'
11
+ CLEAN.include 'dist'
12
+ CLEAN.include '.vendor'
13
+ Find.find( @rakefile_dir ) do |path|
14
+ if File.directory? path
15
+ CLEAN.include path if File.basename(path) == 'tmp'
16
+ else
17
+ Find.prune
18
+ end
19
+ end
20
+
21
+
22
+ desc 'Ensure gemspec-safe permissions on all files'
23
+ task :chmod do
24
+ gemspec = File.expand_path( "#{@package}.gemspec", @rakefile_dir ).strip
25
+ spec = Gem::Specification::load( gemspec )
26
+ spec.files.each do |file|
27
+ FileUtils.chmod 'go=r', file unless File.symlink?(file)
28
+ end
29
+ end
30
+
31
+ desc 'special notes about these rake commands'
32
+ task :help do
33
+ puts %Q{
34
+ == environment variables ==
35
+ SIMP_RPM_BUILD when set, alters the gem produced by pkg:gem to be RPM-safe.
36
+ 'pkg:gem' sets this automatically.
37
+ }
38
+ end
39
+
40
+ desc "Run spec tests"
41
+ RSpec::Core::RakeTask.new(:spec) do |t|
42
+ t.rspec_opts = ['--color']
43
+ t.pattern = 'spec/lib/**/*_spec.rb'
44
+ end
45
+
46
+ desc %q{run all RSpec tests (alias of 'spec')}
47
+ task :test => :spec
48
+
49
+ desc "Run acceptance tests"
50
+ RSpec::Core::RakeTask.new(:acceptance) do |t|
51
+ t.pattern = 'spec/acceptance'
52
+ end
53
+
54
+ namespace :pkg do
55
+ @specfile_template = "rubygem-#{@package}.spec.template"
56
+ @specfile = "build/rubygem-#{@package}.spec"
57
+
58
+ # ----------------------------------------
59
+ # DO NOT UNCOMMENT THIS: the spec file requires a lot of tweaking
60
+ # ----------------------------------------
61
+ # desc "generate RPM spec file for #{@package}"
62
+ # task :spec => [:clean, :gem] do
63
+ # Dir.glob("pkg/#{@package}*.gem") do |pkg|
64
+ # sh %Q{gem2rpm -t "#{@specfile_template}" "#{pkg}" > "#{@specfile}"}
65
+ # end
66
+ # end
67
+
68
+ desc "build rubygem package for #{@package}"
69
+ task :gem => :chmod do
70
+ Dir.chdir @rakefile_dir
71
+ Dir['*.gemspec'].each do |spec_file|
72
+ rpm_build = ENV.fetch('SIMP_RPM_BUILD', '1')
73
+ cmd = %Q{SIMP_RPM_BUILD=#{rpm_build} bundle exec gem build "#{spec_file}"}
74
+ sh cmd
75
+ FileUtils.mkdir_p 'dist'
76
+ FileUtils.mv Dir.glob("#{@package}*.gem"), 'dist/'
77
+ end
78
+ end
79
+
80
+
81
+ desc "build and install rubygem package for #{@package}"
82
+ task :install_gem => [:clean, :gem] do
83
+ Dir.chdir @rakefile_dir
84
+ Dir.glob("dist/#{@package}*.gem") do |pkg|
85
+ sh %Q{bundle exec gem install #{pkg}}
86
+ end
87
+ end
88
+
89
+
90
+ desc "generate RPM for #{@package}"
91
+ require 'tmpdir'
92
+ task :rpm, [:mock_root] => [:clean, :gem] do |t, args|
93
+ mock_root = args[:mock_root]
94
+ # TODO : Get rid of this terrible code. Shoe-horned in until
95
+ # we have a better idea for auto-decet
96
+ if mock_root =~ /^epel-6/ then el_version = '6'
97
+ elsif mock_root =~ /^epel-7/ then el_version = '7'
98
+ else puts 'WARNING: Did not detect epel version'
99
+ end
100
+ tmp_dir = ''
101
+
102
+ if tmp_dir = ENV.fetch( 'SIMP_MOCK_SIMPGEM_ASSETS_DIR', false )
103
+ FileUtils.mkdir_p tmp_dir
104
+ else
105
+ tmp_dir = Dir.mktmpdir( "build_#{@package}" )
106
+ end
107
+
108
+ begin
109
+ Dir.chdir tmp_dir
110
+ specfile = "#{@rakefile_dir}/build/rubygem-#{@package}.el#{el_version}.spec"
111
+ tmp_specfile = "#{tmp_dir}/rubygem-#{@package}.el#{el_version}.spec"
112
+
113
+ # We have to copy to a local directory because mock bugs out in NFS
114
+ # home directories (where SIMP devs often work)
115
+ FileUtils.cp specfile, tmp_specfile, :preserve => true
116
+ Dir.glob("#{@rakefile_dir}/dist/#{@package}*.gem") do |pkg|
117
+ FileUtils.cp pkg, tmp_dir, :preserve => true
118
+ end
119
+
120
+ # Build SRPM from specfile
121
+ sh %Q{mock -r #{mock_root} --buildsrpm --source="#{tmp_dir}" --spec="#{tmp_specfile}" --resultdir="#{tmp_dir}"}
122
+
123
+ # Build RPM from SRPM
124
+ Dir.glob("#{tmp_dir}/rubygem-#{@package}-*.el#{el_version}*.src.rpm") do |pkg|
125
+ sh %Q{mock -r #{mock_root} --rebuild "#{pkg}" --resultdir=#{tmp_dir} --no-cleanup-after}
126
+ end
127
+
128
+ sh %Q{ls -l "#{tmp_dir}"}
129
+
130
+ # copy RPM back into pkg/
131
+ Dir.glob("#{tmp_dir}/rubygem-#{@package}-*.el#{el_version}*.rpm") do |pkg|
132
+ sh %Q{cp "#{pkg}" "#{@rakefile_dir}/dist/"}
133
+ FileUtils.cp pkg, "#{@rakefile_dir}/dist/"
134
+ end
135
+ ensure
136
+ Dir.chdir @rakefile_dir
137
+ # cleanup if needed
138
+ if ! ENV.fetch( 'SIMP_MOCK_SIMPGEM_ASSETS_DIR', false )
139
+ FileUtils.remove_entry_secure tmp_dir
140
+ end
141
+ end
142
+ end
143
+ end
7
144
 
8
- task default: :spec
145
+ # vim: syntax=ruby
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Simp
4
4
  module Test
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.19'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - SIMP Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-30 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows.local.json"
20
21
  - ".github/workflows/pr_glci.yml"
21
22
  - ".github/workflows/pr_glci_cleanup.yml"
22
23
  - ".github/workflows/pr_glci_manual.yml"