Skip to content

Commit f1613a4

Browse files
committed
basic acceptance tests
1 parent 21a68b0 commit f1613a4

24 files changed

+814
-194
lines changed

.fixtures.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@
44
fixtures:
55
forge_modules:
66
# stdlib: "puppetlabs/stdlib"
7+
repositories:
8+
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
9+
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
10+
provision: 'https://github.com/puppetlabs/provision.git'
11+
bootstrap: "https://github.com/puppetlabs/puppetlabs-bootstrap"
12+
puppet_conf: "https://github.com/puppetlabs/puppetlabs-puppet_conf"
13+
ruby_task_helper: "https://git@github.com/puppetlabs/puppetlabs-ruby_task_helper"
14+
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
15+
deploy_pe: 'git://github.com/jarretlavallee/puppet-deploy_pe.git'

.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: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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+
# Store the result of the curl call in $forge_response
54+
- name: Curl Forge for PE versions
55+
id: curl_forge
56+
run: |
57+
echo "::set-output name=forge_response::$(curl https://forge.puppet.com/private/versions/pe)"
58+
- name: Set latest release
59+
id: latest_release
60+
run: |
61+
out=$(jq -c '[.[] | select(.lts == false)][0].latest | {"collection": [.]}' <<<'${{ steps.curl_forge.outputs.forge_response }}')
62+
echo "::set-output name=latest::$out"
63+
- name: Setup Acceptance Test Matrix
64+
id: get-matrix
65+
run: |
66+
if [[ -e spec/fixtures/matrix/latest.json ]]; then
67+
out=$(jq -c '. + ($matrix | .[])' --slurpfile matrix spec/fixtures/matrix/latest.json <<<'${{ steps.latest_release.outputs.latest }}')
68+
echo "::set-output name=matrix::$out"
69+
else
70+
echo "::set-output name=matris::{}"
71+
fi
72+
- name: "Honeycomb: Record Setup Test Matrix time"
73+
if: ${{ always() }}
74+
run: |
75+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
76+
Acceptance:
77+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
78+
needs:
79+
- setup_matrix
80+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
81+
82+
runs-on: ubuntu-20.04
83+
strategy:
84+
fail-fast: false
85+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
86+
87+
env:
88+
BUILDEVENT_FILE: '../buildevents.txt'
89+
90+
steps:
91+
- run: |
92+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
93+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
94+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
95+
- name: "Honeycomb: Start recording"
96+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
97+
with:
98+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
99+
dataset: ${{ env.HONEYCOMB_DATASET }}
100+
job-status: ${{ job.status }}
101+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
102+
103+
- name: "Honeycomb: start first step"
104+
run: |
105+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
106+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
107+
- name: Checkout Source
108+
uses: actions/checkout@v2
109+
110+
- name: Activate Ruby 2.7
111+
uses: ruby/setup-ruby@v1
112+
with:
113+
ruby-version: "2.7"
114+
bundler-cache: true
115+
116+
- name: Print bundle environment
117+
run: |
118+
echo ::group::bundler environment
119+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
120+
echo ::endgroup::
121+
- name: "Honeycomb: Record Setup Environment time"
122+
if: ${{ always() }}
123+
run: |
124+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
125+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
126+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
127+
- name: Provision test environment
128+
run: |
129+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
130+
echo ::group::=== REQUEST ===
131+
cat request.json || true
132+
echo
133+
echo ::endgroup::
134+
echo ::group::=== INVENTORY ===
135+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
136+
then
137+
FILE='spec/fixtures/litmus_inventory.yaml'
138+
elif [ -f 'inventory.yaml' ];
139+
then
140+
FILE='inventory.yaml'
141+
fi
142+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
143+
echo ::endgroup::
144+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
145+
- name: Install PE
146+
run: |
147+
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
148+
- name: Install module
149+
run: |
150+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
151+
- name: "Honeycomb: Record deployment times"
152+
if: ${{ always() }}
153+
run: |
154+
echo ::group::honeycomb step
155+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
156+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
157+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
158+
echo ::endgroup::
159+
- name: Run acceptance tests
160+
run: |
161+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
162+
- name: "Honeycomb: Record acceptance testing times"
163+
if: ${{ always() }}
164+
run: |
165+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
166+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
167+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
168+
- name: Remove test environment
169+
if: ${{ always() }}
170+
continue-on-error: true
171+
run: |
172+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
173+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
174+
echo ::group::=== REQUEST ===
175+
cat request.json || true
176+
echo
177+
echo ::endgroup::
178+
fi
179+
- name: "Honeycomb: Record removal times"
180+
if: ${{ always() }}
181+
run: |
182+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

0 commit comments

Comments
 (0)