Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI/CD workflow to validate YAML files #457

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# For documentation on the format of this file, see
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2

Check warning on line 4 in .github/dependabot.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

4:1 [document-start] missing document start "---"
updates:

- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
80 changes: 40 additions & 40 deletions .github/workflows/generate-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#
# For documentation on the syntax of this file, see
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Build

Check warning on line 8 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

8:1 [document-start] missing document start "---"

Check warning on line 8 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

8:1 [document-start] missing document start "---"

on:

Check warning on line 10 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

10:1 [truthy] truthy value should be one of [false, true]

Check warning on line 10 in .github/workflows/generate-files.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

10:1 [truthy] truthy value should be one of [false, true]
push:
branches: [ main, v7.1 ]
branches: [main, v7.1]

permissions:
contents: read
Expand All @@ -25,48 +25,48 @@
EXTDIR: ../extracted-files/

steps:
- name: Check out GEDCOM
uses: actions/checkout@v4
- name: Check out GEDCOM
uses: actions/checkout@v4

- name: Get the branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Get the branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"

- name: Install mdformat-gfm
run: pip install mdformat-gfm
- name: Install mdformat-gfm
run: pip install mdformat-gfm

- name: Generate files
working-directory: ${{github.workspace}}/build
shell: sh
run: |
export MD_FILES=$(ls ${{ env.SPECDIR }}gedcom*.md | sort)
python3 extract-grammars.py ${MD_FILES} ${{ env.EXTDIR }}
python3 uri-def.py ${MD_FILES} ${{ env.EXTDIR }}tags
ls -l ${{env.EXTDIR}}
- name: Generate files
working-directory: ${{github.workspace}}/build
shell: sh
run: |
export MD_FILES=$(ls ${{ env.SPECDIR }}gedcom*.md | sort)
python3 extract-grammars.py ${MD_FILES} ${{ env.EXTDIR }}
python3 uri-def.py ${MD_FILES} ${{ env.EXTDIR }}tags
ls -l ${{env.EXTDIR}}

- 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: 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/${{steps.extract_branch.outputs.branch}} extracted-files || echo "::set-output name=status::changes"
shell: bash
- name: Check for diffs
id: diff
run: |
git diff --quiet origin/${{steps.extract_branch.outputs.branch}} extracted-files || echo "::set-output name=status::changes"
shell: bash

- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b ${{steps.extract_branch.outputs.branch}}-generate-files
git add extracted-files
git commit -m "Update extracted files"
git push -f origin ${{steps.extract_branch.outputs.branch}}-generate-files
if ! gh pr list | grep -q "${{steps.extract_branch.outputs.branch}}-generate-files"; then
gh pr create -B ${{steps.extract_branch.outputs.branch}} -H ${{steps.extract_branch.outputs.branch}}-generate-files --title 'Update extracted-files in ${{steps.extract_branch.outputs.branch}}' --body $'Update extracted files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr'
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b ${{steps.extract_branch.outputs.branch}}-generate-files
git add extracted-files
git commit -m "Update extracted files"
git push -f origin ${{steps.extract_branch.outputs.branch}}-generate-files
if ! gh pr list | grep -q "${{steps.extract_branch.outputs.branch}}-generate-files"; then
gh pr create -B ${{steps.extract_branch.outputs.branch}} -H ${{steps.extract_branch.outputs.branch}}-generate-files --title 'Update extracted-files in ${{steps.extract_branch.outputs.branch}}' --body $'Update extracted files\nThis PR is auto-generated by [gh pr create].' --label 'automated pr'
fi
env:
GH_TOKEN: ${{ github.token }}
50 changes: 25 additions & 25 deletions .github/workflows/propagate-main-to-v7.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#
# For documentation on the syntax of this file, see
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Build

Check warning on line 8 in .github/workflows/propagate-main-to-v7.1.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

8:1 [document-start] missing document start "---"

on:

Check warning on line 10 in .github/workflows/propagate-main-to-v7.1.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

10:1 [truthy] truthy value should be one of [false, true]
push:
branches: [ main ]
branches: [main]

permissions:
contents: read
Expand All @@ -22,30 +22,30 @@
runs-on: ubuntu-latest

steps:
- name: Check out GEDCOM
uses: actions/checkout@v4
- name: Check out GEDCOM
uses: actions/checkout@v4

- 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: 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 fetch origin
git diff --quiet origin/main..origin/v7.1 || echo "::set-output name=status::changes"
- name: Check for diffs
id: diff
run: |
git fetch origin
git diff --quiet origin/main..origin/v7.1 || echo "::set-output name=status::changes"

- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b merge-main-into-v7.1
git push -f --set-upstream origin merge-main-into-v7.1
if ! gh pr list | grep -q "merge-main-into-v7.1"; then
gh pr create -B v7.1 -H merge-main-into-v7.1 --title 'Merge main into v7.1' --body $'Copy changes from main to v7.1\nThis PR is auto-generated by [gh pr create].' --label 'automated pr' --repo ${{ github.repository }}
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create Pull Request
if: steps.diff.outputs.status == 'changes'
run: |
git checkout -b merge-main-into-v7.1
git push -f --set-upstream origin merge-main-into-v7.1
if ! gh pr list | grep -q "merge-main-into-v7.1"; then
gh pr create -B v7.1 -H merge-main-into-v7.1 --title 'Merge main into v7.1' --body $'Copy changes from main to v7.1\nThis PR is auto-generated by [gh pr create].' --label 'automated pr' --repo ${{ github.repository }}
fi
env:
GH_TOKEN: ${{ github.token }}
26 changes: 26 additions & 0 deletions .github/workflows/validate-yaml.yml
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 6 in .github/workflows/validate-yaml.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

6:1 [document-start] missing document start "---"

on:

Check warning on line 8 in .github/workflows/validate-yaml.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

8:1 [truthy] truthy value should be one of [false, true]
push:
branches: [main, v7.1, next-patch]
pull_request:
branches: [main, v7.1, next-patch]

permissions:
contents: read

jobs:
validate-yaml:
runs-on: ubuntu-latest

steps:
- name: Checkout GEDCOM
uses: actions/checkout@v4

- name: Validate YAML
run: yamllint .yamllint.yml .github .github/workflows
7 changes: 7 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Configuration file for yamllint. For documentation, see
# https://yamllint.readthedocs.io/en/stable/configuration.html

extends: default

Check warning on line 4 in .yamllint.yml

View workflow job for this annotation

GitHub Actions / validate-yaml

4:1 [document-start] missing document start "---"

rules:
line-length: disable