Skip to content

Commit

Permalink
Merge pull request #385 from h0tw1r3/unit-testing
Browse files Browse the repository at this point in the history
modernize test framework and add ci workflow
  • Loading branch information
bastelfreak authored Jan 31, 2024
2 parents 4bed77e + 6663970 commit 8aaf63c
Show file tree
Hide file tree
Showing 74 changed files with 6,292 additions and 1,514 deletions.
18 changes: 14 additions & 4 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ fixtures:
repositories:
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
postgresql: 'https://github.com/puppetlabs/puppet-postgresql.git'
firewall: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
apt: 'https://github.com/puppetlabs/puppetlabs-apt.git'
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
file_concat: 'https://github.com/electrical/puppet-lib-file_concat.git'
systemd: 'https://github.com/camptocamp/puppet-systemd.git'
cron: 'https://github.com/voxpupuli/puppet-cron.git'
provision: 'https://github.com/puppetlabs/provision.git'
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
cron_core: 'https://github.com/puppetlabs/puppetlabs-cron_core.git'
yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core.git'
augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core.git'
postgresql: 'https://github.com/puppetlabs/puppetlabs-postgresql.git'
firewall: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
forge_modules:
postgresql:
repo: 'puppetlabs/postgresql'
ref: "9.2.0"
firewall:
repo: 'puppetlabs/firewall'
ref: "6.0.0"
symlinks:
puppetdb: '#{source_dir}'
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "ci"

on:
pull_request:
branches:
- "main"
paths-ignore:
- '**.md'
- 'examples/**'
- 'LICENSE'
- 'CODEOWNERS'
- 'AUTHORS'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Spec:
uses: ./.github/workflows/module_ci.yml
secrets: inherit
86 changes: 86 additions & 0 deletions .github/workflows/module_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This is a generic workflow for Puppet module CI operations.
name: "Module CI"

on:
workflow_call:
inputs:
runs_on:
description: "The operating system used for the runner."
required: false
default: "ubuntu-latest"
type: "string"
flags:
description: "Additional flags to pass to matrix_from_metadata_v2."
required: false
default: ''
type: "string"

jobs:
setup_matrix:
name: "Setup Test Matrix"
runs-on: ${{ inputs.runs_on }}
outputs:
spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }}

steps:

- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "2.7"
bundler-cache: true

- name: "Bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: Setup Spec Test Matrix
id: get-matrix
run: |
bundle exec matrix_from_metadata_v2 ${{ inputs.flags }}
spec:
name: "Spec tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})"
needs: "setup_matrix"
runs-on: ${{ inputs.runs_on }}
strategy:
fail-fast: false
matrix: ${{ fromJson( needs.setup_matrix.outputs.spec_matrix ) }}

env:
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: ${{matrix.ruby_version}}
bundler-cache: true

- name: "Bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "Run Static & Syntax Tests"
run: |
bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
bundle exec dependency-checker metadata.json || true # temporarily allow to fail
- name: "Run tests"
run: |
bundle exec rake parallel_spec
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
Expand All @@ -25,3 +25,4 @@
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
18 changes: 13 additions & 5 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
Expand All @@ -25,18 +25,26 @@
.project
.envrc
/inventory.yaml
/appveyor.yml
/spec/fixtures/litmus_inventory.yaml
/.fixtures.yml
/Gemfile
/.gitattributes
/.github/
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/.puppet-lint.rc
/Rakefile
/rakelib/
/.rspec
/.rubocop.yml
/.travis.yml
/..yml
/.yardopts
/spec/
/.vscode/
/.sync.yml
/.devcontainer/
/.*.yml
/pdk.yaml
/.pmtignore
/.git*
/.editorconfig
/provision.yaml
4 changes: 4 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
--relative
--no-parameter_types-check
--no-parameter_documentation-check
--no-documentation-check
--no-140chars-check
1 change: 1 addition & 0 deletions .rspec_parallel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--format progress
Loading

0 comments on commit 8aaf63c

Please sign in to comment.