Skip to content

Commit

Permalink
fix: remove hard-coded directory for python-unit-test Action (#41)
Browse files Browse the repository at this point in the history
feat: make versions selectable in python, puppet
fix: correct puppet-build job name
  • Loading branch information
coreone authored Jan 30, 2024
1 parent e51cd07 commit 51895f1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/puppet-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
type: string

jobs:
test-deploy:
test-build:
defaults:
run:
working-directory: ${{ inputs.working_directory }}
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/puppet-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
description: The runner group on which jobs will run.
required: false
type: string
puppet_versions:
default: '{ "versions": [ "7", "8" ] }'
description: The versions of Puppet on which the unit tests should run.
required: false
type: string
ruby_versions:
default: '{ "versions": [ "3.1", "3.2" ] }'
description: The versions of Ruby on which the unit tests should run.
required: false
type: string
timeout_minutes:
description: The maximum time (in minutes) for a job to run.
default: 5
Expand All @@ -26,12 +36,8 @@ jobs:
runs-on: ${{ inputs.jobs_run_on }}
strategy:
matrix:
puppet:
- '7'
- '8'
ruby:
- '3.1'
- '3.2'
puppet: ${{ fromJSON(inputs.puppet_versions).versions }}
ruby: ${{ fromJSON(inputs.ruby_versions).versions }}
steps:
- name: 'Checkout repo'
uses: 'actions/checkout@v4'
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/python-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ name: Python Checks
description: The runner group on which jobs will run.
required: false
type: string
# python_versions:
# default: ['3.7', '3.8', '3.9', '3.10', '3.11']
# description: The versions of Python on which the unit tests should run.
# required: false
# type: string
python_versions:
default: '{ "versions": [ "3.7", "3.8", "3.9", "3.10", "3.11" ] }'
description: The versions of Python on which the unit tests should run.
required: false
type: string
python_package_name:
default: ''
description: The name of the PyPi package the repo will create.
required: false
type: string
test_targets:
default: ''
description: The directories to target for testing.
required: false
type: string
timeout_minutes:
description: The maximum time (in minutes) for a job to run.
default: 5
Expand All @@ -43,7 +48,7 @@ jobs:
runs-on: ${{ inputs.jobs_run_on }}
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ${{ fromJSON(inputs.python_versions).versions }}
steps:
- name: Install additional packages
if: ${{ inputs.additional_packages != '' }}
Expand All @@ -65,7 +70,7 @@ jobs:
run: poetry install
- name: Test with green
run: |
poetry run green tests
poetry run green ${{ inputs.test_targets }}
poetry run coverage xml
- name: Run a test module build and install
if: ${{ inputs.python_package_name != '' }}
Expand Down
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,19 @@ This workflow will setup [Puppet][7] using

This workflow will setup [Puppet][7] using
[ruby/setup-ruby](https://github.com/ruby/setup-ruby). The testing will happen
on a matrix of [Ruby][8] versions `3.1` and `3.2` and [Puppet][7] versions `7`
and `8`. The dependency installation and unit tests will all happen using
[PDK][9].
on a matrix of [Ruby][8] and [Puppet][7] versions. The dependency installation and unit
tests will all happen using [PDK][9].

#### puppet-unit-test Inputs

* `puppet_versions`: The versions of [Puppet][7] to use in the unit tests, passed as a
string in JSON format with `versions` as the key. Default:
`'{ "versions": [ "7", "8" ] }'`
* **Note: Make sure to enclose the JSON string in single quotes!!**
* `ruby_versions`: The versions of [Ruby][8] to use in the unit tests, passed as a
string in JSON format with `versions` as the key. Default:
`'{ "versions": [ "3.1", "3.2" ] }'`
* **Note: Make sure to enclose the JSON string in single quotes!!**

### python-deploy-to-pypi.yaml

Expand Down Expand Up @@ -176,17 +186,22 @@ This workflow will setup [Python][5] (`3.11`) and do a build and deploy of the

### python-unit-test.yaml

This workflow will setup a matrix of [Python][5] versions (currently `['3.7',
'3.8', '3.9', '3.10', '3.11']`) and run the unit tests for the repository using
[green](https://github.com/CleanCut/green). [Poetry][3] is used to install any
[Python][5] dependencies.
This workflow will setup a matrix of [Python][5] versions and run the unit tests for the
repository using [green](https://github.com/CleanCut/green). [Poetry][3] is used to
install any [Python][5] dependencies.

#### python-unit-test Inputs

* `additional_packages`: String of additional packages that should be
installed. Default: ``
* `python_package_name`: The name of the [PyPi][2] package the repo will
create. Default: ``
* `python_versions`: The versions of [Python][5] to use in the unit tests, passed as a
string in JSON format with `versions` as the key. Default:
`'{ "versions": [ "3.7", "3.8", "3.9", "3.10", "3.11" ] }'`
* **Note: Make sure to enclose the JSON string in single quotes!!**
* `test_targets`: A list of directories to target for testing.
[green](https://github.com/CleanCut/green) will autodetect if left blank. Default: ``

### terraform-lint.yaml

Expand Down

0 comments on commit 51895f1

Please sign in to comment.