Skip to content

Commit

Permalink
CI: Add GHA 'local' verify job
Browse files Browse the repository at this point in the history
Change-Id: I792f53af6e53f1f509f0bdff9ddf67008b46f007
Signed-off-by: Andrew Grimberg <[email protected]>
  • Loading branch information
tykeal committed Sep 12, 2023
1 parent 0b38eba commit 9e4a775
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{json,yaml,yml}]
indent_size = 2

[*.markdown]
max_line_length = 80

[*.py]
max_line_legth = 120

[*.sh]
max_line_length = 80
127 changes: 127 additions & 0 deletions .github/workflows/gerrit-verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
name: Gerrit Verify

# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
GERRIT_BRANCH:
description: 'Branch that change is against'
required: true
type: string
GERRIT_CHANGE_ID:
description: 'The ID for the change'
required: true
type: string
GERRIT_CHANGE_NUMBER:
description: 'The Gerrit number'
required: true
type: string
GERRIT_CHANGE_URL:
description: 'URL to the change'
required: true
type: string
GERRIT_EVENT_TYPE:
description: 'Type of Gerrit event'
required: true
type: string
GERRIT_PATCHSET_NUMBER:
description: 'The patch number for the change'
required: true
type: string
GERRIT_PATCHSET_REVISION:
description: 'The revision sha'
required: true
type: string
GERRIT_PROJECT:
description: 'Project in Gerrit'
required: true
type: string
GERRIT_REFSPEC:
description: 'Gerrit refspec of change'
required: true
type: string


concurrency:
group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
cancel-in-progress: true


jobs:
clear-vote:
runs-on: ubuntu-latest
steps:
- name: Clear votes
# yamllint disable-line rule:line-length
uses: lfit/gerrit-review-action@6ac4c2322b68c0120a9b516eb0421491ee1b3fdf # v0.4
with:
host: ${{ vars.GERRIT_SERVER }}
username: ${{ vars.GERRIT_SSH_USER }}
key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
vote-type: clear
- name: Allow replication
run: sleep 10s

actionlint:
needs: clear-vote
runs-on: ubuntu-latest
steps:
- name: Checkout change
# yamllint disable-line rule:line-length
uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
with:
gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
gerrit-project: ${{ inputs.GERRIT_PROJECT }}
gerrit-url: ${{ vars.GERRIT_URL }}
delay: "0s"
- name: Download actionlint
id: get_actionlint
# yamllint disable-line rule:line-length
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash


pre-commit:
needs: clear-vote
runs-on: ubuntu-latest
steps:
- name: Checkout change
# yamllint disable-line rule:line-length
uses: lfit/checkout-gerrit-change-action@57bf0435f739fbbc7ce4cc85c9c3b8a386c6f84b # v0.6
with:
gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
gerrit-project: ${{ inputs.GERRIT_PROJECT }}
gerrit-url: ${{ vars.GERRIT_URL }}
delay: "0s"
- name: Configure Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Run static analysis and format checkers
# yamllint disable-line rule:line-length
run: SKIP=actionlint pipx run pre-commit run --all-files --show-diff-on-failure

vote:
if: ${{ always() }}
needs: [clear-vote, actionlint, pre-commit]
runs-on: ubuntu-latest
steps:
- uses: technote-space/workflow-conclusion-action@v3
- name: Set vote
# yamllint disable-line rule:line-length
uses: lfit/gerrit-review-action@6ac4c2322b68c0120a9b516eb0421491ee1b3fdf # v0.4
with:
host: ${{ vars.GERRIT_SERVER }}
username: ${{ vars.GERRIT_SSH_USER }}
key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
vote-type: ${{ env.WORKFLOW_CONCLUSION }}
30 changes: 30 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# All these sections are optional, edit this file as you like.
[general]
# Ignore certain rules, you can reference them by their id or by their full
# name
# ignore=title-trailing-punctuation, T3

# verbosity should be a value between 1 and 3, the command line -v flags take
# precedence over this
# verbosity = 2

# By default gitlint will ignore merge commits. Set to 'false' to disable.
# ignore-merge-commits=true

# By default gitlint will ignore fixup commits. Set to 'false' to disable.
# ignore-fixup-commits=true

# By default gitlint will ignore squash commits. Set to 'false' to disable.
# ignore-squash-commits=true

# Enable debug mode (prints more output). Disabled by default.
# debug=true

# Set the extra-path where gitlint will search for user defined rules
# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
# extra-path=examples/

contrib=contrib-title-conventional-commits,contrib-body-requires-signed-off-by

[contrib-title-conventional-commits]
types=Fix,Feat,Chore,Docs,Style,Refactor,Perf,Test,Revert,CI,Build
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
ci:
autofix_commit_msg: "Chore: pre-commit autoupdate"
skip:
# pre-commit.ci does not have actionlint installed
- actionlint

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: no-commit-to-branch
args:
- --branch=dev
- --branch=master
- --branch=main
- --branch=rc
- --branch=production

- repo: https://github.com/jorisroovers/gitlint
rev: acc9d9de6369b76d22cb4167029d2035e8730b98 # frozen: v0.19.1
hooks:
- id: gitlint

- repo: https://github.com/adrienverge/yamllint.git
rev: b05e028c5881819161d11cb543fd96a30c06cceb # frozen: v1.32.0
hooks:
- id: yamllint
types: [yaml]

- repo: https://github.com/rhysd/actionlint
rev: fd7ba3c382e13dcc0248e425b4cbc3f1185fa3ee # frozen: v1.6.24
hooks:
- id: actionlint

0 comments on commit 9e4a775

Please sign in to comment.