beaker: Pass beaker_hcloud_token secret #2
Workflow file for this run
This file contains 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: Puppet | ||
on: | ||
workflow_call: | ||
inputs: | ||
pidfile_workaround: | ||
description: How to apply the systemd PIDFile workaround for acceptance tests, if at all | ||
default: 'false' | ||
required: false | ||
type: string | ||
rubocop: | ||
description: Whether to run Rubocop | ||
default: true | ||
required: false | ||
type: boolean | ||
timeout_minutes: | ||
description: The maximum time (in minutes) for a job to take. | ||
default: 45 | ||
required: false | ||
type: number | ||
working-directory: | ||
description: The working directory where all jobs should be executed. Used for modules in subdirectories like a monorepo or a control repository. | ||
default: '.' | ||
required: false | ||
type: string | ||
cache-version: | ||
description: The cache version to pass to setup-ruby | ||
default: '0' | ||
required: false | ||
type: string | ||
additional_packages: | ||
description: String of additional packages that should be installed | ||
default: '' | ||
required: false | ||
type: string | ||
beaker_hypervisor: | ||
description: The hypervisor beaker will use to start containers/VMs | ||
default: docker | ||
required: false | ||
type: string | ||
beaker_facter: | ||
description: Expand the Beaker matrix based on a fact | ||
default: 'false' | ||
required: false | ||
type: string | ||
domain: | ||
description: The domain that will be used for the beaker instances | ||
default: "example.com" | ||
required: false | ||
type: string | ||
unit_runs_on: | ||
description: the runner group used for unit jobs run on | ||
default: ubuntu-latest | ||
required: false | ||
type: string | ||
acceptance_runs_on: | ||
description: the runner group used for acceptance jobs run on | ||
default: ubuntu-20.04 | ||
required: false | ||
type: string | ||
secrets: | ||
beaker_hcloud_token: | ||
description: token to access the Hetzner Cloud API | ||
required: false | ||
default: '' | ||
env: | ||
BEAKER_HYPERVISOR: ${{ inputs.beaker_hypervisor }} | ||
jobs: | ||
setup_matrix: | ||
defaults: | ||
run: | ||
working-directory: ${{ inputs.working-directory }} | ||
name: Static validations | ||
runs-on: ubuntu-latest | ||
timeout-minutes: ${{ inputs.timeout_minutes }} | ||
outputs: | ||
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} | ||
puppet_beaker_test_matrix: ${{ steps.get-outputs.outputs.puppet_beaker_test_matrix }} | ||
env: | ||
BUNDLE_WITHOUT: development:system_tests:release | ||
PUPPET_GEM_VERSION: "~> 7.0" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: install additional packages | ||
if: ${{ inputs.additional_packages != '' }} | ||
run: sudo apt-get install -y ${{ inputs.additional_packages }} | ||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' | ||
bundler-cache: true | ||
cache-version: ${{ inputs.cache-version }} | ||
working-directory: ${{ inputs.working-directory }} | ||
- name: Run static validations | ||
run: bundle exec rake validate lint check | ||
- name: Run rake rubocop | ||
run: bundle exec rake rubocop | ||
if: ${{ inputs.rubocop }} | ||
- name: Setup Test Matrix | ||
id: get-outputs | ||
run: bundle exec metadata2gha --domain ${{ inputs.domain }} --pidfile-workaround ${{ inputs.pidfile_workaround }} --beaker-facter "${{ inputs.beaker_facter }}" | ||
unit: | ||
defaults: | ||
run: | ||
working-directory: ${{ inputs.working-directory }} | ||
needs: setup_matrix | ||
runs-on: ${{ inputs.unit_runs_on }} | ||
timeout-minutes: ${{ inputs.timeout_minutes }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} | ||
env: | ||
BUNDLE_WITHOUT: development:system_tests:release | ||
PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0" | ||
name: ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: install additional packages | ||
if: ${{ inputs.additional_packages != '' }} | ||
run: sudo apt-get install -y ${{ inputs.additional_packages }} | ||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
cache-version: ${{ inputs.cache-version }} | ||
working-directory: ${{ inputs.working-directory }} | ||
- name: Run tests | ||
run: bundle exec rake parallel_spec | ||
acceptance: | ||
defaults: | ||
run: | ||
working-directory: ${{ inputs.working-directory }} | ||
needs: setup_matrix | ||
runs-on: ${{ inputs.acceptance_runs_on }} | ||
env: | ||
BUNDLE_WITHOUT: development:test:release | ||
BEAKER_HCLOUD_TOKEN: : '${{ secrets.beaker_hcloud_token }}' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{fromJson(needs.setup_matrix.outputs.puppet_beaker_test_matrix)}} | ||
name: "${{ matrix.name }}" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: install additional packages | ||
if: ${{ inputs.additional_packages != '' }} | ||
run: sudo apt-get install -y ${{ inputs.additional_packages }} | ||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' | ||
bundler-cache: true | ||
cache-version: ${{ inputs.cache-version }} | ||
working-directory: ${{ inputs.working-directory }} | ||
- name: Run tests | ||
run: bundle exec rake beaker | ||
env: ${{ matrix.env }} | ||
tests: | ||
needs: | ||
- unit | ||
- acceptance | ||
runs-on: ubuntu-latest | ||
name: Test suite | ||
steps: | ||
- run: echo Test suite completed | ||
# explicitly run at the root dir. In case people set working-directory this will otherwise fail (because this jobs doesn't clone the repo and the subdir doesn't exist) | ||
working-directory: '.' |