-
-
Notifications
You must be signed in to change notification settings - Fork 29
258 lines (252 loc) · 9.33 KB
/
build.yaml
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: build
on:
workflow_dispatch:
push:
branches: ['*']
tags:
- v*
pull_request:
type: [opened, reopened, edited]
schedule:
# run every night at midnight
- cron: '0 0 * * *'
jobs:
unit:
name: 'unit - ${{matrix.name}} - puppet (${{matrix.puppet}})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# note: actions/setup-ruby only allows using a major.minor release of ruby
- ruby: '2.7'
puppet: "7.0"
check: "check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
name: 'static'
- ruby: '2.5'
puppet: "6.0"
check: "parallel_spec"
name: 'spec'
- ruby: '2.7'
puppet: "7.0"
check: "parallel_spec"
name: 'spec'
- ruby: '2.7'
puppet: "7.0"
check: 'strings:generate[,,,,,,"--fail-on-warning"]'
name: "documentation"
env:
CHECK: '${{ matrix.check }}'
PUPPET_GEM_VERSION: '~> ${{ matrix.puppet }}'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby }}'
- name: Bundle prep
run: |
gem install bundler
bundle -v
rm -f Gemfile.lock
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION
gem --version
bundle -v
bundle config path vendor/bundle
bundle config without 'system_tests'
bundle lock
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-
- name: Bundle install
run: |
bundle install --jobs $(nproc) --retry 3
- name: Test
run: |
bundle exec rake $CHECK
unit-python:
name: 'unit - ${{matrix.name}} - python (${{matrix.python}})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# note: actions/setup-python only allows using a major.minor releases
- python: '3.8'
make_target: 'python3'
name: 'bolt tasks'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '${{ matrix.python }}'
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python }}-pip-unit-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python }}-pip-unit-
- name: Python prep
run: |
pip install virtualenv
- name: Test
run: |
make ${{ matrix.make_target }}
integration:
name: 'integration - ${{matrix.name}}'
needs:
- unit
- unit-python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# note: actions/setup-ruby only allows using a major.minor release of ruby
- ruby: '2.7'
name: 'centos7-puppet6'
- ruby: '2.7'
name: 'centos7-puppet7'
- ruby: '2.7'
name: 'rocky8-puppet6'
- ruby: '2.7'
name: 'rocky8-puppet7'
- ruby: '2.7'
name: 'ubuntu18-puppet6'
- ruby: '2.7'
name: 'ubuntu18-puppet7'
- ruby: '2.7'
name: 'ubuntu20-puppet6'
- ruby: '2.7'
name: 'ubuntu20-puppet7'
env:
CHECK: '${{ matrix.check }}'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby }}'
- name: Bundle prep
run: |
gem install bundler
bundle -v
rm -f Gemfile.lock
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION
gem --version
bundle -v
# note: this path is relative to the Gemfile path below
bundle config path vendor/bundle
bundle config without 'system_tests'
# note: using custom gemfile for kitchen tests
bundle config gemfile build/kitchen/Gemfile
bundle lock
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists
- uses: actions/cache@v2
with:
# note: this path is the Gemfile + path from above, so it's different than the base level Gemfile cache
path: build/kitchen/vendor/bundle
key: ${{ runner.os }}-${{ matrix.name }}-${{ matrix.ruby }}-gems-integration-v3-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.name }}-${{ matrix.ruby }}-gems-integration-v3-
- name: Bundle install
run: |
bundle install --jobs $(nproc) --retry 3
- name: Test
run: |
bundle exec kitchen test --debug ${{ matrix.name }}
deploy:
name: 'deploy - forge'
needs:
- unit
- unit-python
- integration
runs-on: ubuntu-latest
# only run deploy on tags that start with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# define a "strategy" here so we can use ruby/puppet as variables below
strategy:
fail-fast: false
matrix:
include:
# note: actions/setup-ruby only allows using a major.minor release of ruby
- ruby: '2.5'
puppet: "6.0"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby }}'
- name: Bundle prep
run: |
gem install bundler
bundle -v
rm -f Gemfile.lock
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION
gem --version
bundle -v
bundle config path vendor/bundle
bundle config without 'system_tests'
bundle lock
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists
- uses: actions/cache@v2
with:
# note: we are using the gems-unit cache here since it's the same and can take
# advantage for the cache we already have from the previous 'unit' job
path: vendor/bundle
key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-
- name: Bundle install
run: |
bundle install --jobs $(nproc) --retry 3
- name: Build and Deploy
env:
# configure secrets here:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
BLACKSMITH_FORGE_PASSWORD: '${{ secrets.PUPPET_FORGE_PASSWORD }}'
# use puppet-blacksmith rake tasks to build and deploy the module
run: |
bundle exec rake module:build
bundle exec rake module:push
slack-notification:
name: Slack notification for failed master builds
if: always()
needs:
- unit
- unit-python
- integration
runs-on: ubuntu-latest
steps:
- name: Workflow conclusion
# this step creates an environment variable WORKFLOW_CONCLUSION and is the most reliable way to check the status of previous jobs
uses: technote-space/workflow-conclusion-action@v2
- name: CI Run Failure Slack Notification
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' && github.ref == 'refs/heads/master' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: puppet
status: FAILED
color: danger