Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with Vox Pupuli #73

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
name: noop run

on:
workflow_dispatch: {}
pull_request: {}
push:
branches:
- master
pull_request:
branches:
- master

jobs:
unit:
runs-on: ubuntu-latest
name: Run msync --noop against all modules
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Run msync --noop
run: bundle exec msync update --noop --git-base=https://github.com/
run: bundle exec msync update --noop --git-base=https://github.com/ --branch foobranch
metadata_json_deps:
runs-on: ubuntu-latest
name: Run metadata_json_deps on all modules
steps:
- uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Run msync --noop
run: bundle exec msync clone --git-base=https://github.com/
- run: bundle exec rake metadata_deps
outdated_module_summary:
runs-on: ubuntu-latest
name: Prints a list of all modules with outdated modulesync_config version
steps:
- uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Run msync --noop
run: bundle exec msync clone --git-base=https://github.com/
- name: Generate summary
run: bundle exec bin/outdated_modules_and_their_version

tests:
needs:
- unit
- metadata_json_deps
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed
34 changes: 28 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# frozen_string_literal: true
# Copyright 2016 Vox Pupuli
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source 'https://rubygems.org'
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

gem 'github_changelog_generator'
gem 'modulesync'
gem 'rake'
gem 'rubocop'
group :development do
gem 'pry'
end

group :release do
gem 'faraday-retry', '~> 2.1', require: false
gem 'github_changelog_generator', '~> 1.16.4', require: false
end

gem 'puppet_forge', '>= 2.2.9'
gem 'metadata_json_deps', '>= 0.2.0', '< 2'
gem 'modulesync', '>= 2.6.0'
gem "octokit", "~> 4.0"
# vim: syntax=ruby
72 changes: 15 additions & 57 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,63 +1,21 @@
# frozen_string_literal: true
require 'metadata_json_deps'

require 'erb'
require 'find'
require 'open3'
require 'rubocop/rake_task'
require 'yaml'

def project_files(*suffixes, &block)
Find.find(*Dir['*']) do |path|
if FileTest.directory?(path)
Find.prune if %w[modules vendor].include?(path)
elsif suffixes.map { |x| path.end_with?(x) }.any?
block.call(path)
end
end
end

RuboCop::RakeTask.new

desc 'Check syntax of various files'
task default: %i[erb rubocop yml]

task :erb do
puts '===> Checking ERB files syntax…'
project_files('.erb') do |file|
puts file
erb = File.read(file)
code = ERB.new(erb, trim_mode: '-').src
Open3.popen2e('ruby -c') do |stdin, stdout_and_stderr, wait_thr|
stdin.puts(code)
stdin.close

exit_status = wait_thr.value
abort(stdout_and_stderr.read) unless exit_status.success?

stdout_and_stderr.close
end
end
desc 'Run metadata-json-deps'
task :metadata_deps do
files = FileList['modules/*/*/metadata.json']
MetadataJsonDeps.run(files)
end

task :yml do
puts '===> Checking YAML files syntax…'
project_files('.yml', '.yaml') do |file|
puts file
begin
require 'github_changelog_generator/task'
require 'yaml'

begin
YAML.load_file(file)
rescue Psych::SyntaxError => e
abort(e.message)
end
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog github_actions}
config.user = 'voxpupuli'
config.project = 'modulesync_config'
config.future_release = YAML.safe_load(File.read('moduleroot/.msync.yml.erb'))['modulesync_config_version']
end
end

require 'github_changelog_generator/task'

GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = 'opus-codium'
config.project = 'modulesync_config'
config.future_release = '2.4.0'
config.unreleased = true
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog ignore]
rescue LoadError
end
40 changes: 40 additions & 0 deletions bin/outdated_modules_and_their_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env ruby

require 'yaml'
require 'erb'

# the current version in modulesync_config
version = YAML.load(ERB.new(File.read('moduleroot/.msync.yml.erb')).result)['modulesync_config_version']

mod_ary = []
# min width is width of String "Module"
width_modules = 6
# min width is width of String "modulesync_config version"
width_version = 25
Dir.glob('modules/voxpupuli/puppet-*').sort.each do |f|
if File.exists?(f + '/.msync.yml')
version_module = YAML.load_file(f + '/.msync.yml')['modulesync_config_version']
mod = (f).split('/')[2]
if version != version_module
mod_ary.push([mod, version_module])
width_modules = [width_modules, mod.length].max
width_version = [width_version, version_module.length].max
end
else
version_module = 'None'
mod = (f).split('/')[2]
mod_ary.push([mod, version_module])
width_modules = [width_modules, mod.length].max
width_version = [width_version, version_module.length].max
end
end

total_width = width_modules + width_version + 7

puts '-' * total_width
puts "current version: #{version}"
puts '-' * total_width
puts "| #{'Module'.ljust(width_modules)} | #{'modulesync_config version'.ljust(width_version)} |"
mod_ary.each do |mod, version_module|
puts "| #{mod.ljust(width_modules)} | #{version_module.ljust(width_version)} |"
end
16 changes: 7 additions & 9 deletions config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
extra_owners: []
.github/workflows/ci.yml:
excludes: []
pidfile_workaround: false
additional_packages: ''
acceptance_tests: true
main_branches: ['main']
# PDK creates this
.github/workflows/puppet-lint.yml:
delete: true
Expand All @@ -18,25 +17,21 @@ Gemfile:
required:
':test':
- gem: voxpupuli-test
version: '~> 7.0'
version: '~> 8.0'
- gem: coveralls
- gem: simplecov-console
- gem: puppet_metadata
version: '~> 3.0'
version: '~> 4.0'
':development':
- gem: guard-rake
- gem: overcommit
version: '>= 0.39.1'
':system_tests':
- gem: voxpupuli-acceptance
version: '~> 2.0'
version: '~> 3.0'
':release':
- gem: github_changelog_generator
version: '>= 1.16.1'
- gem: voxpupuli-release
version: '~> 3.0'
- gem: faraday-retry
version: '~> 2.1'
Rakefile:
config.user: opus-codium
# config.project: PROJECT
Expand Down Expand Up @@ -64,6 +59,8 @@ spec/acceptance/nodesets/centos-66-x64-pe.yml:
delete: true
spec/acceptance/nodesets/centos-7-x64.yml:
delete: true
spec/acceptance/nodesets/centos-7.yml:
delete: true
spec/acceptance/nodesets/centos-72-x64.yml:
delete: true
spec/acceptance/nodesets/debian-78-x64.yml:
Expand Down Expand Up @@ -116,6 +113,7 @@ spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml:
delete: true
spec/spec_helper.rb:
add_mocked_facts: true
facterdb_string_keys: false
mock_with: false
spec/spec_helper_acceptance.rb:
unmanaged: true
Expand Down
1 change: 0 additions & 1 deletion managed_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
- puppet-nextcloud
- puppet-odoo
- puppet-postsrsd
- puppet-puppetvpn
- puppet-rwhod
- puppet-sogo
- puppet-ssh
Expand Down
3 changes: 3 additions & 0 deletions moduleroot/.github/labeler.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
skip-changelog:
- head-branch: ['^release-*', 'release']
36 changes: 16 additions & 20 deletions moduleroot/.github/workflows/ci.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

name: CI

on: pull_request
on:
pull_request: {}
push:
branches:
<%- @configs['main_branches'].each do |main_branch| -%>
- <%= main_branch %>
<%- end -%>

concurrency:
group: ${{ github.ref_name }}
Expand All @@ -14,27 +20,17 @@ jobs:
puppet:
name: Puppet
<%- if @configs['acceptance_tests'] && Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%>
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
with:
pidfile_workaround: '<%= @configs['pidfile_workaround'] %>'
<%- if @configs['unit_runs_on'] -%>
unit_runs_on: '<%= @configs['unit_runs_on'] %>'
<%- end -%>
<%- if @configs['acceptance_runs_on'] -%>
acceptance_runs_on: '<%= @configs['acceptance_runs_on'] %>'
<%- end -%>
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
<%- else -%>
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1
<%- if @configs.key?('rubocop') || !@configs['additional_packages'].empty? || @configs.key?('unit_runs_on') -%>
with:
<%- end -%>
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2
<%- end -%>
<%- unless @configs['additional_packages'].empty? -%>
additional_packages: '<%= @configs['additional_packages'] %>'
<%- if @configs['with'] -%>
with:
<%- @configs['with'].each do |k,v| -%>
<%- if v.is_a?(String) -%>
<%= k %>: '<%= v %>'
<%- else -%>
<%= k %>: <%= v %>
<%- end -%>
<%- if @configs.key?('rubocop') -%>
rubocop: <%= @configs['rubocop'] %>
<%- end -%>
<%- if Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].none? && @configs['unit_runs_on'] -%>
unit_runs_on: '<%= @configs['unit_runs_on'] %>'
<%- end -%>
14 changes: 14 additions & 0 deletions moduleroot/.github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "Pull Request Labeler"

on:
pull_request_target: {}

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
13 changes: 12 additions & 1 deletion moduleroot/.github/workflows/release.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ on:
jobs:
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2
with:
<%- if @configs['with'] -%>
<%- @configs['with'].each do |k,v| -%>
<%- if v.is_a?(String) -%>
<%= k %>: '<%= v %>'
<%- else -%>
<%= k %>: <%= v %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- unless @configs['with']&.has_key?('allowed_owner') -%>
allowed_owner: '<%= @configs[:namespace] %>'
<%- end -%>
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
Expand Down
4 changes: 3 additions & 1 deletion moduleroot/.gitignore.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
.*.sw?
/.yardoc/
/Guardfile
<% if ! @configs['paths'].nil? -%>
bolt-debug.log
.rerun.json
<% unless @configs['paths'].nil? -%>
<% @configs['paths'].each do |path| -%>
<%= path %>
<% end -%>
Expand Down
5 changes: 5 additions & 0 deletions moduleroot/.msync.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '9.0.0'
Loading