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
| # This is a generic workflow for Puppet module acceptance operations. | ||
| name: "Module Acceptance" | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs_on: | ||
| description: "The operating system used for the runner." | ||
| required: false | ||
| type: "string" | ||
| flags: | ||
| description: "Additional flags to pass to matrix_from_metadata_v3." | ||
| required: false | ||
| default: '' | ||
| type: "string" | ||
| service_url: | ||
| description: "The service URL to target when provisioning from GCP." | ||
| required: false | ||
| default: 'https://facade-release-6f3kfepqcq-ew.a.run.app/v1/provision' | ||
| type: "string" | ||
| kernel_modules: | ||
| description: "Volume map host kernel /lib/modules into docker container" | ||
| default: true | ||
| type: boolean | ||
| disable_apparmor: | ||
| description: "Disable and stop apparmor" | ||
| default: false | ||
| type: boolean | ||
| ssh-debugging: | ||
| description: Boolean; whether or not to pause for ssh debugging | ||
| required: true | ||
| default: false | ||
| # ENABLE PUPPETCORE. The calling workflow must: | ||
| # - Set a valid PUPPET_FORGE_TOKEN secret on its repository. | ||
| env: | ||
| PUPPET_FORGE_TOKEN: ${{ secrets.PUPPET_FORGE_TOKEN || secrets.PUPPET_FORGE_TOKEN_PUBLIC }} | ||
| BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN || secrets.PUPPET_FORGE_TOKEN_PUBLIC }}" | ||
| SERVICE_URL: ${{ inputs.service_url }} | ||
| jobs: | ||
| setup_matrix: | ||
| name: "Setup Test Matrix" | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| acceptance_matrix: ${{ steps.get-matrix.outputs.matrix }} | ||
| env: | ||
| BUNDLE_WITHOUT: release_prep | ||
| steps: | ||
| - name: "Checkout" | ||
| uses: "actions/checkout@v4" | ||
| - name: "Setup ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "3.1" | ||
| bundler-cache: true | ||
| - name: "Bundle environment" | ||
| run: | | ||
| echo ::group::bundler environment | ||
| bundle env | ||
| echo ::endgroup:: | ||
| - name: Setup Test Matrix | ||
| id: get-matrix | ||
| run: | | ||
| bundle exec matrix_from_metadata_v3 ${{ inputs.flags }} | ||
| acceptance: | ||
| name: "Acceptance tests (${{matrix.platforms.label}}, ${{matrix.collection}})" | ||
| needs: "setup_matrix" | ||
| runs-on: ${{ inputs.runs_on || matrix.platforms.runner }} | ||
| timeout-minutes: 180 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson( needs.setup_matrix.outputs.acceptance_matrix ) }} | ||
| env: | ||
| BUNDLE_WITHOUT: release_prep | ||
| PUPPET_GEM_VERSION: '~> 8.9' | ||
| FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set? | ||
| TWINGATE_PUBLIC_REPO_KEY: ${{ secrets.TWINGATE_PUBLIC_REPO_KEY }} | ||
| steps: | ||
| - name: "Install Twingate" | ||
| uses: "twingate/github-action@v1" | ||
| with: | ||
| service-key: ${{ env.TWINGATE_PUBLIC_REPO_KEY }} | ||
| - name: Fix DNS | ||
| run: | | ||
| echo "=== Remove Azure DNS from eth0 interface ===" | ||
| sudo resolvectl dns eth0 "" | ||
| echo "=== Configure Twingate DNS properly ===" | ||
| sudo resolvectl dns sdwan0 100.95.0.251 100.95.0.252 | ||
| sudo resolvectl domain sdwan0 delivery.puppetlabs.net | ||
| echo "=== Flush DNS cache ===" | ||
| sudo resolvectl flush-caches | ||
| echo "=== Check new configuration ===" | ||
| resolvectl status | ||
| echo "=== Test DNS resolution ===" | ||
| nslookup artifactory.delivery.puppetlabs.net | ||
| - name: "Checkout" | ||
| uses: "actions/checkout@v4" | ||
| - name: "Disable Apparmor" | ||
| if: ${{ inputs.disable_apparmor }} | ||
| run: | | ||
| if command -v apparmor_parser >/dev/null ; then | ||
| sudo find /etc/apparmor.d/ -maxdepth 1 -type f -exec ln -sf {} /etc/apparmor.d/disable/ \; | ||
| sudo apparmor_parser -R /etc/apparmor.d/disable/* || true | ||
| sudo systemctl disable apparmor | ||
| sudo systemctl stop apparmor | ||
| fi | ||
| - name: Start SSH session | ||
| if: ${{ github.event.inputs.ssh-debugging == 'true' }} | ||
| uses: luchihoratiu/debug-via-ssh@main | ||
| with: | ||
| NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} | ||
| SSH_PASS: ${{ secrets.SSH_PASS }} | ||
| - name: "Setup ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "3.1" | ||
| bundler-cache: true | ||
| - name: "Bundle environment" | ||
| run: | | ||
| echo ::group::bundler environment | ||
| bundle env | ||
| echo ::endgroup:: | ||
| - name: "Provision environment" | ||
| run: | | ||
| if [[ "${{ inputs.kernel_modules }}" == "true" ]] && [[ "${{matrix.platforms.provider}}" =~ docker* ]] ; then | ||
| DOCKER_RUN_OPTS="docker_run_opts: {'--volume': '/lib/modules/$(uname -r):/lib/modules/$(uname -r)'}" | ||
| else | ||
| DOCKER_RUN_OPTS='' | ||
| fi | ||
| bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }},$DOCKER_RUN_OPTS]" | ||
| # Redact password | ||
| FILE='spec/fixtures/litmus_inventory.yaml' | ||
| sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true | ||
| - name: "Install Puppet agent" | ||
| run: | | ||
| if [[ "${{ matrix.collection.version }}" ]] ; then | ||
| export PUPPET_VERSION=${{ matrix.collection.version }} | ||
| bundle exec rake 'litmus:install_agent[${{ matrix.collection.collection }}]' | ||
| else | ||
| bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' | ||
| fi | ||
| - name: "Install module" | ||
| run: | | ||
| bundle exec rake 'litmus:install_module' | ||
| - name: Wait as long as the file ${HOME}/pause file is present | ||
| if: ${{ always() && github.event.inputs.ssh-debugging == true }} | ||
| run: | | ||
| while [ -f "${HOME}/pause" ] ; do | ||
| echo "${HOME}/pause present, sleeping for 60 seconds..." | ||
| sleep 60 | ||
| done | ||
| echo "${HOME}/pause absent, continuing workflow." | ||
| - name: "Run acceptance tests" | ||
| run: | | ||
| bundle exec rake 'litmus:acceptance:parallel' | ||
| - name: Wait as long as the file ${HOME}/pause file is present | ||
| if: ${{ always() && github.event.inputs.ssh-debugging == true }} | ||
| run: | | ||
| while [ -f "${HOME}/pause" ] ; do | ||
| echo "${HOME}/pause present, sleeping for 60 seconds..." | ||
| sleep 60 | ||
| done | ||
| echo "${HOME}/pause absent, continuing workflow." | ||
| - name: "Remove test environment" | ||
| if: ${{ always() }} | ||
| continue-on-error: true | ||
| run: | | ||
| if [[ -f spec/fixtures/litmus_inventory.yaml ]]; then | ||
| bundle exec rake 'litmus:tear_down' | ||
| fi | ||