From 8a9ab11908b9878347e4c4e0582bc159fc80fc2b Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 23 Jun 2022 15:49:11 -0400 Subject: [PATCH] Add YAML Linter --- .github/workflows/changelog-enforcer.yml | 2 +- .github/workflows/validate_yaml_files.yml | 24 +++++++++++++++ .yamllint.yml | 29 +++++++++++++++++++ CHANGELOG.md | 2 ++ .../test_cases/case11/extdata.yaml | 2 +- .../test_cases/case23/extdata.yaml | 2 +- 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/validate_yaml_files.yml create mode 100644 .yamllint.yml diff --git a/.github/workflows/changelog-enforcer.yml b/.github/workflows/changelog-enforcer.yml index 1e9cb2979097..cd31258b2684 100644 --- a/.github/workflows/changelog-enforcer.yml +++ b/.github/workflows/changelog-enforcer.yml @@ -4,7 +4,7 @@ on: types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] jobs: - # Enforces the update of a changelog file on every pull request + # Enforces the update of a changelog file on every pull request changelog: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/validate_yaml_files.yml b/.github/workflows/validate_yaml_files.yml new file mode 100644 index 000000000000..b87f59d99d05 --- /dev/null +++ b/.github/workflows/validate_yaml_files.yml @@ -0,0 +1,24 @@ +--- +name: Yaml Lint + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] +jobs: + validate-YAML: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: yaml-lint + name: yaml-lint + uses: ibiqlik/action-yamllint@v3 + with: + no_warnings: true + format: colored + config_file: .yamllint.yml + + - uses: actions/upload-artifact@v2 + if: always() + with: + name: yamllint-logfile + path: ${{ steps.yaml-lint.outputs.logfile }} diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 000000000000..83f5340c7fdf --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,29 @@ +--- + +extends: default + +rules: + braces: + level: warning + max-spaces-inside: 1 + brackets: + level: warning + max-spaces-inside: 1 + colons: + level: warning + commas: + level: warning + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + level: warning + hyphens: + level: warning + indentation: + level: warning + indent-sequences: consistent + line-length: + level: warning + allow-non-breakable-inline-mappings: true + truthy: disable diff --git a/CHANGELOG.md b/CHANGELOG.md index f06bf2c7c10a..ebf770d624c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added monotonic regridding option - Make availalbe to History and ExtData2G all supported regridding methods - Add test cases for ExtData +- Add YAML validator GitHub Action + - This action makes sure all YAML files are valid (to a relaxed standard) ### Changed diff --git a/Tests/ExtData_Testing_Framework/test_cases/case11/extdata.yaml b/Tests/ExtData_Testing_Framework/test_cases/case11/extdata.yaml index f5641f693d84..6738280d70a4 100644 --- a/Tests/ExtData_Testing_Framework/test_cases/case11/extdata.yaml +++ b/Tests/ExtData_Testing_Framework/test_cases/case11/extdata.yaml @@ -1,4 +1,4 @@ Collections: fstream1: {template: "case1.%y4%m2.nc4", valid_range: "2006-01-01/2007-12-31" } Exports: - VAR2D: {variable: VAR2D, collection: fstream1, sample: {extrapolation: clim}} + VAR2D: {variable: VAR2D, collection: fstream1, sample: {extrapolation: clim}} diff --git a/Tests/ExtData_Testing_Framework/test_cases/case23/extdata.yaml b/Tests/ExtData_Testing_Framework/test_cases/case23/extdata.yaml index 62007858b755..49fa281346d1 100644 --- a/Tests/ExtData_Testing_Framework/test_cases/case23/extdata.yaml +++ b/Tests/ExtData_Testing_Framework/test_cases/case23/extdata.yaml @@ -6,6 +6,6 @@ Samplings: extrapolation: clim source_time: "2016-01-01/2016-12-31" Exports: - VAR2D: + VAR2D: - {starting: 1970-01-01, variable: VAR2D, collection: fstream1, sample: S1} - {starting: 2020-01-01, variable: VAR2D, collection: fstream2}