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

Add inputs for unit test for selection the self-hosted runner #201

Merged
merged 8 commits into from
Sep 19, 2023
Merged
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
67 changes: 58 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
type: boolean
description: Whether to use self-hosted runners to run the jobs.
default: true
self-hosted-runner-label:
type: string
description: Label for selecting the self-hosted runners.
default: "large"
pre-run-script:
description: Path to the bash script to be run before the integration tests
type: string
Expand All @@ -25,7 +29,12 @@ concurrency:
jobs:
inclusive-naming-check:
name: Inclusive naming
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
yhaliaw marked this conversation as resolved.
Show resolved Hide resolved
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand Down Expand Up @@ -69,7 +78,12 @@ jobs:
uses: ./.github/workflows/get_runner_image.yaml
shellcheck-lint:
name: Shell scripts lint
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand Down Expand Up @@ -133,7 +147,12 @@ jobs:
run: shellcheck -f gcc ${{steps.gather.outputs.filepaths}}
docker-lint:
name: Dockerfile lint
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand All @@ -150,7 +169,12 @@ jobs:
dockerfile: "${{ steps.dockerfiles.outputs.found }}"
metadata-lint:
name: Lint metadata.yaml
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand All @@ -168,8 +192,13 @@ jobs:
check-jsonschema metadata.yaml --schemafile metadata.schema
lint-and-unit-test:
name: Lint and unit tests
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
needs: get-runner-image
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand Down Expand Up @@ -293,7 +322,12 @@ jobs:
path: report.json
draft-publish-docs:
name: Draft publish docs
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand All @@ -313,7 +347,12 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
license-headers-check:
name: Check license headers
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
Expand All @@ -332,7 +371,12 @@ jobs:
config: .licenserc.yaml
lib-check:
name: Check libraries
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
steps:
- uses: actions/[email protected]
- name: Check libs
Expand All @@ -343,7 +387,6 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
required_status_checks:
name: Required Test Status Checks
runs-on: ${{ inputs.self-hosted-runner && fromJson('[''self-hosted'', ''large'']') || 'ubuntu-22.04' }}
needs:
- draft-publish-docs
- docker-lint
Expand All @@ -353,6 +396,12 @@ jobs:
- metadata-lint
- shellcheck-lint
- license-headers-check
runs-on: >-
${{
inputs.self-hosted-runner &&
fromJson(format('[''self-hosted'', ''{0}'']', inputs.self-hosted-runner-label)) ||
'ubuntu-22.04'
}}
if: always() && !cancelled()
timeout-minutes: 5
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/workflow_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
working-directory: "tests/workflows/integration/test-upload-charm/"
self-hosted-runner: true
self-hosted-runner-label: "edge"
integration:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The following workflows are available:
|--------------------|----------|--------------------|-------------------|
| working-directory | string | "./" | Directory where jobs should be executed |
| self-hosted-runner | bool | true | Whether self-hosted-runner should be enabled |
| self-hosted-runner-label| string | large | Label used to select the self-hosted runner if enabled |
| pre-run-script | string | "" | Path to the bash script to be run before the integration tests |

* comment: Posts the content of the artifact specified as a comment in a PR. It needs to be triggered from a PR triggered workflow.
Expand Down
Loading