From 51895f1e5df2a7a3092116b17da10da165bd50b0 Mon Sep 17 00:00:00 2001 From: coreone Date: Tue, 30 Jan 2024 15:00:32 -0500 Subject: [PATCH] fix: remove hard-coded directory for python-unit-test Action (#41) feat: make versions selectable in python, puppet fix: correct puppet-build job name --- .github/workflows/puppet-build.yaml | 2 +- .github/workflows/puppet-unit-test.yaml | 18 ++++++++++----- .github/workflows/python-unit-test.yaml | 19 ++++++++++------ README.md | 29 +++++++++++++++++++------ 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/.github/workflows/puppet-build.yaml b/.github/workflows/puppet-build.yaml index aa98e74..6a00ee6 100644 --- a/.github/workflows/puppet-build.yaml +++ b/.github/workflows/puppet-build.yaml @@ -34,7 +34,7 @@ type: string jobs: - test-deploy: + test-build: defaults: run: working-directory: ${{ inputs.working_directory }} diff --git a/.github/workflows/puppet-unit-test.yaml b/.github/workflows/puppet-unit-test.yaml index 3a5d25b..fc0c9a4 100644 --- a/.github/workflows/puppet-unit-test.yaml +++ b/.github/workflows/puppet-unit-test.yaml @@ -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 @@ -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' diff --git a/.github/workflows/python-unit-test.yaml b/.github/workflows/python-unit-test.yaml index edbfa58..7c90def 100644 --- a/.github/workflows/python-unit-test.yaml +++ b/.github/workflows/python-unit-test.yaml @@ -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 @@ -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 != '' }} @@ -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 != '' }} diff --git a/README.md b/README.md index 56e291f..3287352 100644 --- a/README.md +++ b/README.md @@ -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 @@ -176,10 +186,9 @@ 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 @@ -187,6 +196,12 @@ This workflow will setup a matrix of [Python][5] versions (currently `['3.7', 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