Skip to content

Commit b39b1b5

Browse files
authored
Merge pull request #274 from binford2k/ci
Forgot to add the test workflows
2 parents fedd8f5 + 3fadadc commit b39b1b5

File tree

3 files changed

+315
-0
lines changed

3 files changed

+315
-0
lines changed

.github/workflows/pr_test.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: "PR Testing"
2+
3+
on: [pull_request]
4+
5+
6+
env:
7+
8+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
9+
HONEYCOMB_DATASET: litmus tests
10+
11+
jobs:
12+
setup_matrix:
13+
name: "Setup Test Matrix"
14+
runs-on: ubuntu-20.04
15+
outputs:
16+
matrix: ${{ steps.get-matrix.outputs.matrix }}
17+
18+
steps:
19+
20+
- name: "Honeycomb: Start recording"
21+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
22+
with:
23+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
24+
dataset: ${{ env.HONEYCOMB_DATASET }}
25+
job-status: ${{ job.status }}
26+
27+
- name: "Honeycomb: Start first step"
28+
run: |
29+
echo STEP_ID=setup-environment >> $GITHUB_ENV
30+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
31+
- name: Checkout Source
32+
uses: actions/checkout@v2
33+
if: ${{ github.repository_owner == 'puppetlabs' }}
34+
35+
- name: Activate Ruby 2.7
36+
uses: ruby/setup-ruby@v1
37+
if: ${{ github.repository_owner == 'puppetlabs' }}
38+
with:
39+
ruby-version: "2.7"
40+
bundler-cache: true
41+
42+
- name: Print bundle environment
43+
if: ${{ github.repository_owner == 'puppetlabs' }}
44+
run: |
45+
echo ::group::bundler environment
46+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
47+
echo ::endgroup::
48+
49+
- name: "Honeycomb: Record Setup Environment time"
50+
if: ${{ github.repository_owner == 'puppetlabs' }}
51+
run: |
52+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
53+
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
54+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
55+
- name: Run validation steps
56+
run: |
57+
bundle exec rake validate
58+
if: ${{ github.repository_owner == 'puppetlabs' }}
59+
60+
- name: Setup Acceptance Test Matrix
61+
id: get-matrix
62+
run: |
63+
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
64+
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2
65+
else
66+
echo "::set-output name=matrix::{}"
67+
fi
68+
69+
- name: "Honeycomb: Record Setup Test Matrix time"
70+
if: ${{ always() }}
71+
run: |
72+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
73+
Acceptance:
74+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
75+
needs:
76+
- setup_matrix
77+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
78+
79+
runs-on: ubuntu-20.04
80+
strategy:
81+
fail-fast: false
82+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
83+
84+
env:
85+
BUILDEVENT_FILE: '../buildevents.txt'
86+
87+
steps:
88+
- run: |
89+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
90+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
91+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
92+
93+
- name: "Honeycomb: Start recording"
94+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
95+
with:
96+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
97+
dataset: ${{ env.HONEYCOMB_DATASET }}
98+
job-status: ${{ job.status }}
99+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
100+
101+
- name: "Honeycomb: start first step"
102+
run: |
103+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
104+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
105+
- name: Checkout Source
106+
uses: actions/checkout@v2
107+
108+
- name: Activate Ruby 2.7
109+
uses: ruby/setup-ruby@v1
110+
with:
111+
ruby-version: "2.7"
112+
bundler-cache: true
113+
114+
- name: Print bundle environment
115+
run: |
116+
echo ::group::bundler environment
117+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
118+
echo ::endgroup::
119+
120+
- name: "Honeycomb: Record Setup Environment time"
121+
if: ${{ always() }}
122+
run: |
123+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
124+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
125+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
126+
- name: Provision test environment
127+
run: |
128+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
129+
echo ::group::=== REQUEST ===
130+
cat request.json || true
131+
echo
132+
echo ::endgroup::
133+
echo ::group::=== INVENTORY ===
134+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
135+
then
136+
FILE='spec/fixtures/litmus_inventory.yaml'
137+
elif [ -f 'inventory.yaml' ];
138+
then
139+
FILE='inventory.yaml'
140+
fi
141+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
142+
echo ::endgroup::
143+
144+
- name: Install agent
145+
run: |
146+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
147+
148+
- name: Install module
149+
run: |
150+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
151+
152+
- name: "Honeycomb: Record deployment times"
153+
if: ${{ always() }}
154+
run: |
155+
echo ::group::honeycomb step
156+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
157+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
158+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
159+
echo ::endgroup::
160+
- name: Run acceptance tests
161+
run: |
162+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
163+
164+
- name: "Honeycomb: Record acceptance testing times"
165+
if: ${{ always() }}
166+
run: |
167+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
168+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
169+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
170+
- name: Remove test environment
171+
if: ${{ always() }}
172+
continue-on-error: true
173+
run: |
174+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
175+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
176+
echo ::group::=== REQUEST ===
177+
cat request.json || true
178+
echo
179+
echo ::endgroup::
180+
fi
181+
182+
- name: "Honeycomb: Record removal times"
183+
if: ${{ always() }}
184+
run: |
185+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

.github/workflows/spec.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: "Spec Tests"
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
pull_request:
8+
9+
10+
env:
11+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
12+
HONEYCOMB_DATASET: litmus tests
13+
14+
jobs:
15+
setup_matrix:
16+
name: "Setup Test Matrix"
17+
runs-on: ubuntu-20.04
18+
outputs:
19+
spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }}
20+
21+
steps:
22+
23+
- name: "Honeycomb: Start recording"
24+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
25+
with:
26+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
27+
dataset: ${{ env.HONEYCOMB_DATASET }}
28+
job-status: ${{ job.status }}
29+
30+
- name: "Honeycomb: Start first step"
31+
run: |
32+
echo STEP_ID=setup-environment >> $GITHUB_ENV
33+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
34+
- name: Checkout Source
35+
uses: actions/checkout@v2
36+
if: ${{ github.repository_owner == 'puppetlabs' }}
37+
38+
- name: Activate Ruby 2.7
39+
uses: ruby/setup-ruby@v1
40+
if: ${{ github.repository_owner == 'puppetlabs' }}
41+
with:
42+
ruby-version: "2.7"
43+
bundler-cache: true
44+
45+
- name: Print bundle environment
46+
if: ${{ github.repository_owner == 'puppetlabs' }}
47+
run: |
48+
echo ::group::bundler environment
49+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
50+
echo ::endgroup::
51+
- name: "Honeycomb: Record Setup Environment time"
52+
if: ${{ github.repository_owner == 'puppetlabs' }}
53+
run: |
54+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
55+
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
56+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
57+
- name: Run Static & Syntax Tests
58+
if: ${{ github.repository_owner == 'puppetlabs' }}
59+
run: |
60+
buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks' -- bundle exec rake validate lint check rubocop
61+
62+
- name: Setup Spec Test Matrix
63+
id: get-matrix
64+
run: |
65+
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
66+
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2
67+
else
68+
echo "::set-output name=spec_matrix::{}"
69+
fi
70+
- name: "Honeycomb: Record Setup Test Matrix time"
71+
if: ${{ always() }}
72+
run: |
73+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
74+
Spec:
75+
name: "Spec Tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})"
76+
needs:
77+
- setup_matrix
78+
if: ${{ needs.setup_matrix.outputs.spec_matrix != '{}' }}
79+
80+
runs-on: ubuntu-20.04
81+
strategy:
82+
fail-fast: false
83+
matrix: ${{fromJson(needs.setup_matrix.outputs.spec_matrix)}}
84+
85+
env:
86+
BUILDEVENT_FILE: '../buildevents.txt'
87+
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
88+
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main'
89+
90+
steps:
91+
- run: |
92+
echo "SANITIZED_PUPPET_VERSION=$(echo '${{ matrix.puppet_version }}' | sed 's/~> //g')" >> $GITHUB_ENV
93+
94+
- run: |
95+
echo 'puppet_version=${{ env.SANITIZED_PUPPET_VERSION }}' >> $BUILDEVENT_FILE
96+
- name: "Honeycomb: Start first step"
97+
run: |
98+
echo "STEP_ID=${{ env.SANITIZED_PUPPET_VERSION }}-spec" >> $GITHUB_ENV
99+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
100+
101+
- name: "Honeycomb: Start recording"
102+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
103+
with:
104+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
105+
dataset: ${{ env.HONEYCOMB_DATASET }}
106+
job-status: ${{ job.status }}
107+
matrix-key: ${{ env.SANITIZED_PUPPET_VERSION }}
108+
- name: Checkout Source
109+
uses: actions/checkout@v2
110+
111+
- name: "Activate Ruby ${{ matrix.ruby_version }}"
112+
uses: ruby/setup-ruby@v1
113+
with:
114+
ruby-version: ${{matrix.ruby_version}}
115+
bundler-cache: true
116+
117+
- name: Print bundle environment
118+
run: |
119+
echo ::group::bundler environment
120+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
121+
echo ::endgroup::
122+
123+
124+
- name: Run parallel_spec tests
125+
run: |
126+
buildevents cmd $TRACE_ID $STEP_ID 'rake parallel_spec Puppet ${{ matrix.puppet_version }}, Ruby ${{ matrix.ruby_version }}' -- bundle exec rake parallel_spec

.sync.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ spec/spec_helper.rb:
2424
unmanaged: false
2525
.github/workflows/release.yml:
2626
unmanaged: false
27+
.github/workflows/pr_test.yml:
28+
unmanaged: false
29+
.github/workflows/spec.yml:
30+
unmanaged: false
2731

0 commit comments

Comments
 (0)