Skip to content

Commit b0fbbcc

Browse files
author
jordanbreen28
committed
(Maint) - Add nightly and PR testing
Prior to this commit, the puppetlabs-sqlserver module lacked the appropriate GHA workflows that are responsible for testing our modules. This commit introduces two new files (.github/workflows/nightly.yml and .github/workflows/pr_test.yml) which will implement two github actions, so that the testing for this module is more inline and consistent with the rest of our supported modules.
1 parent 37b0308 commit b0fbbcc

File tree

2 files changed

+393
-0
lines changed

2 files changed

+393
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: "nightly"
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
8+
env:
9+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
10+
HONEYCOMB_DATASET: litmus tests
11+
12+
jobs:
13+
setup_matrix:
14+
if: ${{ github.repository_owner == 'puppetlabs' }}
15+
name: "Setup Test Matrix"
16+
runs-on: ubuntu-20.04
17+
outputs:
18+
matrix: ${{ steps.get-matrix.outputs.matrix }}
19+
20+
steps:
21+
22+
- name: "Honeycomb: Start recording"
23+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
24+
with:
25+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
26+
dataset: ${{ env.HONEYCOMB_DATASET }}
27+
job-status: ${{ job.status }}
28+
29+
- name: "Honeycomb: Start first step"
30+
run: |
31+
echo STEP_ID=setup-environment >> $GITHUB_ENV
32+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
33+
- name: Checkout Source
34+
uses: actions/checkout@v2
35+
if: ${{ github.repository_owner == 'puppetlabs' }}
36+
37+
- name: Activate Ruby 2.7
38+
uses: ruby/setup-ruby@v1
39+
if: ${{ github.repository_owner == 'puppetlabs' }}
40+
with:
41+
ruby-version: "2.7"
42+
bundler-cache: true
43+
44+
- name: Print bundle environment
45+
if: ${{ github.repository_owner == 'puppetlabs' }}
46+
run: |
47+
echo ::group::bundler environment
48+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
49+
echo ::endgroup::
50+
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: Setup Acceptance Test Matrix
58+
id: get-matrix
59+
if: ${{ github.repository_owner == 'puppetlabs' }}
60+
run: |
61+
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
62+
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2
63+
else
64+
echo "::set-output name=matrix::{}"
65+
fi
66+
67+
- name: "Honeycomb: Record Setup Test Matrix time"
68+
if: ${{ always() }}
69+
run: |
70+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
71+
Acceptance:
72+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
73+
needs:
74+
- setup_matrix
75+
76+
runs-on: ubuntu-20.04
77+
strategy:
78+
fail-fast: false
79+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
80+
81+
env:
82+
BUILDEVENT_FILE: '../buildevents.txt'
83+
84+
steps:
85+
- run: |
86+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
87+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
88+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
89+
90+
91+
- name: "Honeycomb: Start recording"
92+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
93+
with:
94+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
95+
dataset: ${{ env.HONEYCOMB_DATASET }}
96+
job-status: ${{ job.status }}
97+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
98+
99+
- name: "Honeycomb: start first step"
100+
run: |
101+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
102+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
103+
104+
- name: Checkout Source
105+
uses: actions/checkout@v2
106+
107+
- name: Activate Ruby 2.7
108+
uses: ruby/setup-ruby@v1
109+
with:
110+
ruby-version: "2.7"
111+
bundler-cache: true
112+
113+
- name: Print bundle environment
114+
run: |
115+
echo ::group::bundler environment
116+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
117+
echo ::endgroup::
118+
119+
- name: "Honeycomb: Record Setup Environment time"
120+
if: ${{ always() }}
121+
run: |
122+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
123+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
124+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
125+
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+
161+
- name: Run acceptance tests
162+
run: |
163+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
164+
165+
- name: "Honeycomb: Record acceptance testing times"
166+
if: ${{ always() }}
167+
run: |
168+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
169+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
170+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
171+
172+
- name: Remove test environment
173+
if: ${{ always() }}
174+
continue-on-error: true
175+
run: |
176+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
177+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
178+
echo ::group::=== REQUEST ===
179+
cat request.json || true
180+
echo
181+
echo ::endgroup::
182+
fi
183+
184+
- name: "Honeycomb: Record removal times"
185+
if: ${{ always() }}
186+
run: |
187+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'
188+
189+
slack-workflow-status:
190+
if: ${{ github.repository_owner == 'puppetlabs' }}
191+
name: Post Workflow Status To Slack
192+
needs:
193+
- Acceptance
194+
runs-on: ubuntu-20.04
195+
steps:
196+
- name: Slack Workflow Notification
197+
uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1
198+
with:
199+
# Required Input
200+
repo_token: ${{ secrets.GITHUB_TOKEN }}
201+
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }}
202+
# Optional Input
203+
channel: '#team-cat-bots'
204+
name: 'GABot'

.github/workflows/pr_test.yml

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

0 commit comments

Comments
 (0)