Skip to content

Commit 6ceb3db

Browse files
committed
Introduce pre-commit & GitHub Actions for it
Change-Id: I4604d13e5ccf74ec4c7088a40a9f7f915f9b1293
1 parent 1c9f069 commit 6ceb3db

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/build/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: build
2+
3+
runs:
4+
using: composite
5+
6+
steps:
7+
- name: Install dependencies
8+
shell: bash
9+
run: pip install pre-commit
10+
11+
- name: Lint
12+
shell: bash
13+
run: pre-commit run --all

.github/workflows/gerrit.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: gerrit checks
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
type: string
8+
gerrit-ref:
9+
type: string
10+
change:
11+
type: string
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: lineageos-infra/fetch-gerrit-change@main
18+
with:
19+
gerrit-ref: ${{ inputs.gerrit-ref }}
20+
ref: ${{ inputs.ref }}
21+
22+
- name: Check if build/action.yml exists
23+
id: check
24+
run: |
25+
if [ -f ./.github/workflows/build/action.yml ]; then
26+
echo "run=1" >> "$GITHUB_OUTPUT"
27+
fi
28+
29+
- name: Build
30+
if: ${{ steps.check.outputs.run }}
31+
uses: ./.github/workflows/build
32+
33+
- uses: lineageos-infra/gerrit-vote@main
34+
if: ${{ steps.check.outputs.run && always() }}
35+
with:
36+
auth: ${{ secrets.GERRIT_VOTE_CREDS }}
37+
change: ${{ inputs.change }}
38+
ref: ${{ inputs.ref }}

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
12+
rev: v2.15.0
13+
hooks:
14+
- id: pretty-format-kotlin
15+
args: [--autofix, --ktfmt, --ktfmt-style=kotlinlang]

0 commit comments

Comments
 (0)