Skip to content

Commit f71f2fa

Browse files
authored
Merge pull request #1554 from puppetlabs/pdksync_CONT-229-Implement_reusable_workflows
pdksync - CONT-229-Implement reusable workflows
2 parents 14aef71 + 4176ee4 commit f71f2fa

File tree

6 files changed

+133
-577
lines changed

6 files changed

+133
-577
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

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
setup_matrix:
17+
name: "Setup Test Matrix"
18+
needs: "Spec"
19+
runs-on: ubuntu-20.04
20+
outputs:
21+
matrix: ${{ steps.get-matrix.outputs.matrix }}
22+
23+
steps:
24+
- name: Checkout Source
25+
uses: actions/checkout@v2
26+
27+
- name: Activate Ruby 2.7
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: "2.7"
31+
bundler-cache: true
32+
33+
- name: Print bundle environment
34+
run: |
35+
echo ::group::bundler environment
36+
bundle env
37+
echo ::endgroup::
38+
39+
- name: Run validation steps
40+
run: |
41+
bundle exec rake validate
42+
43+
- name: Setup Acceptance Test Matrix
44+
id: get-matrix
45+
run: |
46+
bundle exec matrix_from_metadata_v2
47+
48+
Acceptance:
49+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
50+
needs:
51+
- setup_matrix
52+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
53+
54+
runs-on: ubuntu-20.04
55+
strategy:
56+
fail-fast: false
57+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
58+
59+
steps:
60+
- name: Checkout Source
61+
uses: actions/checkout@v2
62+
63+
- name: Activate Ruby 2.7
64+
uses: ruby/setup-ruby@v1
65+
with:
66+
ruby-version: "2.7"
67+
bundler-cache: true
68+
69+
- name: Print bundle environment
70+
run: |
71+
bundle env
72+
73+
- name: "Disable mysqld apparmor profile"
74+
if: matrix.platforms.provider == 'provision::docker'
75+
run: |
76+
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
77+
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld
78+
79+
- name: Provision test environment
80+
run: |
81+
bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
82+
FILE='spec/fixtures/litmus_inventory.yaml'
83+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
84+
85+
- name: Install agent
86+
run: |
87+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
88+
89+
- name: Install module
90+
run: |
91+
bundle exec rake 'litmus:install_module'
92+
93+
- name: Run acceptance tests
94+
run: |
95+
bundle exec rake 'litmus:acceptance:parallel'
96+
97+
- name: Remove test environment
98+
if: ${{ always() }}
99+
continue-on-error: true
100+
run: |
101+
bundle exec rake 'litmus:tear_down'
102+

0 commit comments

Comments
 (0)