Skip to content

Commit 1279e8a

Browse files
authored
Update build to use github actions (#84)
1 parent 173e699 commit 1279e8a

File tree

12 files changed

+515
-115
lines changed

12 files changed

+515
-115
lines changed

.devcontainer/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# devcontainer
2+
3+
4+
For format details, see https://aka.ms/devcontainer.json.
5+
6+
For config options, see the README at:
7+
https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet
8+
9+
``` json
10+
{
11+
"name": "Puppet Development Kit (Community)",
12+
"dockerFile": "Dockerfile",
13+
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {
16+
"terminal.integrated.shell.linux": "/bin/bash"
17+
},
18+
19+
// Add the IDs of extensions you want installed when the container is created.
20+
"extensions": [
21+
"puppet.puppet-vscode",
22+
"rebornix.Ruby"
23+
]
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
"forwardPorts": [],
27+
28+
// Use 'postCreateCommand' to run commands after the container is created.
29+
"postCreateCommand": "pdk --version",
30+
}
31+
```
32+
33+
34+

.devcontainer/devcontainer.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet
31
{
42
"name": "Puppet Development Kit (Community)",
53
"dockerFile": "Dockerfile",
64

7-
// Set *default* container specific settings.json values on container create.
85
"settings": {
9-
"terminal.integrated.shell.linux": "/bin/bash"
6+
"terminal.integrated.profiles.linux": {
7+
"bash": {
8+
"path": "bash",
9+
}
10+
}
1011
},
1112

12-
// Add the IDs of extensions you want installed when the container is created.
1313
"extensions": [
1414
"puppet.puppet-vscode",
1515
"rebornix.Ruby"
1616
]
17-
18-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19-
// "forwardPorts": [],
20-
21-
// Use 'postCreateCommand' to run commands after the container is created.
22-
// "postCreateCommand": "pdk --version",
2317
}

.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+
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 == 'TraGicCode' }}
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 == 'TraGicCode' }}
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 == 'TraGicCode' }}
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 == 'TraGicCode' && 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 == 'TraGicCode' && 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 == 'TraGicCode' && 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'

.github/workflows/pr_test.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: "PR Testing"
2+
3+
on: [pull_request]
4+
5+
6+
env:
7+
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+
20+
- name: "Honeycomb: Start recording"
21+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
22+
with:
23+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
24+
dataset: ${{ env.HONEYCOMB_DATASET }}
25+
job-status: ${{ job.status }}
26+
27+
- name: "Honeycomb: Start first step"
28+
run: |
29+
echo STEP_ID=setup-environment >> $GITHUB_ENV
30+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
31+
- name: Checkout Source
32+
uses: actions/checkout@v2
33+
if: ${{ github.repository_owner == 'TraGicCode' }}
34+
35+
- name: Activate Ruby 2.7
36+
uses: ruby/setup-ruby@v1
37+
if: ${{ github.repository_owner == 'TraGicCode' }}
38+
with:
39+
ruby-version: "2.7"
40+
bundler-cache: true
41+
42+
- name: Print bundle environment
43+
if: ${{ github.repository_owner == 'TraGicCode' }}
44+
run: |
45+
echo ::group::bundler environment
46+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
47+
echo ::endgroup::
48+
49+
- name: "Honeycomb: Record Setup Environment time"
50+
if: ${{ github.repository_owner == 'TraGicCode' }}
51+
run: |
52+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
53+
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
54+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
55+
- name: Run validation steps
56+
run: |
57+
bundle exec rake validate
58+
if: ${{ github.repository_owner == 'TraGicCode' }}
59+
60+
- name: Setup Acceptance Test Matrix
61+
id: get-matrix
62+
run: |
63+
if [ '${{ github.repository_owner }}' == 'TraGicCode' ]; then
64+
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2
65+
else
66+
echo "::set-output name=matrix::{}"
67+
fi
68+
69+
- name: "Honeycomb: Record Setup Test Matrix time"
70+
if: ${{ always() }}
71+
run: |
72+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
73+
Acceptance:
74+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
75+
needs:
76+
- setup_matrix
77+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
78+
79+
runs-on: ubuntu-20.04
80+
strategy:
81+
fail-fast: false
82+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
83+
84+
env:
85+
BUILDEVENT_FILE: '../buildevents.txt'
86+
87+
steps:
88+
- run: |
89+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
90+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
91+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
92+
93+
- name: "Honeycomb: Start recording"
94+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
95+
with:
96+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
97+
dataset: ${{ env.HONEYCOMB_DATASET }}
98+
job-status: ${{ job.status }}
99+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
100+
101+
- name: "Honeycomb: start first step"
102+
run: |
103+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
104+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
105+
- name: Checkout Source
106+
uses: actions/checkout@v2
107+
108+
- name: Activate Ruby 2.7
109+
uses: ruby/setup-ruby@v1
110+
with:
111+
ruby-version: "2.7"
112+
bundler-cache: true
113+
114+
- name: Print bundle environment
115+
run: |
116+
echo ::group::bundler environment
117+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
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.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
125+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
126+
- name: Provision test environment
127+
run: |
128+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
129+
echo ::group::=== REQUEST ===
130+
cat request.json || true
131+
echo
132+
echo ::endgroup::
133+
echo ::group::=== INVENTORY ===
134+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
135+
then
136+
FILE='spec/fixtures/litmus_inventory.yaml'
137+
elif [ -f 'inventory.yaml' ];
138+
then
139+
FILE='inventory.yaml'
140+
fi
141+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
142+
echo ::endgroup::
143+
144+
- name: Install agent
145+
run: |
146+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
147+
148+
- name: Install module
149+
run: |
150+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
151+
152+
- name: "Honeycomb: Record deployment times"
153+
if: ${{ always() }}
154+
run: |
155+
echo ::group::honeycomb step
156+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
157+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
158+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
159+
echo ::endgroup::
160+
- name: Run acceptance tests
161+
run: |
162+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
163+
164+
- name: "Honeycomb: Record acceptance testing times"
165+
if: ${{ always() }}
166+
run: |
167+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
168+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
169+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
170+
- name: Remove test environment
171+
if: ${{ always() }}
172+
continue-on-error: true
173+
run: |
174+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
175+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
176+
echo ::group::=== REQUEST ===
177+
cat request.json || true
178+
echo
179+
echo ::endgroup::
180+
fi
181+
182+
- name: "Honeycomb: Record removal times"
183+
if: ${{ always() }}
184+
run: |
185+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Publish module"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
create-github-release:
8+
name: Deploy GitHub Release
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
with:
14+
ref: ${{ github.ref }}
15+
clean: true
16+
fetch-depth: 0
17+
- name: Get Version
18+
id: gv
19+
run: |
20+
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
21+
- name: Create Release
22+
uses: actions/create-release@v1
23+
id: create_release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
with:
27+
tag_name: "v${{ steps.gv.outputs.ver }}"
28+
draft: false
29+
prerelease: false
30+
31+
deploy-forge:
32+
name: Deploy to Forge
33+
runs-on: ubuntu-20.04
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
with:
38+
ref: ${{ github.ref }}
39+
clean: true
40+
- name: "PDK Build"
41+
uses: docker://puppet/pdk:nightly
42+
with:
43+
args: 'build'
44+
- name: "Push to Forge"
45+
uses: docker://puppet/pdk:nightly
46+
with:
47+
args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'

0 commit comments

Comments
 (0)