Skip to content

Commit f04c08f

Browse files
committed
(CONT-229) - Implement reusable workflows
1 parent 14aef71 commit f04c08f

File tree

5 files changed

+41
-520
lines changed

5 files changed

+41
-520
lines changed

.github/workflows/auto_release.yml

+4-84
Original file line numberDiff line numberDiff line change
@@ -3,88 +3,8 @@ 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/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'
7+
release_prep:
8+
name: "Release Prep"
9+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main"
10+
secrets: "inherit"

.github/workflows/ci.yml

+21
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/nightly.yml

+12-201
Original file line numberDiff line numberDiff line change
@@ -2,209 +2,20 @@ name: "nightly"
22

33
on:
44
schedule:
5-
- cron: '0 0 * * *'
6-
7-
8-
env:
9-
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
10-
HONEYCOMB_DATASET: litmus tests
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
117

128
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
9+
Spec:
10+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
11+
with:
12+
runs_on: "ubuntu-20.04"
13+
secrets: "inherit"
6614

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'
7115
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: "Disable mysqld apparmor profile"
127-
if: matrix.platforms.provider == 'provision::docker'
128-
run: |
129-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
130-
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld
131-
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-
150-
- name: Install agent
151-
run: |
152-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
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-
158-
- name: "Honeycomb: Record deployment times"
159-
if: ${{ always() }}
160-
run: |
161-
echo ::group::honeycomb step
162-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
163-
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
164-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
165-
echo ::endgroup::
166-
167-
- name: Run acceptance tests
168-
run: |
169-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
170-
171-
- name: "Honeycomb: Record acceptance testing times"
172-
if: ${{ always() }}
173-
run: |
174-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
175-
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
176-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
177-
178-
- name: Remove test environment
179-
if: ${{ always() }}
180-
continue-on-error: true
181-
run: |
182-
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
183-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
184-
echo ::group::=== REQUEST ===
185-
cat request.json || true
186-
echo
187-
echo ::endgroup::
188-
fi
189-
190-
- name: "Honeycomb: Record removal times"
191-
if: ${{ always() }}
192-
run: |
193-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'
16+
needs: Spec
17+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
18+
with:
19+
runs_on: "ubuntu-20.04"
20+
secrets: "inherit"
19421

195-
slack-workflow-status:
196-
if: ${{ github.repository_owner == 'puppetlabs' }}
197-
name: Post Workflow Status To Slack
198-
needs:
199-
- Acceptance
200-
runs-on: ubuntu-20.04
201-
steps:
202-
- name: Slack Workflow Notification
203-
uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1
204-
with:
205-
# Required Input
206-
repo_token: ${{ secrets.GITHUB_TOKEN }}
207-
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }}
208-
# Optional Input
209-
channel: '#team-cat-bots'
210-
name: 'GABot'

0 commit comments

Comments
 (0)