Skip to content

Commit

Permalink
[puppetsync] Clean up for linters
Browse files Browse the repository at this point in the history
Clean up files distributed by puppetsync for various linters.

Also fix a quoting issue in create-github-release action.
  • Loading branch information
silug committed Sep 5, 2024
1 parent 216f83a commit 6d1219b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ jobs:
experimental: false
- label: 'Puppet 8.x'
puppet_version: '~> 8.0'
ruby_version: 3.1
experimental: true
ruby_version: '3.2'
experimental: false
fail-fast: false
env:
PUPPET_VERSION: ${{matrix.puppet.puppet_version}}
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/validate_tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# GitHub Secret variable Type Notes
# ------------------------ -------- ----------------------------------------
# PUPPETFORGE_API_TOKEN Required
# GITLAB_API_PRIVATE_TOKEN Required GitLab token (should have `api` scope)
# NO_SCOPE_GITHUB_TOKEN Required GitHub token (should have no scopes)
# GITLAB_SERVER_URL Optional Specify a GL server other than gitlab.com
# The secure vars will be filtered in GitHub Actions log output, and aren't
# provided to untrusted builds (i.e, triggered by PR from another repository)
#
Expand All @@ -40,21 +38,6 @@ jobs:
--header "Authorization: Bearer ${PUPPETFORGE_API_TOKEN:-default_content_to_cause_401_response}" \
https://forgeapi.puppet.com/v3/users > /dev/null
gitlab:
name: 'GitLab token has scope for developer'
runs-on: ubuntu-latest
env:
GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }}
GITLAB_ORG: ${{ github.event.organization.login }}
steps:
- run: |
GITLAB_API_URL="${GITLAB_API_URL:-https://gitlab.com/api/v4}"
curl -I --http1.1 --fail --silent --show-error \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN" \
"${CURL_CMD[@]}" "${GITLAB_API_URL}/groups/$GITLAB_ORG/audit_events"
github-no-scope:
name: 'No-scope GitHub token has NO scopes'
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Thu Sep 05 2024 Steven Pritchard <[email protected]> - 0.15.0
- [puppetsync] Add EL9 support

* Mon Oct 23 2023 Steven Pritchard <[email protected]> - 0.14.0
- [puppetsync] Add EL9 support

Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-haveged",
"version": "0.14.0",
"version": "0.15.0",
"author": "SIMP Team",
"summary": "Install and manage the HAVEGE daemon.",
"license": "BSD-2-Clause",
Expand All @@ -16,7 +16,7 @@
"dependencies": [
{
"name": "puppet/systemd",
"version_requirement": ">= 4.0.2 < 7.0.0"
"version_requirement": ">= 4.0.2 < 8.0.0"
},
{
"name": "simp/simplib",
Expand Down
69 changes: 40 additions & 29 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# frozen_string_literal: true
#
# ------------------------------------------------------------------------------
# NOTICE: **This file is maintained with puppetsync**
#
# This file is automatically updated as part of a puppet module baseline.
# The next baseline sync will overwrite any local changes made to this file.
# ------------------------------------------------------------------------------

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet'
Expand All @@ -11,29 +18,25 @@
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
module_name = File.basename(File.expand_path(File.join(__FILE__, '../..')))

# Add fixture lib dirs to LOAD_PATH. Work-around for PUP-3336
if Puppet.version < '4.0.0'
Dir["#{fixture_path}/modules/*/lib"].entries.each do |lib_dir|
$LOAD_PATH << lib_dir
end
end

unless ENV.key?('TRUSTED_NODE_DATA')
warn '== WARNING: TRUSTED_NODE_DATA is unset, using TRUSTED_NODE_DATA=yes'
ENV['TRUSTED_NODE_DATA'] = 'yes'
if ENV['PUPPET_DEBUG']
Puppet::Util::Log.level = :debug
Puppet::Util::Log.newdestination(:console)
end

default_hiera_config = <<-DEFAULT_HIERA_CONFIG
default_hiera_config = <<~HIERA_CONFIG
---
:backends:
- "yaml"
:yaml:
:datadir: "stub"
:hierarchy:
- "%{custom_hiera}"
- "%{module_name}"
- "default"
DEFAULT_HIERA_CONFIG
version: 5
hierarchy:
- name: Custom Test Hiera
path: "%{custom_hiera}.yaml"
- name: "%{module_name}"
path: "%{module_name}.yaml"
- name: Common
path: default.yaml
defaults:
data_hash: yaml_data
datadir: "stub"
HIERA_CONFIG

# This can be used from inside your spec tests to set the testable environment.
# You can use this to stub out an ENC.
Expand Down Expand Up @@ -82,9 +85,10 @@ def set_hieradata(hieradata)
RSpec.configure do |c|
# If nothing else...
c.default_facts = {
:production => {
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:concat_basedir => '/tmp'
production: {
#:fqdn => 'production.rspec.test.localdomain',
path: '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
concat_basedir: '/tmp'
}
}

Expand All @@ -110,10 +114,16 @@ def set_hieradata(hieradata)

# rubocop:disable RSpec/BeforeAfterAll
c.before(:all) do
# rubocop:disable Security/YAMLLoad
data = YAML.load(default_hiera_config)
# rubocop:enable Security/YAMLLoad
data[:yaml][:datadir] = File.join(fixture_path, 'hieradata')
data = YAML.safe_load(default_hiera_config)
data.each_key do |key|
next unless data[key].is_a?(Hash)

if data[key][:datadir] == 'stub'
data[key][:datadir] = File.join(fixture_path, 'hieradata')
elsif data[key]['datadir'] == 'stub'
data[key]['datadir'] = File.join(fixture_path, 'hieradata')
end
end

File.open(c.hiera_config, 'w') do |f|
f.write data.to_yaml
Expand All @@ -130,6 +140,7 @@ def set_hieradata(hieradata)
end

# ensure the user running these tests has an accessible environmentpath
Puppet[:digest_algorithm] = 'sha256'
Puppet[:environmentpath] = @spec_global_env_temp
Puppet[:user] = Etc.getpwuid(Process.uid).name
Puppet[:group] = Etc.getgrgid(Process.gid).name
Expand All @@ -152,7 +163,7 @@ def set_hieradata(hieradata)
Dir.glob("#{RSpec.configuration.module_path}/*").each do |dir|
begin
Pathname.new(dir).realpath
rescue StandardError => e
raise "ERROR: The module '#{dir}' is not installed (#{e.message}). Tests cannot continue."
rescue StandardError
raise "ERROR: The module '#{dir}' is not installed. Tests cannot continue."
end
end

0 comments on commit 6d1219b

Please sign in to comment.