Skip to content

Commit

Permalink
ci: separate unit test jobs so they can run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
awownysz-splunk committed Dec 5, 2023
1 parent 3c09a0a commit 7cbd574
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/reusable-lightweight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ name: lightweight-check

on:
workflow_call:
inputs:
marker:
required: false
description: 'Parallel run marker'
type: string
default: >-
[""]
secrets:
SA_GH_USER_NAME:
description: GPG signature username
Expand Down Expand Up @@ -159,16 +151,16 @@ jobs:
# uses: ./.github/actions/test-inventory
uses: splunk/addonfactory-workflow-addon-release/.github/actions/test-inventory@ci/lightweight-workflow-ADDON-66448

run-unit-tests:
# Two separate unit test jobs needed as jobs that depend on unit-test success can't proceed
# if any matrix job fails. Currently python 3.9 always fails as it's not supported.
# TODO: group these jobs into the matrix once python 3.9 is supported

run-unit-tests-3_7:
name: Unit tests
if: ${{ needs.test-inventory.outputs.unit == 'true' }}
runs-on: ubuntu-latest
continue-on-error: true
needs:
- test-inventory
outputs:
result-3_7: ${{ steps.unit-tests-3_7.outcome }}
result-3_9: ${{ steps.unit-tests-3_9.outcome }}
permissions:
actions: read
deployments: read
Expand All @@ -183,17 +175,29 @@ jobs:
uses: splunk/addonfactory-workflow-addon-release/.github/actions/unit-tests@ci/lightweight-workflow-ADDON-66448
with:
python_version: '3.7'

run-unit-tests-3_9:
name: Unit tests
if: ${{ needs.test-inventory.outputs.unit == 'true' }}
runs-on: ubuntu-latest
continue-on-error: true
needs:
- test-inventory
permissions:
actions: read
deployments: read
contents: read
packages: read
statuses: read
checks: write
steps:
- name: Run unit tests for python 3.9
id: unit-tests-3_9
# uses: ./.github/actions/unit-tests
uses: splunk/addonfactory-workflow-addon-release/.github/actions/unit-tests@ci/lightweight-workflow-ADDON-66448
with:
python_version: '3.9'

# Two separate unit test steps needed as jobs that depend on unit-test success can't proceed
# if any matrix job fails. Currently python 3.9 always fails as it's not supported.
# TODO: group these jobs into the matrix once python 3.9 is supported

build:
name: Build python-${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand All @@ -204,14 +208,14 @@ jobs:
- lint
- review-secrets
- semgrep
- run-unit-tests
- run-unit-tests-3_7
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.9"
if: ${{ !cancelled() && (needs.run-unit-tests.outputs.result-3_7 == 'success' || needs.run-unit-tests.result == 'skipped') }}
if: ${{ !cancelled() && (needs.run-unit-tests-3_7.result == 'success' || needs.run-unit-tests-3_7.result == 'skipped') }}
permissions:
contents: write
packages: read
Expand Down

0 comments on commit 7cbd574

Please sign in to comment.