* Bump actions/checkout from 4 to 6 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Upgrade Python version from 3.9 to 3.12 as 3.9 is no longer supported and a newer version is a requirement for other updates --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Harry <Harry@cadby.co.uk>
123 lines
4.7 KiB
YAML
123 lines
4.7 KiB
YAML
---
|
|
name: Validate definitions
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.12'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v4
|
|
id: cache-venv
|
|
with:
|
|
path: ${{ env.pythonLocation }}
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -r requirements.txt
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
- name: Lint YAML files
|
|
run: |
|
|
yamllint --format github --strict \
|
|
device-types/ module-types/
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.12'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v4
|
|
id: cache-venv
|
|
with:
|
|
path: ${{ env.pythonLocation }}
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -r requirements.txt
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
- name: Format YAML files (hooks)
|
|
run: pre-commit run --config .pre-commit-hooks-config.yaml --all-files
|
|
- name: Format YAML files (yamlfmt)
|
|
run: pre-commit run --config .pre-commit-yamlfmt-config.yaml --all-files
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: [lint, format]
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.12'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v4
|
|
id: cache-venv-pytest
|
|
with:
|
|
path: ${{ env.pythonLocation }}
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-pytest-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.pythonLocation }}-pytest-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -r requirements.txt
|
|
python -m pip install pytest-github-actions-annotate-failures
|
|
if: steps.cache-venv-pytest.outputs.cache-hit != 'true'
|
|
- name: Run Test Cases
|
|
id: pytest
|
|
run: pytest --tb=short -v
|
|
- name: Check for pickle file change
|
|
id: pickle-change
|
|
uses: tj-actions/changed-files@v46
|
|
with:
|
|
files: tests/known-slugs.pickle
|
|
- name: Add PR Comment if pickle file is modified
|
|
uses: mshick/add-pr-comment@v2
|
|
if: steps.pickle-change.outputs.any_changed == 'true'
|
|
with:
|
|
message: |
|
|
Hello, it appears that you have modified the `tests/known-slugs.pickle` file. This file is automatically generated via a GitHub Action, which contains all currently available slugs. This file should **never** be commited by a contributor in a PR.
|
|
|
|
In order to fix this, you will need to remove the modification on the pickle file. There are a handful of ways to do so but often it is easiest to revert the commit and force push it again without the pickle file included. If you need assistance you are welcome to ping a maintainer via this PR, or via our NetDev Slack.
|
|
- name: Add Labels if pickle file is modified
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
if: steps.pickle-change.outputs.any_changed == 'true'
|
|
with:
|
|
labels: |
|
|
status: revisions needed
|
|
status: pickle-issue
|
|
- uses: actions-ecosystem/action-remove-labels@v1
|
|
if: steps.pickle-change.outputs.any_changed != 'true'
|
|
with:
|
|
labels: |
|
|
status: pickle-issue
|