ci: Fix formatting

At the same time, reduce indentation level on lists because otherwise the formatter is broken.
This commit is contained in:
Dorota Czaplejewicz
2021-12-16 12:49:46 +00:00
parent b2485c343a
commit 4a7dc799be
2 changed files with 69 additions and 62 deletions

View File

@ -1,15 +1,15 @@
image: debian:bullseye
stages:
- build
- test
- build
- test
before_script:
- apt-get -y update
- apt-get -y install wget ca-certificates gnupg
- echo "deb [trusted=yes] http://ci.puri.sm/ bullseyeci main" > /etc/apt/sources.list.d/ci.list
- wget -O- https://ci.puri.sm/ci-repo.key | apt-key add -
- apt-get -y update
- apt-get -y update
- apt-get -y install wget ca-certificates gnupg
- echo "deb [trusted=yes] http://ci.puri.sm/ bullseyeci main" > /etc/apt/sources.list.d/ci.list
- wget -O- https://ci.puri.sm/ci-repo.key | apt-key add -
- apt-get -y update
build_docs:
stage: build

View File

@ -4,7 +4,8 @@
Usage: yamlfmt.py [--apply] file.yaml
"""
import ruamel.yaml
import io
from ruamel.yaml import YAML
import sys
args = sys.argv[:]
@ -16,10 +17,16 @@ except ValueError:
path = args[1]
def dump(yaml, yml):
buf = io.BytesIO()
yaml.dump(yml, buf)
return buf.getvalue().decode('utf-8')
with open(path) as f:
contents = f.read()
yml = ruamel.yaml.round_trip_load(contents)
formatted = ruamel.yaml.round_trip_dump(yml, block_seq_indent=2)
yaml = YAML()
yml = yaml.load(contents)
formatted = dump(yaml, yml)
well_formatted = formatted == contents
if not well_formatted: