From c5f3e0489ba2dc5e84312f9e2db7c025e28ef004 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Sun, 5 May 2024 01:54:36 +0200 Subject: [PATCH 1/3] Cleanup workflow templates; require 'with' key in module's .sync.yml --- config_defaults.yml | 2 -- moduleroot/.github/workflows/ci.yml.erb | 32 +++----------------- moduleroot/.github/workflows/release.yml.erb | 4 ++- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/config_defaults.yml b/config_defaults.yml index adea84c5..5d396f06 100644 --- a/config_defaults.yml +++ b/config_defaults.yml @@ -2,8 +2,6 @@ # yamllint disable rule:line-length .github/workflows/ci.yml: excludes: [] - pidfile_workaround: false - additional_packages: '' acceptance_tests: true main_branches: ['main', 'master'] # PDK creates this diff --git a/moduleroot/.github/workflows/ci.yml.erb b/moduleroot/.github/workflows/ci.yml.erb index 801c2e1e..91084300 100644 --- a/moduleroot/.github/workflows/ci.yml.erb +++ b/moduleroot/.github/workflows/ci.yml.erb @@ -21,42 +21,18 @@ jobs: name: Puppet <%- if @configs['acceptance_tests'] && Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%> uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 - with: - pidfile_workaround: '<%= @configs['pidfile_workaround'] %>' <%- if @configs['with'] -%> + with: <%- @configs['with'].each do |k,v| -%> - <%= k %>: <%= v %> -<%- end -%> -<%- end -%> -<%- if @configs['unit_runs_on'] -%> - unit_runs_on: '<%= @configs['unit_runs_on'] %>' -<%- end -%> -<%- if @configs['beaker_facter'] -%> - beaker_facter: '<%= @configs['beaker_facter'] %>' -<%- end -%> -<%- if @configs['beaker_hypervisor'] -%> - beaker_hypervisor: '<%= @configs['beaker_hypervisor'] %>' + <%= k %>: '<%= v %>' <%- end -%> -<%- if @configs['acceptance_runs_on'] -%> - acceptance_runs_on: '<%= @configs['acceptance_runs_on'] %>' <%- end -%> <%- else -%> uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 -<%- if @configs.key?('rubocop') || !@configs['additional_packages'].empty? || @configs.key?('unit_runs_on') || @configs.key?('with') -%> - with: -<%- end -%> <%- if @configs['with'] -%> + with: <%- @configs['with'].each do |k,v| -%> - <%= k %>: <%= v %> -<%- end -%> -<%- end -%> -<%- end -%> -<%- unless @configs['additional_packages'].empty? -%> - additional_packages: '<%= @configs['additional_packages'] %>' + <%= 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 -%> diff --git a/moduleroot/.github/workflows/release.yml.erb b/moduleroot/.github/workflows/release.yml.erb index c4d598b8..f48ae376 100644 --- a/moduleroot/.github/workflows/release.yml.erb +++ b/moduleroot/.github/workflows/release.yml.erb @@ -16,10 +16,12 @@ jobs: with: <%- if @configs['with'] -%> <%- @configs['with'].each do |k,v| -%> - <%= k %>: <%= v %> + <%= k %>: '<%= v %>' <%- end -%> <%- end -%> +<%- if @configs['with'].nil? || !@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 From 0517b40852618098a0cf46c9ca3cc75001c0cee8 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Sun, 5 May 2024 10:17:27 +0200 Subject: [PATCH 2/3] fix: only write hypens for string values --- moduleroot/.github/workflows/ci.yml.erb | 8 ++++++++ moduleroot/.github/workflows/release.yml.erb | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/moduleroot/.github/workflows/ci.yml.erb b/moduleroot/.github/workflows/ci.yml.erb index 91084300..e7e6addb 100644 --- a/moduleroot/.github/workflows/ci.yml.erb +++ b/moduleroot/.github/workflows/ci.yml.erb @@ -24,7 +24,11 @@ jobs: <%- if @configs['with'] -%> with: <%- @configs['with'].each do |k,v| -%> +<%- if v.is_a?(String) -%> <%= k %>: '<%= v %>' +<%- else -%> + <%= k %>: <%= v %> +<%- end -%> <%- end -%> <%- end -%> <%- else -%> @@ -32,7 +36,11 @@ jobs: <%- if @configs['with'] -%> with: <%- @configs['with'].each do |k,v| -%> +<%- if v.is_a?(String) -%> <%= k %>: '<%= v %>' +<%- else -%> + <%= k %>: <%= v %> +<%- end -%> <%- end -%> <%- end -%> <%- end -%> diff --git a/moduleroot/.github/workflows/release.yml.erb b/moduleroot/.github/workflows/release.yml.erb index f48ae376..fa86188e 100644 --- a/moduleroot/.github/workflows/release.yml.erb +++ b/moduleroot/.github/workflows/release.yml.erb @@ -16,7 +16,11 @@ jobs: with: <%- if @configs['with'] -%> <%- @configs['with'].each do |k,v| -%> +<%- if v.is_a?(String) -%> <%= k %>: '<%= v %>' +<%- else -%> + <%= k %>: <%= v %> +<%- end -%> <%- end -%> <%- end -%> <%- if @configs['with'].nil? || !@configs['with'].has_key?('allowed_owner') -%> From 71b96a7984ffcffd646d1993a51dd960775be882 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Wed, 8 May 2024 22:28:37 +0200 Subject: [PATCH 3/3] fixup: even more cleanup --- moduleroot/.github/workflows/ci.yml.erb | 12 +----------- moduleroot/.github/workflows/release.yml.erb | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/moduleroot/.github/workflows/ci.yml.erb b/moduleroot/.github/workflows/ci.yml.erb index e7e6addb..d9c15805 100644 --- a/moduleroot/.github/workflows/ci.yml.erb +++ b/moduleroot/.github/workflows/ci.yml.erb @@ -21,18 +21,9 @@ jobs: name: Puppet <%- if @configs['acceptance_tests'] && Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%> uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 -<%- if @configs['with'] -%> - with: -<%- @configs['with'].each do |k,v| -%> -<%- if v.is_a?(String) -%> - <%= k %>: '<%= v %>' -<%- else -%> - <%= k %>: <%= v %> -<%- end -%> -<%- end -%> -<%- end -%> <%- else -%> uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 +<%- end -%> <%- if @configs['with'] -%> with: <%- @configs['with'].each do |k,v| -%> @@ -43,4 +34,3 @@ jobs: <%- end -%> <%- end -%> <%- end -%> -<%- end -%> diff --git a/moduleroot/.github/workflows/release.yml.erb b/moduleroot/.github/workflows/release.yml.erb index fa86188e..4e2efb97 100644 --- a/moduleroot/.github/workflows/release.yml.erb +++ b/moduleroot/.github/workflows/release.yml.erb @@ -23,7 +23,7 @@ jobs: <%- end -%> <%- end -%> <%- end -%> -<%- if @configs['with'].nil? || !@configs['with'].has_key?('allowed_owner') -%> +<%- unless @configs['with']&.has_key?('allowed_owner') -%> allowed_owner: '<%= @configs[:namespace] %>' <%- end -%> secrets: