Skip to content
Draft
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
54 changes: 54 additions & 0 deletions .github/scripts/pdk_validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3

import xml.etree.ElementTree as et
import sys

PUPPET_MODULE=""

def parse_pdk_validate_results() -> et.ElementTree:
"""
Parse the xml file and return the tree

Returns:
et.ElementTree: The parsed tree
"""
tree = et.parse(sys.stdin)
return tree

def add_annotation(testcase:et.Element):
"""
Writes Github commands to stdout to add annotations to the Github Actions

Args:
testcase (et.Element): The testcase to add the annotation for
"""
check=testcase[0].get("classname")
file,line,column=testcase[0].get("name").split(":")
kind="error" if testcase[1].get("type")=="error" else "warning"
message=testcase[1].get("message")
print(f"::{kind} file={PUPPET_MODULE}/{file},line={line},col={column},title={check}::{message}")

def scan_testcases(only_errors:bool):
"""
Scan the test cases

Args:
only_errors (bool): Only scan for errors
"""
root = parse_pdk_validate_results().getroot()

for testcase in root.iter("testcase"):
failure = testcase.find("failure")
if failure is None:
continue
if only_errors and failure.get("type")!="error":
continue
add_annotation([testcase, failure])

def main(only_errors):
scan_testcases(only_errors)

if __name__ == "__main__":
if "--module" in sys.argv:
PUPPET_MODULE=sys.argv[sys.argv.index("--module")+1]
main(sys.argv[1]=="--only-errors")
30 changes: 30 additions & 0 deletions .github/workflows/pdk_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PDK Tests

on: pull_request

jobs:
run-pdk-tests:
name: Run PDK tests
runs-on: ubuntu-latest
env:
PUPPET_MODULE: site/profile

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PDK
run: |
wget https://apt.puppet.com/puppet-tools-release-jammy.deb
sudo dpkg -i puppet-tools-release-jammy.deb
sudo apt-get update
sudo apt-get install pdk

- name: Run PDK validate
run: pdk validate --format=junit | "${{github.workspace}}/.github/scripts/pdk_validate" --only-errors --module ${{env.PUPPET_MODULE}}
working-directory: "${{env.PUPPET_MODULE}}"

- name: Run PDK unit test
run: pdk test unit
continue-on-error: true
working-directory: "${{env.PUPPET_MODULE}}"
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.5'
ruby-version: "2.7"
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Test with Rake
run: |
Expand Down
6 changes: 6 additions & 0 deletions site/profile/.fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file can be used to install module dependencies for unit testing
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
---
fixtures:
forge_modules:
# stdlib: "puppetlabs/stdlib"
5 changes: 5 additions & 0 deletions site/profile/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.rb eol=lf
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
35 changes: 35 additions & 0 deletions site/profile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.git/
.*.sw[op]
.metadata
.yardoc
.yardwarns
*.iml
/.bundle/
/.idea/
/.vagrant/
/coverage/
/bin/
/doc/
/Gemfile.local
/Gemfile.lock
/junit/
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
51 changes: 51 additions & 0 deletions site/profile/.pdkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.git/
.*.sw[op]
.metadata
.yardoc
.yardwarns
*.iml
/.bundle/
/.idea/
/.vagrant/
/coverage/
/bin/
/doc/
/Gemfile.local
/Gemfile.lock
/junit/
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
/.fixtures.yml
/Gemfile
/.gitattributes
/.github/
/.gitignore
/.pdkignore
/.puppet-lint.rc
/Rakefile
/rakelib/
/.rspec
/..yml
/.yardopts
/spec/
/.vscode/
/.sync.yml
/.devcontainer/
9 changes: 9 additions & 0 deletions site/profile/.puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--fail-on-warnings
--relative
--no-80chars-check
--no-140chars-check
--no-class_inherits_from_params_class-check
--no-autoloader_layout-check
--no-documentation-check
--no-single_quote_string_with_variables-check
--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp
2 changes: 2 additions & 0 deletions site/profile/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format documentation
Loading
Loading