Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 1ef7457

Browse files
committed
Add github action to run pdk validate
1 parent 1792de2 commit 1ef7457

File tree

2 files changed

+105
-73
lines changed

2 files changed

+105
-73
lines changed

.github/workflows/pdk-test-unit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,31 @@ on:
55
- pull_request
66

77
jobs:
8+
validating:
9+
runs-on: self-hosted-novum
10+
steps:
11+
- name: Clone repository
12+
uses: actions/checkout@v2
13+
14+
- name: Run pdk validate
15+
uses: puppets-epic-show-theatre/action-pdk-validate@v1
16+
with:
17+
# [optional]
18+
# A string indicating the Puppet version to validate against, such as "5.4.2" or "5.5".
19+
puppet-version: "5.5"
20+
821
testing:
922
runs-on: self-hosted-novum
23+
if: always()
24+
needs:
25+
- validating
1026
steps:
1127
- name: Clone repository
1228
uses: actions/checkout@v2
1329

1430
- name: Run unit tests
1531
uses: puppets-epic-show-theatre/action-pdk-test-unit@v1
32+
# added because there are open ended dependencies version requirements in metadata.json
1633
with:
1734
# [optional]
1835
# A string indicating the Puppet version to validate against, such as "5.4.2" or "5.5".

spec/classes/github_actions_runner_spec.rb

Lines changed: 88 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,84 @@
66
let(:facts) { os_facts }
77
let(:params) do
88
{
9-
:instances => { 'first_runner' => { 'labels' => ['test_label1', 'test_label2'], 'repo_name' => 'test_repo'}}, }
9+
'instances' => {
10+
'first_runner' => {
11+
'labels' => ['test_label1', 'test_label2'],
12+
'repo_name' => 'test_repo',
13+
},
14+
},
15+
}
1016
end
1117

1218
it { is_expected.to compile.with_all_deps }
1319
it { is_expected.to contain_class('github_actions_runner') }
1420

1521
context 'is expected to create a github_actions_runner root directory' do
1622
it do
17-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0').with({
23+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0').with(
1824
'ensure' => 'directory',
1925
'owner' => 'root',
2026
'group' => 'root',
2127
'mode' => '0644',
22-
})
28+
)
2329
end
2430
end
2531

2632
context 'is expected to create a github_actions_runner a new root directory' do
2733
let(:params) do
28-
super().merge({ 'base_dir_name' => '/tmp/actions-runner'})
34+
super().merge('base_dir_name' => '/tmp/actions-runner')
2935
end
36+
3037
it do
31-
is_expected.to contain_file('/tmp/actions-runner-2.272.0').with({
38+
is_expected.to contain_file('/tmp/actions-runner-2.272.0').with(
3239
'ensure' => 'directory',
3340
'owner' => 'root',
3441
'group' => 'root',
3542
'mode' => '0644',
36-
})
43+
)
3744
end
3845
end
3946

4047
context 'is expected to create a github_actions_runner root directory with test user' do
4148
let(:params) do
42-
super().merge({ 'user' => 'test_user',
43-
'group' => 'test_group'})
49+
super().merge('user' => 'test_user',
50+
'group' => 'test_group')
4451
end
52+
4553
it do
46-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0').with({
54+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0').with(
4755
'ensure' => 'directory',
4856
'owner' => 'test_user',
4957
'group' => 'test_group',
5058
'mode' => '0644',
51-
})
59+
)
5260
end
5361
end
5462

5563
context 'is expected to create a github_actions_runner instance directory' do
5664
it do
57-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner').with({
65+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner').with(
5866
'ensure' => 'directory',
5967
'owner' => 'root',
6068
'group' => 'root',
6169
'mode' => '0644',
62-
})
70+
)
6371
end
6472
end
6573

6674
context 'is expected to create a github_actions_runner instance directory with test user' do
6775
let(:params) do
68-
super().merge({ 'user' => 'test_user',
69-
'group' => 'test_group'})
76+
super().merge('user' => 'test_user',
77+
'group' => 'test_group')
7078
end
79+
7180
it do
72-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner').with({
81+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner').with(
7382
'ensure' => 'directory',
7483
'owner' => 'test_user',
7584
'group' => 'test_group',
7685
'mode' => '0644',
77-
})
86+
)
7887
end
7988
end
8089

@@ -86,127 +95,131 @@
8695

8796
context 'is expected to contain archive' do
8897
it do
89-
is_expected.to contain_archive("first_runner-actions-runner-linux-x64-2.272.0.tar.gz").with({
98+
is_expected.to contain_archive('first_runner-actions-runner-linux-x64-2.272.0.tar.gz').with(
9099
'ensure' => 'present',
91100
'user' => 'root',
92101
'group' => 'root',
93-
})
102+
)
94103
end
95104
end
96105

97106
context 'is expected to contain archive with test package and test url' do
98107
let(:params) do
99-
super().merge({ 'package_name' => 'test_package',
100-
'package_ensure' => '9.9.9',
101-
'repository_url' => 'https://test_url'})
108+
super().merge('package_name' => 'test_package',
109+
'package_ensure' => '9.9.9',
110+
'repository_url' => 'https://test_url')
102111
end
112+
103113
it do
104-
is_expected.to contain_archive("first_runner-test_package-9.9.9.tar.gz").with({
114+
is_expected.to contain_archive('first_runner-test_package-9.9.9.tar.gz').with(
105115
'ensure' => 'present',
106116
'user' => 'root',
107117
'group' => 'root',
108-
'source' => 'https://test_url/v9.9.9/test_package-9.9.9.tar.gz'
109-
})
118+
'source' => 'https://test_url/v9.9.9/test_package-9.9.9.tar.gz',
119+
)
110120
end
111121
end
112122

113123
context 'is expected to contain an ownership exec' do
114124
it do
115-
is_expected.to contain_exec('first_runner-ownership').with({
125+
is_expected.to contain_exec('first_runner-ownership').with(
116126
'user' => 'root',
117127
'command' => '/bin/chown -R root:root /some_dir/actions-runner-2.272.0/first_runner',
118-
})
128+
)
119129
end
120130
end
121131

122132
context 'is expected to contain a Run exec' do
123133
it do
124-
is_expected.to contain_exec('first_runner-run_configure_install_runner.sh').with({
134+
is_expected.to contain_exec('first_runner-run_configure_install_runner.sh').with(
125135
'user' => 'root',
126136
'command' => '/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh',
127-
})
137+
)
128138
end
129139
end
130140

131141
context 'is expected to create a github_actions_runner installation script' do
132142
it do
133-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with({
143+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with(
134144
'ensure' => 'present',
135145
'owner' => 'root',
136146
'group' => 'root',
137147
'mode' => '0755',
138-
})
148+
)
139149
end
140150
end
141151

142152
context 'is expected to create a github_actions_runner installation script with test version' do
143153
let(:params) do
144-
super().merge({ 'package_ensure' => '9.9.9'})
154+
super().merge('package_ensure' => '9.9.9')
145155
end
156+
146157
it do
147-
is_expected.to contain_file('/some_dir/actions-runner-9.9.9/first_runner/configure_install_runner.sh').with({
158+
is_expected.to contain_file('/some_dir/actions-runner-9.9.9/first_runner/configure_install_runner.sh').with(
148159
'ensure' => 'present',
149160
'owner' => 'root',
150161
'group' => 'root',
151162
'mode' => '0755',
152-
})
163+
)
153164
end
154165
end
155166

156167
context 'is expected to create a github_actions_runner installation script with config in content' do
157168
it do
158-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/\/some_dir\/actions-runner-2.272.0\/first_runner\/config.sh/)
169+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{/some_dir/actions-runner-2.272.0/first_runner/config.sh})
159170
end
160171
end
161172

162173
context 'is expected to create a github_actions_runner installation script with github org in content' do
163174
it do
164-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/https:\/\/github.com\/github_org\/test_repo/)
175+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{https://github.com/github_org/test_repo})
165176
end
166177
end
167178

168179
context 'is expected to create a github_actions_runner installation script with test_org in content ' do
169180
let(:params) do
170-
super().merge({ 'org_name' => 'test_org'})
181+
super().merge('org_name' => 'test_org')
171182
end
183+
172184
it do
173-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/https:\/\/github.com\/test_org\/test_repo/)
185+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{https://github.com/test_org/test_repo})
174186
end
175187
end
176188

177189
context 'is expected to create a github_actions_runner installation script with labels in content' do
178190
it do
179-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/test_label1,test_label2/)
191+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{test_label1,test_label2})
180192
end
181193
end
182194

183195
context 'is expected to create a github_actions_runner installation script with PAT in content' do
184196
it do
185-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/authorization: token PAT/)
197+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{authorization: token PAT})
186198
end
187199
end
188200

189201
context 'is expected to create a github_actions_runner installation script with test_PAT in content' do
190202
let(:params) do
191-
super().merge({ 'personal_access_token' => 'test_PAT'})
203+
super().merge('personal_access_token' => 'test_PAT')
192204
end
205+
193206
it do
194-
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(/authorization: token test_PAT/)
207+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with_content(%r{authorization: token test_PAT})
195208
end
196209
end
197210

198211
context 'is expected to create a github_actions_runner installation with proxy settings in systemd globally in init.pp' do
199212
let(:params) do
200213
super().merge(
201-
'http_proxy' => 'http://proxy.local',
202-
'https_proxy' => 'http://proxy.local',
203-
'no_proxy' => 'example.com',
204-
'instances' => {
205-
'first_runner' => {
206-
'labels' => ['test_label1'],
207-
'repo_name' => 'test_repo',
208-
},
209-
},
214+
'http_proxy' => 'http://proxy.local',
215+
'https_proxy' => 'http://proxy.local',
216+
'no_proxy' => 'example.com',
217+
'instances' => {
218+
'first_runner' => {
219+
'labels' => ['test_label1'],
220+
'repo_name' => 'test_repo',
221+
},
222+
},
210223
)
211224
end
212225

@@ -220,16 +233,16 @@
220233
context 'is expected to create a github_actions_runner installation with proxy settings in systemd globally in init.pp overwriting in a instance' do
221234
let(:params) do
222235
super().merge(
223-
'http_proxy' => 'http://proxy.local',
224-
'https_proxy' => 'http://proxy.local',
225-
'no_proxy' => 'example.com',
226-
'instances' => {
227-
'first_runner' => {
228-
'labels' => ['test_label1'],
229-
'repo_name' => 'test_repo',
230-
'http_proxy' => 'http://newproxy.local',
231-
},
232-
},
236+
'http_proxy' => 'http://proxy.local',
237+
'https_proxy' => 'http://proxy.local',
238+
'no_proxy' => 'example.com',
239+
'instances' => {
240+
'first_runner' => {
241+
'labels' => ['test_label1'],
242+
'repo_name' => 'test_repo',
243+
'http_proxy' => 'http://newproxy.local',
244+
},
245+
},
233246
)
234247
end
235248

@@ -243,14 +256,15 @@
243256
context 'is expected to create a github_actions_runner installation with proxy settings in systemd' do
244257
let(:params) do
245258
super().merge(
246-
'instances' => {
247-
'first_runner' => {
248-
'labels' => ['test_label1'],
249-
'repo_name' => 'test_repo',
250-
'http_proxy' => 'http://proxy.local',
251-
'https_proxy' => 'http://proxy.local',
252-
'no_proxy' => 'example.com'},
253-
},
259+
'instances' => {
260+
'first_runner' => {
261+
'labels' => ['test_label1'],
262+
'repo_name' => 'test_repo',
263+
'http_proxy' => 'http://proxy.local',
264+
'https_proxy' => 'http://proxy.local',
265+
'no_proxy' => 'example.com',
266+
},
267+
},
254268
)
255269
end
256270

@@ -264,11 +278,12 @@
264278
context 'is expected to create a github_actions_runner installation without proxy settings in systemd' do
265279
let(:params) do
266280
super().merge(
267-
'instances' => {
268-
'first_runner' => {
269-
'labels' => ['test_label1'],
270-
'repo_name' => 'test_repo'},
271-
},
281+
'instances' => {
282+
'first_runner' => {
283+
'labels' => ['test_label1'],
284+
'repo_name' => 'test_repo',
285+
},
286+
},
272287
)
273288
end
274289

0 commit comments

Comments
 (0)