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