Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize test framework and add ci workflow #385

Merged
merged 10 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}'
h0tw1r3 marked this conversation as resolved.
Show resolved Hide resolved
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
h0tw1r3 marked this conversation as resolved.
Show resolved Hide resolved
--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
Loading