|
| 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 |
0 commit comments