From a388af6155de6a42c1684de013727ae6d2f23dc7 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Fri, 5 Jan 2024 17:21:21 -0800 Subject: [PATCH] enforce scenario normalization (#1718) Closes #1713. --- .github/workflows/yaml-normalization.yml | 27 ++++++++++++++++++++++++ data/recipes.yaml | 1 - scripts/normalize-all-scenarios.sh | 6 ------ scripts/normalize-all-yaml.sh | 8 +++++++ 4 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/yaml-normalization.yml delete mode 100755 scripts/normalize-all-scenarios.sh create mode 100755 scripts/normalize-all-yaml.sh diff --git a/.github/workflows/yaml-normalization.yml b/.github/workflows/yaml-normalization.yml new file mode 100644 index 00000000..d9d42125 --- /dev/null +++ b/.github/workflows/yaml-normalization.yml @@ -0,0 +1,27 @@ +name: YAML normalization +on: + push: + paths: + - 'data/**.yaml' + branches: + - main + pull_request: + paths: + - 'data/**.yaml' + branches: + - main +jobs: + ensure-yaml-normalization: + name: Ensure YAML files are normalized + runs-on: ubuntu-latest + steps: + - name: 'Setup yq' + uses: dcarbone/install-yq-action@v1.1.1 + with: + version: "v4.35.1" + download-compressed: true + - uses: actions/checkout@v3 + - name: Normalize + run: | + scripts/normalize-all-yaml.sh + git diff --name-only --exit-code diff --git a/data/recipes.yaml b/data/recipes.yaml index bd1ef2f3..35a5d63c 100644 --- a/data/recipes.yaml +++ b/data/recipes.yaml @@ -205,7 +205,6 @@ ######################################### ## METAL ## ######################################### - ## VEINS - in: - [1, mountain] diff --git a/scripts/normalize-all-scenarios.sh b/scripts/normalize-all-scenarios.sh deleted file mode 100755 index 4db1b10a..00000000 --- a/scripts/normalize-all-scenarios.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -e - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -cd $SCRIPT_DIR/.. - -find data/scenarios -type f -name '*.yaml' -print0 | xargs -0 --max-args 1 yq --inplace diff --git a/scripts/normalize-all-yaml.sh b/scripts/normalize-all-yaml.sh new file mode 100755 index 00000000..265112ec --- /dev/null +++ b/scripts/normalize-all-yaml.sh @@ -0,0 +1,8 @@ +#!/bin/bash -e + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR/.. + +find data -type f -name '*.yaml' -print0 | xargs -0 --max-args 1 sed -i -e 's/[[:blank:]]\+$//' + +find data -type f -name '*.yaml' -print0 | xargs -0 --max-args 1 yq --inplace