Skip to content

Commit aeaa7c9

Browse files
committed
update acceptance testing and add workflow
1 parent ecec68d commit aeaa7c9

28 files changed

+659
-384
lines changed

.fixtures.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ fixtures:
1414
augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core.git'
1515
postgresql: 'https://github.com/puppetlabs/puppetlabs-postgresql.git'
1616
firewall: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
17-
forge_modules:
1817
postgresql:
19-
repo: 'puppetlabs/postgresql'
20-
ref: "9.2.0"
18+
repo: 'https://github.com/puppetlabs/puppetlabs-postgresql.git'
19+
ref: 'v9.2.0'
2120
firewall:
22-
repo: 'puppetlabs/firewall'
23-
ref: "6.0.0"
21+
repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
22+
ref: 'v6.0.0'
2423
symlinks:
2524
puppetdb: '#{source_dir}'

.github/workflows/ci.yml

+40-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: "ci"
22

33
on:
44
pull_request:
5+
types:
6+
- opened
7+
- labeled
8+
- synchronize
59
branches:
610
- "main"
711
paths-ignore:
@@ -11,12 +15,47 @@ on:
1115
- 'CODEOWNERS'
1216
- 'AUTHORS'
1317
workflow_dispatch:
18+
inputs:
19+
debug:
20+
description: "Debug"
21+
type: boolean
22+
required: false
23+
default: true
24+
run_spec:
25+
description: "Run Spec job"
26+
type: boolean
27+
required: false
28+
default: true
29+
run_acceptance:
30+
description: "Run Acceptance job"
31+
type: boolean
32+
required: false
33+
default: false
1434

1535
concurrency:
1636
group: ${{ github.workflow }}-${{ github.ref }}
1737
cancel-in-progress: true
1838

1939
jobs:
40+
Matrix:
41+
uses: ./.github/workflows/matrix.yml
42+
with:
43+
flags: "--exclude-platforms '[\"Ubuntu-18.04\"]'" # TODO: remove after postgres module update
2044
Spec:
21-
uses: ./.github/workflows/module_ci.yml
45+
if: ${{ github.event_name == 'pull_request' || inputs.run_spec == 'true' }}
46+
needs: Matrix
47+
uses: ./.github/workflows/module_spec.yml
2248
secrets: inherit
49+
with:
50+
debug: ${{ github.events.inputs.debug == 'true' || contains(github.event.pull_request.labels.*.name, 'debug') }}
51+
ignore_dependency_check: true # TODO: remove after module updates
52+
matrix: ${{ needs.Matrix.outputs.spec_matrix }}
53+
Acceptance:
54+
if: ${{ github.event_name == 'pull_request' || inputs.run_acceptance == 'true' }}
55+
needs: [ Matrix, Spec ]
56+
uses: ./.github/workflows/module_acceptance.yml
57+
secrets: inherit
58+
with:
59+
debug: ${{ github.events.inputs.debug == 'true' || contains(github.event.pull_request.labels.*.name, 'debug') }}
60+
matrix: ${{ needs.Matrix.outputs.acceptance_matrix }}
61+
runs_on: ubuntu-20.04 # TODO: cgroupv1 containers do not provision on ubuntu-latest

.github/workflows/matrix.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
on:
3+
workflow_call:
4+
inputs:
5+
runs_on:
6+
description: "The operating system used for the runner."
7+
required: false
8+
default: "ubuntu-latest"
9+
type: "string"
10+
flags:
11+
description: "Additional flags to pass to matrix_from_metadata_v2."
12+
required: false
13+
default: ''
14+
type: "string"
15+
outputs:
16+
spec_matrix:
17+
description: "Spec matrix from metadata"
18+
value: ${{ jobs.generate-json-matrix.outputs.spec_matrix }}
19+
acceptance_matrix:
20+
description: "Acceptance matrix from metadata"
21+
value: ${{ jobs.generate-json-matrix.outputs.acceptance_matrix }}
22+
23+
jobs:
24+
generate-json-matrix:
25+
name: Generate
26+
runs-on: ${{ inputs.runs_on }}
27+
outputs:
28+
spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }}
29+
acceptance_matrix: ${{ steps.get-matrix.outputs.matrix }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
35+
- name: Activate Ruby 2.7
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: "2.7"
39+
bundler-cache: true
40+
- name: Setup Test Matrix
41+
id: get-matrix
42+
run: |
43+
bundle exec matrix_from_metadata_v2 ${{ inputs.flags }}
44+
echo ::group::spec matrix
45+
sed -n 's/^spec_matrix=\(.*\)/\1/p' $GITHUB_OUTPUT | jq
46+
echo ::endgroup::
47+
echo ::group::acceptance matrix
48+
sed -n 's/^matrix=\(.*\)/\1/p' $GITHUB_OUTPUT | jq
49+
echo ::endgroup::
+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# This is a generic workflow for Puppet module acceptance operations.
2+
name: "Module Acceptance"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
matrix:
8+
description: "JSON matrix"
9+
type: "string"
10+
required: true
11+
debug:
12+
description: "Run jobs with debug steps and flags enabled"
13+
type: "boolean"
14+
required: false
15+
default: false
16+
puppet_version:
17+
description: "Version of Puppet used to run tests"
18+
type: "string"
19+
required: false
20+
default: "~> 7.24"
21+
ruby_version:
22+
description: "Version of Ruby to install"
23+
type: "string"
24+
required: false
25+
default: "2.7"
26+
runs_on:
27+
description: "The operating system used for the runner"
28+
type: "string"
29+
required: false
30+
default: "ubuntu-latest"
31+
32+
jobs:
33+
Test:
34+
name: "Test ${{ matrix.platforms.label }} with ${{ matrix.collection }}"
35+
runs-on: ${{ inputs.runs_on }}
36+
strategy:
37+
fail-fast: false
38+
matrix: ${{ fromJson(inputs.matrix) }}
39+
env:
40+
PUPPET_GEM_VERSION: ${{ inputs.puppet_version }}
41+
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main'
42+
BOLT_GEM: 1
43+
steps:
44+
- name: Checkout Source
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 1
48+
49+
- name: Activate Ruby ${{ inputs.ruby_version }}
50+
uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: ${{ inputs.ruby_version }}
53+
bundler-cache: true
54+
55+
- name: Debug
56+
if: ${{ inputs.debug == true }}
57+
run: |
58+
echo ::group::bundler environment
59+
bundle env
60+
echo ::endgroup::
61+
echo ::group::docker info
62+
docker info
63+
echo ::endgroup::
64+
echo "RSPEC_DEBUG=1" >> $GITHUB_ENV
65+
echo "DEBUG=1" >> $GITHUB_ENV
66+
67+
- name: Cache fixture modules
68+
id: cache-fixtures
69+
uses: actions/cache@v4
70+
env:
71+
cache-name: cache-fixtures-modules
72+
with:
73+
path: spec/fixtures/modules
74+
key: test-${{ env.cache-name }}-${{ hashFiles('metadata.json', '.fixtures.yml') }}
75+
restore-keys: |
76+
test-${{ env.cache-name }}-
77+
test-
78+
79+
- name: Provision test environment
80+
timeout-minutes: 10
81+
run: |
82+
bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
83+
FILE='spec/fixtures/litmus_inventory.yaml'
84+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
85+
if [ "${{ inputs.debug }}" == "true" ] ; then
86+
while read CN ; do
87+
echo ::group::docker container $CN
88+
docker inspect "$CN"
89+
echo ::endgroup::
90+
done < <(docker ps --format '{{.Names}}')
91+
fi
92+
93+
- name: Install agent
94+
run: |
95+
echo ::group::agent
96+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
97+
echo ::endgroup::
98+
99+
- name: Install module
100+
run: bundle exec rake 'litmus:install_module'
101+
102+
- name: Run acceptance tests
103+
id: run-acceptance
104+
timeout-minutes: 15
105+
run: bundle exec rake 'litmus:acceptance'
106+
107+
- name: Failure Logs
108+
if: ${{ failure() && steps.run-acceptance.conclusion == 'failure' }}
109+
continue-on-error: true
110+
run: |
111+
echo ::group::last 100 lines in runner journal
112+
journalctl -n 100
113+
echo ::endgroup::
114+
echo ::group::last 100 lines in container journal
115+
bundle exec bolt command run 'journalctl -n 100' -t all -i spec/fixtures/litmus_inventory.yaml
116+
echo ::endgroup::
117+
echo ::group::last 50 lines of puppetlabs logs
118+
bundle exec bolt command run 'tail -n 50 /var/log/puppetlabs/*/*.log' -t all -i spec/fixtures/litmus_inventory.yaml
119+
echo ::endgroup::
120+
121+
- name: Tear down
122+
if: ${{ always() }}
123+
continue-on-error: true
124+
run: |
125+
if [[ -f spec/fixtures/litmus_inventory.yaml ]]; then
126+
bundle exec rake 'litmus:tear_down'
127+
fi

.github/workflows/module_ci.yml

-86
This file was deleted.

0 commit comments

Comments
 (0)