Skip to content

Commit dc0e121

Browse files
authored
Merge pull request #22 from MartyEwings/cloud_ci
Cloud CI conversion and Acceptance Tests
2 parents 7c27c4f + 10f8f49 commit dc0e121

20 files changed

+749
-159
lines changed

.github/workflows/auto_release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: "Auto release"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
8+
HONEYCOMB_DATASET: litmus tests
9+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
11+
jobs:
12+
auto_release:
13+
name: "Automatic release prep"
14+
runs-on: ubuntu-20.04
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="auto-release" >> $GITHUB_ENV
27+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
28+
29+
- name: "Checkout Source"
30+
if: ${{ github.repository_owner == 'puppetlabs' }}
31+
uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
persist-credentials: false
35+
36+
- name: "PDK Release prep"
37+
uses: docker://puppet/iac_release:ci
38+
with:
39+
args: 'release prep --force'
40+
env:
41+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: "Get Version"
44+
if: ${{ github.repository_owner == 'puppetlabs' }}
45+
id: gv
46+
run: |
47+
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
48+
49+
- name: "Check if a release is necessary"
50+
if: ${{ github.repository_owner == 'puppetlabs' }}
51+
id: check
52+
run: |
53+
git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true"
54+
55+
- name: "Commit changes"
56+
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
57+
run: |
58+
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
59+
git config --local user.name "GitHub Action"
60+
git add .
61+
git commit -m "Release prep v${{ steps.gv.outputs.ver }}"
62+
63+
- name: Create Pull Request
64+
id: cpr
65+
uses: puppetlabs/peter-evans-create-pull-request@v3
66+
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
commit-message: "Release prep v${{ steps.gv.outputs.ver }}"
70+
branch: "release-prep"
71+
delete-branch: true
72+
title: "Release prep v${{ steps.gv.outputs.ver }}"
73+
body: |
74+
Automated release-prep through [pdk-templates](https://github.com/puppetlabs/pdk-templates/blob/main/moduleroot/.github/workflows/auto_release.yml.erb) from commit ${{ github.sha }}.
75+
Please verify before merging:
76+
- [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green
77+
- [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests
78+
- [ ] Ensure the [changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) version and [metadata](https://github.com/${{ github.repository }}/blob/release-prep/metadata.json) version match
79+
labels: "maintenance"
80+
81+
- name: PR outputs
82+
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
83+
run: |
84+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
85+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
86+
87+
- name: "Honeycomb: Record finish step"
88+
if: ${{ always() }}
89+
run: |
90+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Finished auto release workflow'
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: "PE Latest Acceptance Testing"
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
env:
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+
- name: "Honeycomb: Start recording"
20+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
21+
with:
22+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
23+
dataset: ${{ env.HONEYCOMB_DATASET }}
24+
job-status: ${{ job.status }}
25+
26+
- name: "Honeycomb: Start first step"
27+
run: |
28+
echo STEP_ID=setup-environment >> $GITHUB_ENV
29+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30+
- name: Checkout Source
31+
uses: actions/checkout@v2
32+
if: ${{ github.repository_owner == 'puppetlabs' }}
33+
34+
- name: Activate Ruby 2.7
35+
uses: ruby/setup-ruby@v1
36+
if: ${{ github.repository_owner == 'puppetlabs' }}
37+
with:
38+
ruby-version: "2.7"
39+
bundler-cache: true
40+
41+
- name: Print bundle environment
42+
if: ${{ github.repository_owner == 'puppetlabs' }}
43+
run: |
44+
echo ::group::bundler environment
45+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
46+
echo ::endgroup::
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+
# Store the result of the curl call in $forge_response
55+
- name: Curl Forge for PE versions
56+
id: curl_forge
57+
run: |
58+
echo "::set-output name=forge_response::$(curl https://forge.puppet.com/private/versions/pe)"
59+
60+
- name: Set latest release
61+
id: latest_release
62+
run: |
63+
out=$(jq -c '[.[] | select(.lts == false)][0].latest | {"collection": [.]}' <<<'${{ steps.curl_forge.outputs.forge_response }}')
64+
echo "::set-output name=latest::$out"
65+
66+
- name: Setup Acceptance Test Matrix
67+
id: get-matrix
68+
run: |
69+
if [[ -e spec/fixtures/matrix/latest.json ]]; then
70+
out=$(jq -c '. + ($matrix | .[])' --slurpfile matrix spec/fixtures/matrix/latest.json <<<'${{ steps.latest_release.outputs.latest }}')
71+
echo "::set-output name=matrix::$out"
72+
else
73+
echo "::set-output name=matris::{}"
74+
fi
75+
76+
- name: "Honeycomb: Record Setup Test Matrix time"
77+
if: ${{ always() }}
78+
run: |
79+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
80+
81+
Acceptance:
82+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
83+
needs:
84+
- setup_matrix
85+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
86+
87+
runs-on: ubuntu-20.04
88+
strategy:
89+
fail-fast: false
90+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
91+
92+
env:
93+
BUILDEVENT_FILE: '../buildevents.txt'
94+
95+
steps:
96+
- run: |
97+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
98+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
99+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
100+
- name: "Honeycomb: Start recording"
101+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
102+
with:
103+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
104+
dataset: ${{ env.HONEYCOMB_DATASET }}
105+
job-status: ${{ job.status }}
106+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
107+
108+
- name: "Honeycomb: start first step"
109+
run: |
110+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
111+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
112+
- name: Checkout Source
113+
uses: actions/checkout@v2
114+
115+
- name: Activate Ruby 2.7
116+
uses: ruby/setup-ruby@v1
117+
with:
118+
ruby-version: "2.7"
119+
bundler-cache: true
120+
121+
- name: Print bundle environment
122+
run: |
123+
echo ::group::bundler environment
124+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
125+
echo ::endgroup::
126+
- name: "Honeycomb: Record Setup Environment time"
127+
if: ${{ always() }}
128+
run: |
129+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
130+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
131+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
132+
- name: Provision test environment
133+
run: |
134+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
135+
echo ::group::=== REQUEST ===
136+
cat request.json || true
137+
echo
138+
echo ::endgroup::
139+
echo ::group::=== INVENTORY ===
140+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
141+
then
142+
FILE='spec/fixtures/litmus_inventory.yaml'
143+
elif [ -f 'inventory.yaml' ];
144+
then
145+
FILE='inventory.yaml'
146+
fi
147+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
148+
echo ::endgroup::
149+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
150+
- name: Install PE
151+
run: |
152+
buildevents cmd $TRACE_ID $STEP_ID 'rake deploy_pe::provision_master' -- bundle exec bolt --tmpdir /tmp --log-level debug --modulepath spec/fixtures/modules -i ./$INVENTORY_PATH plan run deploy_pe::provision_master --params '{"version":"${{ matrix.collection }}","pe_settings":{"password":"puppetlabs", "configure_tuning": false}}' --targets all --stream
153+
154+
- name: Install module
155+
run: |
156+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
157+
- name: "Honeycomb: Record deployment times"
158+
if: ${{ always() }}
159+
run: |
160+
echo ::group::honeycomb step
161+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
162+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
163+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
164+
echo ::endgroup::
165+
- name: Run acceptance tests
166+
run: |
167+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
168+
- name: "Honeycomb: Record acceptance testing times"
169+
if: ${{ always() }}
170+
run: |
171+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
172+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
173+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
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+
- name: "Honeycomb: Record removal times"
186+
if: ${{ always() }}
187+
run: |
188+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

0 commit comments

Comments
 (0)