ci: Reformat yaml file
Includes a formatter script
This commit is contained in:
		@ -17,9 +17,9 @@ build_docs:
 | 
				
			|||||||
    paths:
 | 
					    paths:
 | 
				
			||||||
      - _build
 | 
					      - _build
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
      - apt-get -y install python3-pip python3-sphinx
 | 
					    - apt-get -y install python3-pip python3-sphinx
 | 
				
			||||||
      - pip3 install recommonmark
 | 
					    - pip3 install recommonmark
 | 
				
			||||||
      - ./doc/build.sh _build
 | 
					    - ./doc/build.sh _build
 | 
				
			||||||
  except:
 | 
					  except:
 | 
				
			||||||
    variables:
 | 
					    variables:
 | 
				
			||||||
      - $PKG_ONLY == "1"
 | 
					      - $PKG_ONLY == "1"
 | 
				
			||||||
@ -42,33 +42,37 @@ build_deb:
 | 
				
			|||||||
  stage: build
 | 
					  stage: build
 | 
				
			||||||
  artifacts:
 | 
					  artifacts:
 | 
				
			||||||
    paths:
 | 
					    paths:
 | 
				
			||||||
      - "*.deb"
 | 
					      - '*.deb'
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
      - rm -f ../*.deb
 | 
					    - rm -f ../*.deb
 | 
				
			||||||
      - apt-get -y build-dep .
 | 
					    - apt-get -y build-dep .
 | 
				
			||||||
      - apt-get -y install devscripts
 | 
					    - apt-get -y install devscripts
 | 
				
			||||||
      - REV=$(git log -1 --format=%h)
 | 
					    - REV=$(git log -1 --format=%h)
 | 
				
			||||||
      - VER=$(dpkg-parsechangelog -SVersion)
 | 
					    - VER=$(dpkg-parsechangelog -SVersion)
 | 
				
			||||||
      - 'DEBFULLNAME="Librem5 CI" EMAIL="librem5-builds@lists.community.puri.sm" dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"'
 | 
					    - DEBFULLNAME="Librem5 CI"
 | 
				
			||||||
      - debuild -i -us -uc -b
 | 
					    - EMAIL="librem5-builds@lists.community.puri.sm"
 | 
				
			||||||
      - cp ../*.deb .
 | 
					    - dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"
 | 
				
			||||||
 | 
					    - debuild -i -us -uc -b
 | 
				
			||||||
 | 
					    - cp ../*.deb .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
build_deb:arm64:
 | 
					build_deb:arm64:
 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
      - aarch64
 | 
					    - aarch64
 | 
				
			||||||
  stage: build
 | 
					  stage: build
 | 
				
			||||||
  artifacts:
 | 
					  artifacts:
 | 
				
			||||||
    paths:
 | 
					    paths:
 | 
				
			||||||
      - "*.deb"
 | 
					      - '*.deb'
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
      - rm -f ../*.deb
 | 
					    - rm -f ../*.deb
 | 
				
			||||||
      - apt-get -y build-dep .
 | 
					    - apt-get -y build-dep .
 | 
				
			||||||
      - apt-get -y install devscripts
 | 
					    - apt-get -y install devscripts
 | 
				
			||||||
      - REV=$(git log -1 --format=%h)
 | 
					    - REV=$(git log -1 --format=%h)
 | 
				
			||||||
      - VER=$(dpkg-parsechangelog -SVersion)
 | 
					    - VER=$(dpkg-parsechangelog -SVersion)
 | 
				
			||||||
      - 'DEBFULLNAME="Librem5 CI" EMAIL="librem5-builds@lists.community.puri.sm" dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"'
 | 
					    - DEBFULLNAME="Librem5 CI"
 | 
				
			||||||
      - debuild -i -us -uc -b
 | 
					    - EMAIL="librem5-builds@lists.community.puri.sm"
 | 
				
			||||||
      - cp ../*.deb .
 | 
					    - dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"
 | 
				
			||||||
 | 
					    - debuild -i -us -uc -b
 | 
				
			||||||
 | 
					    - cp ../*.deb .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_lintian:
 | 
					test_lintian:
 | 
				
			||||||
  stage: test
 | 
					  stage: test
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										36
									
								
								tools/yamlfmt
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								tools/yamlfmt
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""Checks YAML files for correct formatting.
 | 
				
			||||||
 | 
					Usage: yamlfmt.py [--apply] file.yaml
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import ruamel.yaml
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					args = sys.argv[:]
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    args.remove('--apply')
 | 
				
			||||||
 | 
					    want_apply = True
 | 
				
			||||||
 | 
					except ValueError:
 | 
				
			||||||
 | 
					    want_apply = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					path = args[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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)
 | 
				
			||||||
 | 
					    well_formatted = formatted == contents
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					if not well_formatted:
 | 
				
			||||||
 | 
					    print('The yaml file is not correctly formatted:', path)
 | 
				
			||||||
 | 
					    if want_apply:
 | 
				
			||||||
 | 
					        print('Correcting', path)
 | 
				
			||||||
 | 
					        with open(path, 'w') as f:
 | 
				
			||||||
 | 
					            f.write(formatted)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        print('Please use the following correction:')
 | 
				
			||||||
 | 
					        print('----------corrected', path)
 | 
				
			||||||
 | 
					        print(formatted)
 | 
				
			||||||
 | 
					        print('----------end corrected', path)
 | 
				
			||||||
 | 
					        sys.exit(1)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user