-
Notifications
You must be signed in to change notification settings - Fork 14
175 lines (169 loc) · 5.77 KB
/
beaker.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
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: '.'