Skip to content

Commit 8aaf63c

Browse files
authored
Merge pull request #385 from h0tw1r3/unit-testing
modernize test framework and add ci workflow
2 parents 4bed77e + 6663970 commit 8aaf63c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6292
-1514
lines changed

.fixtures.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ fixtures:
33
repositories:
44
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
55
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
6-
postgresql: 'https://github.com/puppetlabs/puppet-postgresql.git'
7-
firewall: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
86
apt: 'https://github.com/puppetlabs/puppetlabs-apt.git'
97
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
10-
file_concat: 'https://github.com/electrical/puppet-lib-file_concat.git'
118
systemd: 'https://github.com/camptocamp/puppet-systemd.git'
12-
cron: 'https://github.com/voxpupuli/puppet-cron.git'
9+
provision: 'https://github.com/puppetlabs/provision.git'
10+
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
11+
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
1312
cron_core: 'https://github.com/puppetlabs/puppetlabs-cron_core.git'
1413
yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core.git'
1514
augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core.git'
15+
postgresql: 'https://github.com/puppetlabs/puppetlabs-postgresql.git'
16+
firewall: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
17+
forge_modules:
18+
postgresql:
19+
repo: 'puppetlabs/postgresql'
20+
ref: "9.2.0"
21+
firewall:
22+
repo: 'puppetlabs/firewall'
23+
ref: "6.0.0"
24+
symlinks:
25+
puppetdb: '#{source_dir}'

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "ci"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
paths-ignore:
8+
- '**.md'
9+
- 'examples/**'
10+
- 'LICENSE'
11+
- 'CODEOWNERS'
12+
- 'AUTHORS'
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
Spec:
21+
uses: ./.github/workflows/module_ci.yml
22+
secrets: inherit

.github/workflows/module_ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# This is a generic workflow for Puppet module CI operations.
2+
name: "Module CI"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
runs_on:
8+
description: "The operating system used for the runner."
9+
required: false
10+
default: "ubuntu-latest"
11+
type: "string"
12+
flags:
13+
description: "Additional flags to pass to matrix_from_metadata_v2."
14+
required: false
15+
default: ''
16+
type: "string"
17+
18+
jobs:
19+
setup_matrix:
20+
name: "Setup Test Matrix"
21+
runs-on: ${{ inputs.runs_on }}
22+
outputs:
23+
spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }}
24+
25+
steps:
26+
27+
- name: "Checkout"
28+
uses: "actions/checkout@v4"
29+
with:
30+
ref: ${{ github.event.pull_request.head.sha }}
31+
32+
- name: "Setup ruby"
33+
uses: "ruby/setup-ruby@v1"
34+
with:
35+
ruby-version: "2.7"
36+
bundler-cache: true
37+
38+
- name: "Bundle environment"
39+
run: |
40+
echo ::group::bundler environment
41+
bundle env
42+
echo ::endgroup::
43+
44+
- name: Setup Spec Test Matrix
45+
id: get-matrix
46+
run: |
47+
bundle exec matrix_from_metadata_v2 ${{ inputs.flags }}
48+
49+
spec:
50+
name: "Spec tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})"
51+
needs: "setup_matrix"
52+
runs-on: ${{ inputs.runs_on }}
53+
strategy:
54+
fail-fast: false
55+
matrix: ${{ fromJson( needs.setup_matrix.outputs.spec_matrix ) }}
56+
57+
env:
58+
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
59+
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?
60+
61+
steps:
62+
- name: "Checkout"
63+
uses: "actions/checkout@v4"
64+
with:
65+
ref: ${{ github.event.pull_request.head.sha }}
66+
67+
- name: "Setup ruby"
68+
uses: "ruby/setup-ruby@v1"
69+
with:
70+
ruby-version: ${{matrix.ruby_version}}
71+
bundler-cache: true
72+
73+
- name: "Bundle environment"
74+
run: |
75+
echo ::group::bundler environment
76+
bundle env
77+
echo ::endgroup::
78+
79+
- name: "Run Static & Syntax Tests"
80+
run: |
81+
bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
82+
bundle exec dependency-checker metadata.json || true # temporarily allow to fail
83+
84+
- name: "Run tests"
85+
run: |
86+
bundle exec rake parallel_spec

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/log/
1717
/pkg/
1818
/spec/fixtures/manifests/
19-
/spec/fixtures/modules/
19+
/spec/fixtures/modules/*
2020
/tmp/
2121
/vendor/
2222
/convert_report.txt
@@ -25,3 +25,4 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28+
/spec/fixtures/litmus_inventory.yaml

.pdkignore

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/log/
1717
/pkg/
1818
/spec/fixtures/manifests/
19-
/spec/fixtures/modules/
19+
/spec/fixtures/modules/*
2020
/tmp/
2121
/vendor/
2222
/convert_report.txt
@@ -25,18 +25,26 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/appveyor.yml
28+
/spec/fixtures/litmus_inventory.yaml
2929
/.fixtures.yml
3030
/Gemfile
3131
/.gitattributes
32+
/.github/
3233
/.gitignore
33-
/.gitlab-ci.yml
3434
/.pdkignore
35+
/.puppet-lint.rc
3536
/Rakefile
3637
/rakelib/
3738
/.rspec
38-
/.rubocop.yml
39-
/.travis.yml
39+
/..yml
4040
/.yardopts
4141
/spec/
4242
/.vscode/
43+
/.sync.yml
44+
/.devcontainer/
45+
/.*.yml
46+
/pdk.yaml
47+
/.pmtignore
48+
/.git*
49+
/.editorconfig
50+
/provision.yaml

.puppet-lint.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
--relative
2+
--no-parameter_types-check
3+
--no-parameter_documentation-check
4+
--no-documentation-check
5+
--no-140chars-check

.rspec_parallel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--format progress

0 commit comments

Comments
 (0)