Skip to content

Commit acfa520

Browse files
committed
(SUP-2428) CI Initial commit
This commit adds the PDK and github actions configs needed to run spec tests in the cloud.
1 parent 70ec7f9 commit acfa520

File tree

5 files changed

+280
-73
lines changed

5 files changed

+280
-73
lines changed

.github/workflows/auto_release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: "Auto release"
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 6'
6+
workflow_dispatch:
7+
8+
env:
9+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
10+
HONEYCOMB_DATASET: litmus tests
11+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
jobs:
14+
auto_release:
15+
name: "Automatic release prep"
16+
runs-on: ubuntu-20.04
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="auto-release" >> $GITHUB_ENV
29+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30+
31+
- name: "Checkout Source"
32+
if: ${{ github.repository_owner == 'puppetlabs' }}
33+
uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 0
36+
persist-credentials: false
37+
38+
- name: "PDK Release prep"
39+
uses: docker://puppet/iac_release:ci
40+
with:
41+
args: 'release prep --force'
42+
env:
43+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: "Get Version"
46+
if: ${{ github.repository_owner == 'puppetlabs' }}
47+
id: gv
48+
run: |
49+
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
50+
51+
- name: "Commit changes"
52+
if: ${{ github.repository_owner == 'puppetlabs' }}
53+
run: |
54+
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
55+
git config --local user.name "GitHub Action"
56+
git add .
57+
git commit -m "Release prep v${{ steps.gv.outputs.ver }}"
58+
59+
- name: Create Pull Request
60+
id: cpr
61+
uses: puppetlabs/peter-evans-create-pull-request@v3
62+
if: ${{ github.repository_owner == 'puppetlabs' }}
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
commit-message: "Release prep v${{ steps.gv.outputs.ver }}"
66+
branch: "release-prep"
67+
delete-branch: true
68+
title: "Release prep v${{ steps.gv.outputs.ver }}"
69+
body: |
70+
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 }}.
71+
Please verify before merging:
72+
- [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green
73+
- [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests
74+
- [ ] 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
75+
labels: "maintenance"
76+
77+
- name: PR outputs
78+
if: ${{ github.repository_owner == 'puppetlabs' }}
79+
run: |
80+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
81+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
82+
83+
- name: "Honeycomb: Record finish step"
84+
if: ${{ always() }}
85+
run: |
86+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Finished auto release workflow'

.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:2.1.0.0
42+
with:
43+
args: 'build'
44+
- name: "Push to Forge"
45+
uses: docker://puppet/pdk:2.1.0.0
46+
with:
47+
args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'

.github/workflows/spec.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: "Spec Tests"
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+
spec_matrix: ${{ steps.get-matrix.outputs.spec_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+
31+
- name: Checkout Source
32+
uses: actions/checkout@v2
33+
if: ${{ github.repository_owner == 'puppetlabs' }}
34+
35+
- name: Activate Ruby 2.7
36+
uses: ruby/setup-ruby@v1
37+
if: ${{ github.repository_owner == 'puppetlabs' }}
38+
with:
39+
ruby-version: "2.7"
40+
bundler-cache: true
41+
42+
- name: Print bundle environment
43+
if: ${{ github.repository_owner == 'puppetlabs' }}
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 == 'puppetlabs' }}
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+
56+
- name: Setup Spec Test Matrix
57+
id: get-matrix
58+
run: |
59+
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
60+
buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2
61+
else
62+
echo "::set-output name=spec_matrix::{}"
63+
fi
64+
65+
- name: "Honeycomb: Record Setup Test Matrix time"
66+
if: ${{ always() }}
67+
run: |
68+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
69+
70+
Spec:
71+
name: "Spec Tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})"
72+
needs:
73+
- setup_matrix
74+
if: ${{ needs.setup_matrix.outputs.spec_matrix != '{}' }}
75+
76+
runs-on: ubuntu-20.04
77+
strategy:
78+
fail-fast: false
79+
matrix: ${{fromJson(needs.setup_matrix.outputs.spec_matrix)}}
80+
81+
env:
82+
BUILDEVENT_FILE: '../buildevents.txt'
83+
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
84+
85+
steps:
86+
- run: |
87+
echo "SANITIZED_PUPPET_VERSION=$(echo '${{ matrix.puppet_version }}' | sed 's/~> //g')" >> $GITHUB_ENV
88+
89+
- run: |
90+
echo 'puppet_version=${{ env.SANITIZED_PUPPET_VERSION }}' >> $BUILDEVENT_FILE
91+
92+
- name: "Honeycomb: Start first step"
93+
run: |
94+
echo "STEP_ID=${{ env.SANITIZED_PUPPET_VERSION }}-spec" >> $GITHUB_ENV
95+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
96+
97+
- name: "Honeycomb: Start recording"
98+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
99+
with:
100+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
101+
dataset: ${{ env.HONEYCOMB_DATASET }}
102+
job-status: ${{ job.status }}
103+
matrix-key: ${{ env.SANITIZED_PUPPET_VERSION }}
104+
105+
- name: Checkout Source
106+
uses: actions/checkout@v2
107+
108+
- name: "Activate Ruby ${{ matrix.ruby_version }}"
109+
uses: ruby/setup-ruby@v1
110+
with:
111+
ruby-version: ${{matrix.ruby_version}}
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: Run Static & Syntax Tests
121+
run: |
122+
buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks Puppet ${{ matrix.puppet_version }}, Ruby ${{ matrix.ruby_version }}' -- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
123+
124+
- name: Run parallel_spec tests
125+
run: |
126+
buildevents cmd $TRACE_ID $STEP_ID 'rake parallel_spec Puppet ${{ matrix.puppet_version }}, Ruby ${{ matrix.ruby_version }}' -- bundle exec rake parallel_spec

.sync.yml

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
---
2-
mock_with: ':rspec'
2+
common:
33

4-
appveyor.yml:
4+
".gitlab-ci.yml":
55
delete: true
6-
.gitlab-ci.yml:
6+
appveyor.yml:
77
delete: true
8-
.project:
8+
.gitpod.Dockerfile:
9+
unmanaged: true
10+
.gitpod.yml:
11+
unmanaged: true
12+
.github/workflows/nightly.yml:
13+
unmanaged: true
14+
.github/workflows/pr_test.yml:
15+
unmanaged: true
16+
.github/workflows/auto_release.yml:
17+
unmanaged: true
18+
.github/workflows/spec.yml:
19+
checks: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop'
20+
unmanaged: true
21+
.github/workflows/release.yml:
22+
unmanaged: true
23+
.travis.yml:
924
delete: true
1025

11-
.rubocop.yml:
12-
default_configs:
13-
Style/BracesAroundHashParameters:
14-
Description: |
15-
Braces are actually required by Ruby 2.7 in order to disambiguate between
16-
keword arguments and actual hash parameters. Removed in RuboCop v0.80.0.
17-
Enabled: false
18-
19-
spec/default_facts.yml:
20-
extra_facts:
21-
pe_server_version: '2016.4.5'
22-
.rubocop.yml:
23-
selected_profile: off
24-
25-
.travis.yml:
26-
branches:
27-
- master
28-
- main
29-
- /^v\d/
26+
Rakefile:
27+
changelog_user: "puppetlabs"

.travis.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)