(CAT-2383) PDK update for puppetcore changes #224
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Integration Testing" | |
on: | |
pull_request: | |
branches: | |
- "main" | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
setup_matrix: | |
name: "Setup Test Matrix" | |
runs-on: ubuntu-24.04 | |
outputs: | |
matrix: ${{ steps.get-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v3 | |
if: ${{ github.repository_owner == 'puppetlabs' }} | |
- name: Activate Ruby 3.2 | |
uses: ruby/setup-ruby@v1 | |
if: ${{ github.repository_owner == 'puppetlabs' }} | |
with: | |
ruby-version: "3.2" | |
bundler-cache: true | |
- name: Print bundle environment | |
if: ${{ github.repository_owner == 'puppetlabs' }} | |
run: | | |
echo ::group::bundler environment | |
bundle env | |
echo ::endgroup:: | |
- name: Setup Integration Test Matrix | |
id: get-matrix | |
run: | | |
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then | |
echo "matrix={'platform':['ubuntu-2204-lts'],'collection':['puppetcore8-nightly']}" >> $GITHUB_OUTPUT | |
else | |
echo "matrix={}" >> $GITHUB_OUTPUT | |
fi | |
Integration: | |
needs: | |
- setup_matrix | |
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} | |
# env: | |
# PUPPET_GEM_VERSION: '~> 7.24' | |
# FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set? | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v3 | |
- name: Activate Ruby 3.2 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.2" | |
bundler-cache: true | |
- name: Print bundle environment | |
run: | | |
echo ::group::bundler environment | |
bundle env | |
echo ::endgroup:: | |
- name: Create the fixtures directory | |
run: | | |
bundle exec rake spec_prep | |
- name: Provision test environment | |
run: | | |
bundle exec bolt --modulepath spec/fixtures/modules plan run ntp::acceptance::provision_integration image=${{ matrix.platform }} | |
# Redact password | |
FILE='spec/fixtures/litmus_inventory.yaml' | |
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true | |
- name: Inject PE vars into inventory (Ruby, safe) | |
shell: bash | |
run: | | |
FILE='spec/fixtures/litmus_inventory.yaml' | |
# Use Ruby to safely modify YAML: redact ssh.password and add PE Postgres version under vars | |
ruby - "$FILE" <<'RUBY' | |
require 'yaml' | |
file = ARGV[0] | |
inv = YAML.load_file(file) | |
unless inv.is_a?(Hash) && inv.key?('groups') | |
raise "Unexpected inventory structure: #{inv.class}" | |
end | |
(inv['groups'] || []).each do |g| | |
(g['targets'] || []).each do |t| | |
# Redact SSH password if present | |
if (ssh = t.dig('config', 'ssh')) | |
ssh['password'] = '[redacted]' if ssh.key?('password') | |
end | |
# Ensure vars exist and inject desired PE param | |
t['vars'] ||= {} | |
t['vars']['puppet_enterprise::params::postgres_version'] = '13' | |
end | |
end | |
File.write(file, inv.to_yaml) | |
RUBY | |
echo "::group::litmus_inventory.yaml (after injection)" | |
cat "$FILE" | |
echo "::endgroup::" | |
- name: Install PE | |
run: | | |
bundle exec bolt --modulepath spec/fixtures/modules -i ./spec/fixtures/litmus_inventory.yaml plan run ntp::acceptance::pe_server | |
- name: Install Agents | |
run: | | |
bundle exec bolt --modulepath spec/fixtures/modules -i ./spec/fixtures/litmus_inventory.yaml plan run ntp::acceptance::pe_agent | |
- name: Install module | |
run: | | |
bundle exec rake 'litmus:install_module' | |
- name: Run integration tests | |
run: | | |
bundle exec rake ntp:integration | |
- name: Remove test environment | |
if: ${{ always() }} | |
continue-on-error: true | |
run: | | |
bundle exec rake 'litmus:tear_down' |