ci: add always_run input to checks & tests, use this on release workflow

This bypasses the `changed-files` check, and forces the checks to run. The release workflow sets this flag to ensure that the checks and tests are always run for a release.
This commit is contained in:
psychedelicious 2024-03-12 18:19:41 +11:00
parent d0d695c020
commit efea1a8a7d
5 changed files with 79 additions and 23 deletions

View File

@ -1,7 +1,7 @@
# Runs frontend code quality checks. # Runs frontend code quality checks.
# #
# Checks for changes to frontend files before running the checks. # Checks for changes to frontend files before running the checks.
# When manually triggered or when called from another workflow, always runs the checks. # If always_run is true, always runs the checks.
name: 'frontend checks' name: 'frontend checks'
@ -16,7 +16,19 @@ on:
- 'synchronize' - 'synchronize'
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
inputs:
always_run:
description: 'Always run the checks'
required: true
type: boolean
default: true
workflow_call: workflow_call:
inputs:
always_run:
description: 'Always run the checks'
required: true
type: boolean
default: true
defaults: defaults:
run: run:
@ -30,7 +42,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: check for changed frontend files - name: check for changed frontend files
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' }} if: ${{ inputs.always_run != true }}
id: changed-files id: changed-files
uses: tj-actions/changed-files@v42 uses: tj-actions/changed-files@v42
with: with:
@ -39,30 +51,30 @@ jobs:
- 'invokeai/frontend/web/**' - 'invokeai/frontend/web/**'
- name: install dependencies - name: install dependencies
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
uses: ./.github/actions/install-frontend-deps uses: ./.github/actions/install-frontend-deps
- name: tsc - name: tsc
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm lint:tsc' run: 'pnpm lint:tsc'
shell: bash shell: bash
- name: dpdm - name: dpdm
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm lint:dpdm' run: 'pnpm lint:dpdm'
shell: bash shell: bash
- name: eslint - name: eslint
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm lint:eslint' run: 'pnpm lint:eslint'
shell: bash shell: bash
- name: prettier - name: prettier
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm lint:prettier' run: 'pnpm lint:prettier'
shell: bash shell: bash
- name: knip - name: knip
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm lint:knip' run: 'pnpm lint:knip'
shell: bash shell: bash

View File

@ -1,7 +1,7 @@
# Runs frontend tests. # Runs frontend tests.
# #
# Checks for changes to frontend files before running the tests. # Checks for changes to frontend files before running the tests.
# When manually triggered or called from another workflow, always runs the tests. # If always_run is true, always runs the tests.
name: 'frontend tests' name: 'frontend tests'
@ -16,7 +16,19 @@ on:
- 'synchronize' - 'synchronize'
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
inputs:
always_run:
description: 'Always run the tests'
required: true
type: boolean
default: true
workflow_call: workflow_call:
inputs:
always_run:
description: 'Always run the tests'
required: true
type: boolean
default: true
defaults: defaults:
run: run:
@ -30,7 +42,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: check for changed frontend files - name: check for changed frontend files
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' }} if: ${{ inputs.always_run != true }}
id: changed-files id: changed-files
uses: tj-actions/changed-files@v42 uses: tj-actions/changed-files@v42
with: with:
@ -39,10 +51,10 @@ jobs:
- 'invokeai/frontend/web/**' - 'invokeai/frontend/web/**'
- name: install dependencies - name: install dependencies
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
uses: ./.github/actions/install-frontend-deps uses: ./.github/actions/install-frontend-deps
- name: vitest - name: vitest
if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.frontend_any_changed == 'true' || inputs.always_run == true }}
run: 'pnpm test:no-watch' run: 'pnpm test:no-watch'
shell: bash shell: bash

View File

@ -1,7 +1,7 @@
# Runs python code quality checks. # Runs python code quality checks.
# #
# Checks for changes to python files before running the checks. # Checks for changes to python files before running the checks.
# When manually triggered or called from another workflow, always runs the tests. # If always_run is true, always runs the checks.
# #
# TODO: Add mypy or pyright to the checks. # TODO: Add mypy or pyright to the checks.
@ -18,7 +18,19 @@ on:
- 'synchronize' - 'synchronize'
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
inputs:
always_run:
description: 'Always run the checks'
required: true
type: boolean
default: true
workflow_call: workflow_call:
inputs:
always_run:
description: 'Always run the checks'
required: true
type: boolean
default: true
jobs: jobs:
python-checks: python-checks:
@ -29,7 +41,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: check for changed python files - name: check for changed python files
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' }} if: ${{ inputs.always_run != true }}
id: changed-files id: changed-files
uses: tj-actions/changed-files@v42 uses: tj-actions/changed-files@v42
with: with:
@ -41,7 +53,7 @@ jobs:
- 'tests/**' - 'tests/**'
- name: setup python - name: setup python
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.10' python-version: '3.10'
@ -49,16 +61,16 @@ jobs:
cache-dependency-path: pyproject.toml cache-dependency-path: pyproject.toml
- name: install ruff - name: install ruff
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
run: pip install ruff run: pip install ruff
shell: bash shell: bash
- name: ruff check - name: ruff check
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
run: ruff check --output-format=github . run: ruff check --output-format=github .
shell: bash shell: bash
- name: ruff format - name: ruff format
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
run: ruff format --check . run: ruff format --check .
shell: bash shell: bash

View File

@ -1,7 +1,7 @@
# Runs python tests on a matrix of python versions and platforms. # Runs python tests on a matrix of python versions and platforms.
# #
# Checks for changes to python files before running the tests. # Checks for changes to python files before running the tests.
# When manually triggered or called from another workflow, always runs the tests. # If always_run is true, always runs the tests.
name: 'python tests' name: 'python tests'
@ -16,7 +16,19 @@ on:
- 'synchronize' - 'synchronize'
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
inputs:
always_run:
description: 'Always run the tests'
required: true
type: boolean
default: true
workflow_call: workflow_call:
inputs:
always_run:
description: 'Always run the tests'
required: true
type: boolean
default: true
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@ -63,7 +75,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: check for changed python files - name: check for changed python files
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' }} if: ${{ inputs.always_run != true }}
id: changed-files id: changed-files
uses: tj-actions/changed-files@v42 uses: tj-actions/changed-files@v42
with: with:
@ -75,7 +87,7 @@ jobs:
- 'tests/**' - 'tests/**'
- name: setup python - name: setup python
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
@ -83,12 +95,12 @@ jobs:
cache-dependency-path: pyproject.toml cache-dependency-path: pyproject.toml
- name: install dependencies - name: install dependencies
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
env: env:
PIP_EXTRA_INDEX_URL: ${{ matrix.extra-index-url }} PIP_EXTRA_INDEX_URL: ${{ matrix.extra-index-url }}
run: > run: >
pip3 install --editable=".[test]" pip3 install --editable=".[test]"
- name: run pytest - name: run pytest
if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} if: ${{ steps.changed-files.outputs.python_any_changed == 'true' || inputs.always_run == true }}
run: pytest run: pytest

View File

@ -30,15 +30,23 @@ jobs:
frontend-checks: frontend-checks:
uses: ./.github/workflows/frontend-checks.yml uses: ./.github/workflows/frontend-checks.yml
with:
always_run: true
frontend-tests: frontend-tests:
uses: ./.github/workflows/frontend-tests.yml uses: ./.github/workflows/frontend-tests.yml
with:
always_run: true
python-checks: python-checks:
uses: ./.github/workflows/python-checks.yml uses: ./.github/workflows/python-checks.yml
with:
always_run: true
python-tests: python-tests:
uses: ./.github/workflows/python-tests.yml uses: ./.github/workflows/python-tests.yml
with:
always_run: true
build: build:
uses: ./.github/workflows/build-installer.yml uses: ./.github/workflows/build-installer.yml