Skip to content

Commit 97f9e89

Browse files
authored
🔧 Added yamlfmt pre-commit (#1446)
1 parent 9ee2628 commit 97f9e89

File tree

8 files changed

+96
-91
lines changed

8 files changed

+96
-91
lines changed

.github/workflows/benchmark.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
path: ./cache
2828
key: ${{ runner.os }}-benchmark
2929
- name: Extract benchmark data
30-
run: python .github/scripts/extract_benchmark_data.py output.json output_action.json
30+
run: python .github/scripts/extract_benchmark_data.py output.json output_action.json
3131
- name: Store benchmark result
3232
uses: benchmark-action/github-action-benchmark@v1
3333
with:
@@ -58,5 +58,5 @@ jobs:
5858
cp mem_out.html docs/memory.html
5959
git add docs/memory.html
6060
git -c "user.name=Sphinx-Needs CI" -c "[email protected]" commit -m "memory.html update"
61-
- name: Push changes
61+
- name: Push changes
6262
run: git push origin benchmarks

.github/workflows/ci.yaml

+17-17
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
name: Lint
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
13-
- name: Set up Python
14-
uses: actions/setup-python@v5
15-
with:
16-
python-version: '3.9'
17-
- uses: pre-commit/[email protected]
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: '3.9'
17+
- uses: pre-commit/[email protected]
1818

1919
tests-core:
2020
name: "Core py${{ matrix.python-version }} sphinx~=${{ matrix.sphinx-version }} ${{ matrix.os }}"
2121
runs-on: ${{ matrix.os }}
2222
strategy:
23-
fail-fast: false # Set on "false" to get the results of ALL builds
23+
fail-fast: false # Set on "false" to get the results of ALL builds
2424
matrix:
2525
os: ["ubuntu-latest"]
2626
python-version: ["3.10", "3.12"]
@@ -122,26 +122,26 @@ jobs:
122122
python -m pytest -v tests/no_mpl_tests.py
123123
- name: Run HTML build
124124
# the docs should build without matplotlib (just issuing warnings)
125-
run: sphinx-build -b html . _build
125+
run: sphinx-build -b html . _build
126126
working-directory: docs
127127

128128
check:
129-
129+
130130
# This job does nothing and is only used for the branch protection
131131
# see https://github.com/marketplace/actions/alls-green#why
132132

133133
if: always()
134134

135135
needs:
136-
- lint
137-
- tests-core
138-
- tests-js
139-
- tests-no-mpl
136+
- lint
137+
- tests-core
138+
- tests-js
139+
- tests-no-mpl
140140

141141
runs-on: ubuntu-latest
142142

143143
steps:
144-
- name: Decide whether the needed jobs succeeded or failed
145-
uses: re-actors/alls-green@release/v1
146-
with:
147-
jobs: ${{ toJSON(needs) }}
144+
- name: Decide whether the needed jobs succeeded or failed
145+
uses: re-actors/alls-green@release/v1
146+
with:
147+
jobs: ${{ toJSON(needs) }}

.github/workflows/docker.yaml

+6-8
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,19 @@ jobs:
2727
base-image: ["sphinxdoc/sphinx:latest", "sphinxdoc/sphinx-latexpdf:latest"]
2828
image: ["sphinxneeds", "sphinxneeds-latexpdf"]
2929
exclude:
30-
- base-image: "sphinxdoc/sphinx:latest"
31-
image: "sphinxneeds-latexpdf"
32-
- base-image: "sphinxdoc/sphinx-latexpdf:latest"
33-
image: "sphinxneeds"
30+
- base-image: "sphinxdoc/sphinx:latest"
31+
image: "sphinxneeds-latexpdf"
32+
- base-image: "sphinxdoc/sphinx-latexpdf:latest"
33+
image: "sphinxneeds"
3434
name: "Image: ${{ matrix.image }} | Baseimage: ${{ matrix.base-image }}"
3535
runs-on: ubuntu-latest
3636
steps:
3737
# Checks-out your repository under $GITHUB_WORKSPACE
3838
- name: Checkout 🛎️
3939
uses: actions/checkout@v4
40-
-
41-
name: Set up Docker Build 🐋
40+
- name: Set up Docker Build 🐋
4241
uses: docker/setup-buildx-action@v3
43-
-
44-
name: Extract metadata (tags, labels) for Docker
42+
- name: Extract metadata (tags, labels) for Docker
4543
id: meta
4644
uses: docker/metadata-action@v5
4745
with:

.github/workflows/docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
run: |
1919
python -m pip install -e .[docs]
2020
- name: Run linkcheck
21-
run: sphinx-build -b linkcheck . _build
21+
run: sphinx-build -b linkcheck . _build
2222
working-directory: docs

.github/workflows/js_test.yml

+41-43
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,45 @@ jobs:
44
js_tests:
55
runs-on: ubuntu-latest
66
steps:
7-
- name: Set Up Python 3.10.8
8-
uses: actions/setup-python@v5
9-
with:
10-
python-version: 3.10.8
11-
- name: Use Node.js
12-
uses: actions/setup-node@v4
13-
with:
14-
node-version: 18
15-
- uses: actions/checkout@v4
16-
- name: Update pip
17-
run: |
18-
pip install -U wheel
19-
pip install -U setuptools
20-
python -m pip install -U pip
21-
- name: Get pip cache dir
22-
id: pip-cache
23-
run: |
24-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
25-
- name: Pip cache
26-
uses: actions/cache@v4
27-
with:
28-
path: ${{ steps.pip-cache.outputs.dir }}
29-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
30-
restore-keys: |
31-
${{ runner.os }}-pip-
32-
- name: Install package
33-
run: |
34-
pip install -e .[docs]
35-
- name: Install Node dependencies
36-
run: npm install cypress
37-
- name: Build Docs
38-
id: sphinx-build-docs
39-
run: sphinx-build -a -T -E -j 4 -b html -d /tmp/sphinx_build/doctrees ./docs /tmp/sphinx_build/html
40-
- name: E2E Cypress Test on Chrome
41-
uses: cypress-io/github-action@v6
42-
with:
43-
browser: chrome
44-
config-file: tests/js_test/cypress.config.js
45-
start: npm start
46-
# quote the url to be safe against YML parsing surprises
47-
wait-on: 'http://localhost:8080'
48-
49-
7+
- name: Set Up Python 3.10.8
8+
uses: actions/setup-python@v5
9+
with:
10+
python-version: 3.10.8
11+
- name: Use Node.js
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: 18
15+
- uses: actions/checkout@v4
16+
- name: Update pip
17+
run: |
18+
pip install -U wheel
19+
pip install -U setuptools
20+
python -m pip install -U pip
21+
- name: Get pip cache dir
22+
id: pip-cache
23+
run: |
24+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
25+
- name: Pip cache
26+
uses: actions/cache@v4
27+
with:
28+
path: ${{ steps.pip-cache.outputs.dir }}
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
- name: Install package
33+
run: |
34+
pip install -e .[docs]
35+
- name: Install Node dependencies
36+
run: npm install cypress
37+
- name: Build Docs
38+
id: sphinx-build-docs
39+
run: sphinx-build -a -T -E -j 4 -b html -d /tmp/sphinx_build/doctrees ./docs /tmp/sphinx_build/html
40+
- name: E2E Cypress Test on Chrome
41+
uses: cypress-io/github-action@v6
42+
with:
43+
browser: chrome
44+
config-file: tests/js_test/cypress.config.js
45+
start: npm start
46+
# quote the url to be safe against YML parsing surprises
47+
wait-on: 'http://localhost:8080'
5048

.github/workflows/release.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
- '[0-9].[0-9]+.[0-9]+'
66

77
jobs:
8-
publish:
8+
publish:
99

10-
name: Publish to PyPi
11-
# needs: check
12-
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
13-
runs-on: ubuntu-latest
14-
steps:
10+
name: Publish to PyPi
11+
# needs: check
12+
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
13+
runs-on: ubuntu-latest
14+
steps:
1515
- name: Checkout source
1616
uses: actions/checkout@v4
1717
- name: Set up Python 3.10

.pre-commit-config.yaml

+19-14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
99
rev: v0.9.9
1010
hooks:
11-
- id: ruff
12-
args: [--fix]
13-
- id: ruff-format
11+
- id: ruff
12+
args: [--fix]
13+
- id: ruff-format
14+
15+
- repo: https://github.com/google/yamlfmt
16+
rev: v0.16.0
17+
hooks:
18+
- id: yamlfmt
1419

1520
- repo: https://github.com/pre-commit/mirrors-mypy
1621
rev: v1.15.0
1722
hooks:
18-
- id: mypy
19-
files: sphinx_needs/.*
20-
args: []
21-
additional_dependencies:
22-
- sphinx==7.4.7
23-
- docutils==0.20
24-
- types-docutils==0.20.0.20240201
25-
- types-jsonschema
26-
- types-requests
23+
- id: mypy
24+
files: sphinx_needs/.*
25+
args: []
26+
additional_dependencies:
27+
- sphinx==7.4.7
28+
- docutils==0.20
29+
- types-docutils==0.20.0.20240201
30+
- types-jsonschema
31+
- types-requests
2732

2833
# TODO this does not work on pre-commit.ci
2934
# - repo: https://github.com/astral-sh/uv-pre-commit
@@ -40,5 +45,5 @@ repos:
4045
entry: rst2html.py README.rst --halt=warning
4146
pass_filenames: false
4247
additional_dependencies:
43-
- docutils==0.20.1
44-
- pygments
48+
- docutils==0.20.1
49+
- pygments

.yamlfmt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
formatter:
2+
type: basic
3+
retain_line_breaks_single: true
4+
disallow_anchors: true

0 commit comments

Comments
 (0)