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

wip ci #382

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
22 changes: 18 additions & 4 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@ fixtures:
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'
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'
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:
repo: https://github.com/puppetlabs/puppetlabs-cron_core.git
puppet_version: ">= 6.0.0"
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
puppet_version: ">= 6.0.0"
augeas_core:
repo: https://github.com/puppetlabs/puppetlabs-augeas_core.git
puppet_version: ">= 6.0.0"
forge_modules:
firewall:
repo: 'puppetlabs/firewall'
ref: "6.0.0"
symlinks:
puppetdb: '#{source_dir}'
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "ci"

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

jobs:
Unit:
uses: "./.github/workflows/module_unit.yml"
secrets: "inherit"

Acceptance:
needs: Unit
uses: "./.github/workflows/module_acceptance.yml"
secrets: "inherit"
112 changes: 112 additions & 0 deletions .github/workflows/module_acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This is a generic workflow for Puppet module acceptance operations.
name: "Module Acceptance Tests"

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
# platforms with old systemd don't work with the github action runners unprivileged docker setup
default: "--exclude-platforms '[\"redhat-8\",\"redhat-7\",\"Scientific-7\",\"CentOS-7\",\"OracleLinux-7\"]'"
type: "string"

jobs:

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

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- 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 Test Matrix"
id: get-matrix
run: |
bundle exec matrix_from_metadata_v2 ${{ inputs.flags }}

acceptance:
name: "Test (${{matrix.platforms.label}}, ${{matrix.collection}})"
needs: "setup_matrix"
runs-on: ${{ inputs.runs_on }}
timeout-minutes: 180
strategy:
fail-fast: false
max-parallel: 8
matrix: ${{ fromJson( needs.setup_matrix.outputs.acceptance_matrix ) }}

env:
PUPPET_GEM_VERSION: '~> 7.24'
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- 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: "Provision environment"
run: |
if [[ "${{matrix.platforms.provider}}" == "docker" ]]; then
DOCKER_RUN_OPTS="docker_run_opts: {'--volume': '/lib/modules/$(uname -r):/lib/modules/$(uname -r)'}"
else
DOCKER_RUN_OPTS=''
fi
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }},$DOCKER_RUN_OPTS]"
# Redact password
FILE='spec/fixtures/litmus_inventory.yaml'
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true

- name: "Install Puppet agent"
run: |
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'

- name: "Install module"
run: |
bundle exec rake 'litmus:install_modules_from_fixtures'

- name: "Run acceptance tests"
run: |
bundle exec rake 'litmus:acceptance'

- name: "Remove test environment"
if: ${{ always() }}
continue-on-error: true
run: |
if [[ -f spec/fixtures/litmus_inventory.yaml ]]; then
bundle exec rake 'litmus:tear_down'
fi
85 changes: 85 additions & 0 deletions .github/workflows/module_unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This is a generic workflow for Puppet module CI operations.
name: "Module Unit Tests"

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:
fetch-depth: 1

- 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 Test Matrix"
id: get-matrix
run: |
bundle exec matrix_from_metadata_v2 ${{ inputs.flags }}

spec:
name: "Test (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:
fetch-depth: 1

- 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 ci:check ci:syntax ci:lint ci:doc
bundle exec dependency-checker metadata.json || true # temporarily disabled

- name: "Run tests"
run: |
bundle exec rake ci:unit
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
45 changes: 0 additions & 45 deletions .nodeset.yml

This file was deleted.

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
2 changes: 2 additions & 0 deletions .rspec_parallel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format progress
Loading