Skip to content

Commit 1cb90ed

Browse files
authored
Merge pull request #671 from puppetlabs/pdksync_CONT-229-Implement_reusable_workflows
2 parents f4a2435 + c60c463 commit 1cb90ed

File tree

7 files changed

+48
-735
lines changed

7 files changed

+48
-735
lines changed

.github/workflows/auto_release.yml

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,88 +3,7 @@ name: "Auto release"
33
on:
44
workflow_dispatch:
55

6-
env:
7-
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
8-
HONEYCOMB_DATASET: litmus tests
9-
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10-
116
jobs:
12-
auto_release:
13-
name: "Automatic release prep"
14-
runs-on: ubuntu-20.04
15-
16-
steps:
17-
18-
- name: "Honeycomb: Start recording"
19-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
20-
with:
21-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
22-
dataset: ${{ env.HONEYCOMB_DATASET }}
23-
job-status: ${{ job.status }}
24-
25-
- name: "Honeycomb: start first step"
26-
run: |
27-
echo STEP_ID="auto-release" >> $GITHUB_ENV
28-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
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/pdk:2.6.1.0
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'
7+
release_prep:
8+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main"
9+
secrets: "inherit"

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "ci"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
workflow_dispatch:
8+
9+
jobs:
10+
Spec:
11+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
12+
with:
13+
runs_on: "ubuntu-20.04"
14+
secrets: "inherit"
15+
16+
Acceptance:
17+
needs: Spec
18+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
19+
with:
20+
runs_on: "ubuntu-20.04"
21+
secrets: "inherit"

.github/workflows/integration_test.yml

Lines changed: 9 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: "Integration Testing"
22

33
on: [pull_request]
44

5-
env:
6-
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
7-
HONEYCOMB_DATASET: litmus tests
8-
95
jobs:
106
setup_matrix:
117
name: "Setup Test Matrix"
@@ -14,18 +10,6 @@ jobs:
1410
matrix: ${{ steps.get-matrix.outputs.matrix }}
1511

1612
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-
2913
- name: Checkout Source
3014
uses: actions/checkout@v2
3115
if: ${{ github.repository_owner == 'puppetlabs' }}
@@ -41,16 +25,9 @@ jobs:
4125
if: ${{ github.repository_owner == 'puppetlabs' }}
4226
run: |
4327
echo ::group::bundler environment
44-
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
28+
bundle env
4529
echo ::endgroup::
4630
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-Integration-Test-Matrix >> $GITHUB_ENV
52-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
53-
5431
- name: Setup Integration Test Matrix
5532
id: get-matrix
5633
run: |
@@ -60,11 +37,6 @@ jobs:
6037
echo "matrix={}" >> $GITHUB_OUTPUT
6138
fi
6239
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-
6840
Integration:
6941
needs:
7042
- setup_matrix
@@ -75,26 +47,7 @@ jobs:
7547
fail-fast: false
7648
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
7749

78-
env:
79-
BUILDEVENT_FILE: '../buildevents.txt'
80-
8150
steps:
82-
- run: |
83-
echo 'platform=${{ matrix.platform }}' >> $BUILDEVENT_FILE
84-
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
85-
86-
- name: "Honeycomb: Start recording"
87-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
88-
with:
89-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
90-
dataset: ${{ env.HONEYCOMB_DATASET }}
91-
job-status: ${{ job.status }}
92-
matrix-key: ${{ matrix.platform }}-${{ matrix.collection }}
93-
94-
- name: "Honeycomb: start first step"
95-
run: |
96-
echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
97-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
9851

9952
- name: Checkout Source
10053
uses: actions/checkout@v2
@@ -108,39 +61,19 @@ jobs:
10861
- name: Print bundle environment
10962
run: |
11063
echo ::group::bundler environment
111-
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
64+
bundle env
11265
echo ::endgroup::
11366
11467
- name: Create the fixtures directory
11568
run: |
116-
echo ::group::Create the fixtures directory
117-
buildevents cmd $TRACE_ID $STEP_ID 'bundle exec rake spec_prep' -- bundle exec rake spec_prep
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.platform }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
125-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
69+
bundle exec rake spec_prep
12670
12771
- name: Provision test environment
12872
run: |
129-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platform }}' -- bundle exec bolt --modulepath spec/fixtures/modules plan run ntp::acceptance::provision_integration image=${{ matrix.platform }}
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
73+
bundle exec bolt --modulepath spec/fixtures/modules plan run ntp::acceptance::provision_integration image=${{ matrix.platform }}
74+
# Redact password
75+
FILE='spec/fixtures/litmus_inventory.yaml'
14276
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
143-
echo ::endgroup::
14477
14578
- name: Install PE
14679
run: |
@@ -152,41 +85,14 @@ jobs:
15285
15386
- name: Install module
15487
run: |
155-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
156-
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.platform }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
163-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
164-
echo ::endgroup::
88+
bundle exec rake 'litmus:install_module'
16589
16690
- name: Run integration tests
16791
run: |
168-
buildevents cmd $TRACE_ID $STEP_ID 'rake ntp:integration' -- bundle exec rake ntp:integration
169-
170-
- name: "Honeycomb: Record integration testing times"
171-
if: ${{ always() }}
172-
run: |
173-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run integration tests'
174-
echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
175-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
92+
bundle exec rake ntp:integration
17693
17794
- name: Remove test environment
17895
if: ${{ always() }}
17996
continue-on-error: true
18097
run: |
181-
if [ -f inventory.yaml ]; then
182-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
183-
echo ::group::=== REQUEST ===
184-
cat request.json || true
185-
echo
186-
echo ::endgroup::
187-
fi
188-
189-
- name: "Honeycomb: Record removal times"
190-
if: ${{ always() }}
191-
run: |
192-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'
98+
bundle exec rake 'litmus:tear_down'

0 commit comments

Comments
 (0)