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

Adds basic workflow for pdk based modules #15

Open
wants to merge 2 commits into
base: v1
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions .github/workflows/pdk-basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PDK basic

on:
workflow_call:
inputs:
container_image:
description: Image to use when running tests
default: 'puppet/puppet-dev-tools:2022-04-21-e44b72b'
logicminds marked this conversation as resolved.
Show resolved Hide resolved
required: false
type: string

jobs:
validate:
logicminds marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
container: ${{ inputs.container_image }}
outputs:
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }}
steps:
- uses: actions/checkout@v2
- name: action-pdk-validate-puppet-7
run: pdk validate --puppet-version=7
Comment on lines +21 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make version 7 an input with a default as well. That allows users to trivially override it. Also means switching 7 to 8 is just a one line change instead of two.

- run: gem install puppet_metadata --no-document
- name: Setup Test Matrix
id: get-outputs
run: metadata2gha --use-fqdn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FQDN part is only relevant for Beaker. Doesn't hurt, but it doesn't add anything either. I wonder if I should push it into beaker-hostgenerator itself, perhaps even make it the default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the default



unit-puppet:
needs:
- validate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.validate.outputs.puppet_unit_test_matrix)}}
container: ${{ inputs.container_image }}
steps:
- uses: actions/checkout@v2
- name: action-pdk-test-unit-puppet-${{ matrix.puppet }}
run: pdk test unit --puppet-version=${{ matrix.puppet }}
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,31 @@ jobs:
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
working-directory: ./site/profiles
```

## Cloning private repos
If your CI pipline will clone private repos via the .fixtures.yml or Puppetfile
you will need to supply a ssh private key for the runner to use during the job.

That ssh private key can be a machine user's ssh key, or github deploy key. As long
as the key has access to the repos it will need to clone.

You will need to create a github secret for the private key named `PRIVATE_SSH_KEY`

An example CI workflow is below for this kind of setup.

For reference: https://stackoverflow.com/questions/57612428/cloning-private-github-repository-within-organisation-in-actions


```yaml
name: CI

on: pull_request

jobs:
puppet:
- name: Setup deploy key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it should be a secret that the workflow accepts. Here is where we have an example for the release workflow:

secrets:
username:
description: 'The forge username to use'
required: true
api_key:
description: 'The forge API key'
required: true

(see https://github.com/voxpupuli/gha-puppet#calling-the-release-workflow for how to call it):

Then you can add it as a when: secrets.PRIVATE_SSH_KEY in the workflow and you don't need as much duplication in various workflows.

run: eval `ssh-agent -s` && ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}'
- name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/pdk-basic.yml@master
Comment on lines +240 to +242
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing indenting

Suggested change
run: eval `ssh-agent -s` && ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}'
- name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/pdk-basic.yml@master
run: eval `ssh-agent -s` && ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}'
- name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/pdk-basic.yml@master


```