ci: Add linting of workflow and related pre-commit hook (#4032)

* Add actionlint pre-commit hook

* Add workflow to lint workflows

* Remove unused input in Python Cache action

* Move from deprecated set-output syntax to new one

* Add actionlint config to specify self-hosted runners labels
This commit is contained in:
Silvano Cerza 2023-02-02 14:33:23 +01:00 committed by GitHub
parent 2878c57645
commit e62d24d0eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 11 deletions

3
.github/actionlint.yml vendored Normal file
View File

@ -0,0 +1,3 @@
self-hosted-runner:
# Labels of self-hosted runner in array of string
labels: ["cml"]

View File

@ -6,9 +6,6 @@ inputs:
description: 'prefix for the cache (to distinguish OS)'
required: true
default: 'linux'
pythonPath:
description: 'Python path to cache/restore'
required: true
pythonVersion:
description: 'Python version to use'
required: true

View File

@ -7,7 +7,6 @@ jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v3
@ -19,7 +18,7 @@ jobs:
shell: bash
# We only need `major.minor` in Readme so we cut the full version string to the first two tokens
run: |
echo "::set-output name=current_release_minor::$(cat VERSION.txt | cut -d "." -f 1,2)"
echo "current_release_minor=$(cat VERSION.txt | cut -d "." -f 1,2)" >> $GITHUB_OUTPUT
- name: Create new version branch
run: |
@ -31,7 +30,7 @@ jobs:
- name: Bump version on main
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main
cat VERSION.txt | awk -F. '/[0-9]+\./{$2++;print}' OFS=. | tee VERSION.txt

View File

@ -6,21 +6,19 @@ on:
branches:
- main
# release branches have the form v1.9.x
- 'v[0-9].*[0-9].x'
- "v[0-9].*[0-9].x"
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v3
- name: Set up Python 3.8.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"
- name: Install dependencies
run: |
@ -34,7 +32,7 @@ jobs:
id: current-version
shell: bash
# We only need `major.minor` in Readme so we cut the full version string to the first two tokens
run: echo "::set-output name=minor::$(cat VERSION.txt | cut -d "." -f 1,2)"
run: echo "minor=$(cat VERSION.txt | cut -d "." -f 1,2)" >> $GITHUB_OUTPUT
- name: Sync docs with unstable release
# Instead of putting more logic into the previous step, let's just assume that commits on `main`

19
.github/workflows/workflows_linting.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Github workflows linter
on:
pull_request:
paths:
- ".github/workflows"
jobs:
lint-workflows:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install actionlint
run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
- name: Run actionlint
run: actionlint

View File

@ -20,5 +20,9 @@ repos:
hooks:
- id: black-jupyter
- repo: https://github.com/rhysd/actionlint
rev: v1.6.23
hooks:
- id: actionlint
# TODO we can make mypy and pylint run at this stage too, once their execution gets normalized