From a3a3a4c4bf682049c6a9c5ba53ca90a1df7e33f4 Mon Sep 17 00:00:00 2001 From: Dave Thaler Date: Thu, 25 Apr 2024 12:21:50 -0700 Subject: [PATCH] Add CI/CD workflow to validate YAML files (#40) * Add CI/CD workflow to validate YAML files Signed-off-by: Dave Thaler * Update YAML files to resolve issues found by yamllint Signed-off-by: Dave Thaler * Use directories not files Signed-off-by: Dave Thaler --------- Signed-off-by: Dave Thaler Co-authored-by: Dave Thaler --- .github/workflows/generate-files.yml | 78 ++++++++++++++-------------- .github/workflows/validate-yaml.yml | 26 ++++++++++ .yamllint.yml | 8 +++ 3 files changed, 73 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/validate-yaml.yml create mode 100644 .yamllint.yml diff --git a/.github/workflows/generate-files.yml b/.github/workflows/generate-files.yml index 76df316..cd30d48 100644 --- a/.github/workflows/generate-files.yml +++ b/.github/workflows/generate-files.yml @@ -9,7 +9,7 @@ name: Build on: push: - branches: [ main ] + branches: [main] permissions: contents: read @@ -22,41 +22,41 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Generate files - working-directory: ${{github.workspace}} - run: | - python registry_tools/syncstandard.py - python registry_tools/makeTSV.py - python registry_tools/makeJSON.py - - - name: Set git config - env: - GH_TOKEN: ${{ github.token }} - run: | - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" - git config -l - - - name: Check for diffs - id: diff - run: | - git diff --quiet origin/main . || echo "::set-output name=status::changes" - shell: bash - - - name: Create Pull Request - if: steps.diff.outputs.status == 'changes' - run: | - git checkout -b generated-files - git add . - git commit -m "Update generated files" - git push -f origin generated-files - if ! gh pr list | grep -q "generated-files"; then - gh pr create -B main -H generated-files --title 'Update generated files' --body $'Update generated files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr' - fi - env: - GH_TOKEN: ${{ github.token }} + - name: Check out repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Generate files + working-directory: ${{github.workspace}} + run: | + python registry_tools/syncstandard.py + python registry_tools/makeTSV.py + python registry_tools/makeJSON.py + + - name: Set git config + env: + GH_TOKEN: ${{ github.token }} + run: | + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" + git config -l + + - name: Check for diffs + id: diff + run: | + git diff --quiet origin/main . || echo "::set-output name=status::changes" + shell: bash + + - name: Create Pull Request + if: steps.diff.outputs.status == 'changes' + run: | + git checkout -b generated-files + git add . + git commit -m "Update generated files" + git push -f origin generated-files + if ! gh pr list | grep -q "generated-files"; then + gh pr create -B main -H generated-files --title 'Update generated files' --body $'Update generated files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr' + fi + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/validate-yaml.yml b/.github/workflows/validate-yaml.yml new file mode 100644 index 0000000..d8bf418 --- /dev/null +++ b/.github/workflows/validate-yaml.yml @@ -0,0 +1,26 @@ +# For documentation on the github environment, see +# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners +# +# For documentation on the syntax of this file, see +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: Validate-YAML + +on: + push: + branches: [main, next-minor, next-patch] + pull_request: + branches: [main, next-minor, next-patch] + +permissions: + contents: read + +jobs: + validate-yaml: + runs-on: ubuntu-latest + + steps: + - name: Checkout GEDCOM.io + uses: actions/checkout@v4 + + - name: Validate YAML + run: yamllint . .github .github/workflows calendar/standard data-type/standard enumeration/standard enumeration-set/standard month/standard structure/extension structure/standard uri/exid-types diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..0824f77 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +# Configuration file for yamllint. For documentation, see +# https://yamllint.readthedocs.io/en/stable/configuration.html + +extends: default + +rules: + line-length: disable + trailing-spaces: disable