Skip to content

Commit 1f8b69e

Browse files
committed
Added yamllint pre-commit hook
1 parent 73bf4d7 commit 1f8b69e

File tree

12 files changed

+88
-42
lines changed

12 files changed

+88
-42
lines changed

.codeclimate.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
version: "2" # Required to adjust maintainability checks
23

3-
checks: # https://docs.codeclimate.com/docs/maintainability#section-checks
4+
checks: # https://docs.codeclimate.com/docs/maintainability#section-checks
45
argument-count:
56
config:
67
threshold: 7
@@ -10,7 +11,7 @@ checks: # https://docs.codeclimate.com/docs/maintainability#section-checks
1011
file-lines:
1112
config:
1213
threshold: 500
13-
method-complexity: # https://docs.codeclimate.com/docs/cognitive-complexity
14+
method-complexity: # https://docs.codeclimate.com/docs/cognitive-complexity
1415
config:
1516
threshold: 5
1617
method-count:
@@ -25,7 +26,7 @@ checks: # https://docs.codeclimate.com/docs/maintainability#section-checks
2526
return-statements:
2627
config:
2728
threshold: 4
28-
similar-code: # https://docs.codeclimate.com/docs/duplication-concept
29+
similar-code: # https://docs.codeclimate.com/docs/duplication-concept
2930
config:
3031
threshold: # Language-specific defaults; an override will affect all languages
3132
identical-code:
@@ -43,7 +44,7 @@ plugins:
4344
pep8:
4445
enabled: true
4546
checks:
46-
E501: # Line too long (> 79 characters)
47+
E501: # Line too long (> 79 characters)
4748
enabled: false
4849
# https://docs.codeclimate.com/docs/radon
4950
radon:

.github/actions/install-dependencies/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ runs:
1919

2020
- name: Install System Dependencies
2121
shell: bash
22-
# Retries installing files 3 times, as either the GitHub Actions runner or APT's API can be unreliable
22+
# Retries installing files 3 times, as either the GitHub Actions runner or APT's
23+
# API can be unreliable
2324
run: |
2425
sudo apt update
2526
sudo apt install python3-dev libldap2-dev libsasl2-dev libssl-dev -o Acquire::Retries=3

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
version: 2
23
updates:
34
- package-ecosystem: "uv"

.github/workflows/_reusable_add-content-to-project.yml

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
1-
# This is a reusable workflow; see https://docs.github.com/en/actions/using-workflows/reusing-workflows.
2-
# It was created because GitHub projects' workflows (see e.g. https://github.com/orgs/MAKENTNU/projects/1/workflows)
3-
# don't (currently) support doing the specific things done in the steps below.
1+
---
2+
# This is a reusable workflow - see
3+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows.
4+
# It was created because GitHub projects' workflows (see e.g.
5+
# https://github.com/orgs/MAKENTNU/projects/1/workflows) don't (currently) support doing
6+
# the specific things done in the steps below.
47
#
58
# The workflow requires that the following repository variables have been created:
6-
# - `ORGANIZATION_PROJECT_NUMBER` - The number/ID in the project URL (https://github.com/orgs/MAKENTNU/projects/1)
9+
# - `ORGANIZATION_PROJECT_NUMBER` - The number/ID in the project URL
10+
# (https://github.com/orgs/MAKENTNU/projects/1)
711
# - `ORGANIZATION_PROJECT__DATE_FIELD_NAME` - The name of the project's date field
8-
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` - The value of the 'Status' field set for an item when closed
9-
# (see https://github.com/orgs/MAKENTNU/projects/1/workflows/3569450)
10-
# and the following organization variables:
11-
# - `ORGANIZATION_NAME` - The name of the organization in the project URL (https://github.com/orgs/MAKENTNU/projects/1)
12+
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` - The value of the 'Status'
13+
# field set for an item when closed (see
14+
# https://github.com/orgs/MAKENTNU/projects/1/workflows/3569450)
15+
# ...and the following organization variables:
16+
# - `ORGANIZATION_NAME` - The name of the organization in the project URL
17+
# (https://github.com/orgs/MAKENTNU/projects/1)
1218
#
13-
# The workflow also expects that the following project workflows are turned on for the project:
19+
# The workflow also expects that the following project workflows are turned on for
20+
# the project:
1421
# - "Item closed" (https://github.com/orgs/MAKENTNU/projects/1/workflows/3569450):
1522
# - "When an item is closed": "issue, pull request"
16-
# - "Set value": "Status: <the value of the `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` repository variable>"
17-
# and that the following project workflows are turned off:
23+
# - "Set value": "Status: <the value of
24+
# the `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` repository variable>"
25+
# ...and that the following project workflows are turned off:
1826
# - "Item added to project"
1927
# - "Item reopened"
20-
# (The "Pull request merged" project workflow (https://github.com/orgs/MAKENTNU/projects/1/workflows/3569451)
21-
# does not affect and is not affected by any of this.
22-
# However, it could be natural that it sets the same value as the "Item closed" project workflow.)
28+
# (The "Pull request merged" project workflow
29+
# (https://github.com/orgs/MAKENTNU/projects/1/workflows/3569451) does not affect and is
30+
# not affected by any of this. However, it could be natural that it sets the same value
31+
# as the "Item closed" project workflow.)
2332

2433
name: Add content to project
2534

2635
on:
2736
workflow_call:
2837
inputs:
2938
content_id:
30-
description: "The ID of an issue or a PR, to be added to this repo's GitHub project"
39+
description: >
40+
The ID of an issue or a PR, to be added to this repo's GitHub project
3141
required: true
3242
type: string
3343
status_field_value_name:
34-
description: "The name of one of the values of the project's (single select) 'Status' field, to set for the added project item"
44+
description: >
45+
The name of one of the values of the project's (single select) 'Status' field,
46+
to set for the added project item
3547
required: true
3648
type: string
3749

3850
jobs:
3951
add_content:
4052
runs-on: ubuntu-latest
41-
# Code based on https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions#example-workflow-authenticating-with-a-github-app
53+
# Code based on
54+
# https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions#example-workflow-authenticating-with-a-github-app
4255
steps:
4356
- name: Generate token
4457
id: generate_token
45-
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
58+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
4659
with:
4760
app_id: ${{ secrets.MAKE_BOT_APP_ID }}
4861
private_key: ${{ secrets.MAKE_BOT_APP_PEM }}
@@ -89,7 +102,8 @@ jobs:
89102
echo "DATE_FIELD_ID=$(jq --arg FIELD_NAME "$DATE_FIELD_NAME" -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD_NAME) | .id' project_data.json)"
90103
# The ID of the project's status field
91104
echo "STATUS_FIELD_ID=$(jq --arg FIELD_NAME "$STATUS_FIELD_NAME" -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD_NAME) | .id' project_data.json)"
92-
# The ID of one of the values of the project's (single select) status field, with name `inputs.status_field_value_name`
105+
# The ID of one of the values of the project's (single select) status field,
106+
# with name `inputs.status_field_value_name`
93107
echo "STATUS_FIELD_VALUE_ID=$(jq --arg FIELD_NAME "$STATUS_FIELD_NAME" --arg STATUS_NAME "$STATUS_FIELD_VALUE_NAME" -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD_NAME) | .options[] | select(.name==$STATUS_NAME) | .id' project_data.json)"
94108
} >> "$GITHUB_ENV"
95109
@@ -107,7 +121,8 @@ jobs:
107121
}
108122
}' -f project="$PROJECT_ID" -f content="$CONTENT_ID" --jq '.data.addProjectV2ItemById.item.id' )"
109123
110-
# The ID of the project item (representing an issue or a PR with ID `inputs.content_id`), which was either added or already existed
124+
# The ID of the project item (representing an issue or a PR with ID
125+
# `inputs.content_id`), which was either added or already existed
111126
echo "ITEM_ID=$item_id" >> "$GITHUB_ENV"
112127
113128
- name: Get project item data
@@ -145,16 +160,19 @@ jobs:
145160
{
146161
# The value of the project item's date field (with ID `env.DATE_FIELD_ID`)
147162
echo "DATE_FIELD_VALUE=$(jq --arg FIELD_ID "$DATE_FIELD_ID" -r '.data.node.fieldValues.nodes[] | select(.field.id==$FIELD_ID) | .date' project_item_data.json)"
148-
# The value of the project item's status field (with ID `env.STATUS_FIELD_ID`)
163+
# The value of the project item's status field (with ID
164+
# `env.STATUS_FIELD_ID`)
149165
echo "STATUS_FIELD_VALUE=$(jq --arg FIELD_ID "$STATUS_FIELD_ID" -r '.data.node.fieldValues.nodes[] | select(.field.id==$FIELD_ID) | .name' project_item_data.json)"
150166
} >> "$GITHUB_ENV"
151167
152168
- name: Set status
153169
# Only set the status if it's not already set,
154-
# or if it's a reopened issue/PR (as they should be marked with the value of `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` when closed
155-
# - see https://github.com/orgs/MAKENTNU/projects/1/workflows/3569450)
170+
# or if it's a reopened issue/PR (as they should be marked with the value of
171+
# `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS` when closed - see
172+
# https://github.com/orgs/MAKENTNU/projects/1/workflows/3569450)
156173
if: ${{ !env.STATUS_FIELD_VALUE
157-
|| github.event.action == 'reopened' && env.STATUS_FIELD_VALUE == vars.ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS }}
174+
|| github.event.action == 'reopened'
175+
&& env.STATUS_FIELD_VALUE == vars.ORGANIZATION_PROJECT__STATUS_VALUE_FOR_CLOSED_ITEMS }}
158176
env:
159177
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
160178
run: |

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: CI
23

3-
on: [ push, pull_request ]
4+
on: [push, pull_request]
45

56
jobs:
67
lint:

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
---
12
name: "CodeQL"
23

34
on:
45
push:
5-
branches: [ 'main' ]
6+
branches: ['main']
67
pull_request:
78
# The branches below must be a subset of the branches above
8-
branches: [ 'main' ]
9+
branches: ['main']
910
schedule:
1011
# Runs at 06:45 UTC every Monday
1112
- cron: '45 6 * * 1'
@@ -26,7 +27,7 @@ jobs:
2627
strategy:
2728
fail-fast: false
2829
matrix:
29-
language: [ 'python', 'javascript' ]
30+
language: ['python', 'javascript']
3031
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3132
# Use only 'java' to analyze code written in Java, Kotlin or both
3233
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
@@ -37,7 +38,8 @@ jobs:
3738
uses: actions/checkout@v5
3839

3940
- name: Install System Dependencies
40-
# Retries installing files 3 times, as the GitHub Actions CI is occasionally unreliable
41+
# Retries installing files 3 times, as either the GitHub Actions runner or APT's
42+
# API can be unreliable
4143
run: |
4244
sudo apt update
4345
sudo apt install python3-dev libldap2-dev libsasl2-dev libssl-dev -o Acquire::Retries=3

.github/workflows/project-add-issue.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
---
12
# This workflow requires that the following repository variables have been created:
2-
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_ADDED_ISSUES` - The value of the 'Status' field to set for issues when added to the project.
3-
# in addition to the ones required by `_reusable_add-content-to-project.yml`.
3+
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_ADDED_ISSUES` - The value of the 'Status'
4+
# field to set for issues when added to the project.
5+
# ...in addition to the ones required by `_reusable_add-content-to-project.yml`.
46

57
name: Add issues to project
68

79
on:
810
issues:
9-
types: [ opened, reopened ]
11+
types: [opened, reopened]
1012

1113
jobs:
1214
add_to_project:

.github/workflows/project-add-pull-request.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
---
12
# This workflow requires that the following repository variables have been created:
2-
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_ADDED_PULL_REQUESTS` - The value of the 'Status' field to set for pull requests when added to the project.
3-
# in addition to the ones required by `_reusable_add-content-to-project.yml`.
3+
# - `ORGANIZATION_PROJECT__STATUS_VALUE_FOR_ADDED_PULL_REQUESTS` - The value of
4+
# the 'Status' field to set for pull requests when added to the project.
5+
# ...in addition to the ones required by `_reusable_add-content-to-project.yml`.
46

57
name: Add pull requests to project
68

79
on:
810
pull_request:
9-
types: [ opened, reopened, ready_for_review ]
11+
types: [opened, reopened, ready_for_review]
1012

1113
jobs:
1214
add_to_project:

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ repos:
1919
hooks:
2020
- id: validate-pyproject
2121

22+
- repo: https://github.com/adrienverge/yamllint
23+
rev: v1.37.1
24+
hooks:
25+
- id: yamllint
26+
args:
27+
- '--config-data={
28+
extends: default,
29+
rules: {
30+
line-length: {max: 88, level: warning},
31+
new-lines: {type: platform},
32+
truthy: disable,
33+
},
34+
}'
35+
2236
- repo: meta
2337
hooks:
2438
- id: check-hooks-apply

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Lastly, a new [release](https://github.com/MAKENTNU/web/releases) must be create
4545
- ...with the following hooks:
4646
- Several of the standard `pre-commit-hooks` and `meta` hooks
4747
- `validate-pyproject`
48+
- `yamllint`
4849

4950

5051
## 2025-05-03 (MAKENTNU/web#757)

0 commit comments

Comments
 (0)