From 0bcb17270bee05286f1446b6d6cc24b28a2225bd Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Fri, 27 Sep 2024 23:19:35 +0300 Subject: [PATCH] Yaml Lint --- .github/CODEOWNERS | 1 + .github/workflows/build.yml | 32 +++---- .github/workflows/workflow_validate.yml | 117 ++++++++++++++++++++++++ .gitignore | 14 +++ .yamllint | 21 +++++ 5 files changed, 169 insertions(+), 16 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/workflow_validate.yml create mode 100644 .gitignore create mode 100644 .yamllint diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..1f9349e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @andrewjswan diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2c51e8..bd97007 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build / CEC Remote on: push: # On Push to Master branch - branches: + branches: - master # Ignore all Tags / Release tags-ignore: @@ -68,21 +68,21 @@ jobs: outputs: changes: ${{ steps.changes.outputs.xmp }} steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - xmp: - - '**.xmp2' + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + xmp: + - '**.xmp2' codeql: name: CodeQL if: ${{ needs.changes.outputs.changes == 'true' }} - uses: andrewjswan/MPE/.github/workflows/codeql.yml@master + uses: Mediaportal-Plugin-Team/Mediaportal-Tools/.github/workflows/codeql.yml@master with: build-path: CecRemote\Installer - needs: + needs: - build - changes permissions: @@ -108,7 +108,7 @@ jobs: - name: Git Checkout / MPE / XPath uses: actions/checkout@v4 with: - repository: andrewjswan/MPE + repository: Mediaportal-Plugin-Team/Mediaportal-Tools path: MPE - name: MP folder for MPEMaker @@ -230,8 +230,8 @@ jobs: - name: Delete XML Artifact uses: geekyeggo/delete-artifact@v5 with: - name: CECRemote XML - failOnError: false + name: CECRemote XML + failOnError: false release: name: CEC Remote / Release @@ -243,9 +243,9 @@ jobs: contents: write outputs: changes: ${{ needs.mpe.outputs.changes }} - + runs-on: ubuntu-latest - + steps: - name: Download Artifacts uses: actions/download-artifact@v4 @@ -314,7 +314,7 @@ jobs: - name: Failure if: ${{ contains(needs.*.result, 'failure') }} run: exit 1 - + cache-clear: name: Clear cache runs-on: ubuntu-latest diff --git a/.github/workflows/workflow_validate.yml b/.github/workflows/workflow_validate.yml new file mode 100644 index 0000000..0cdd92a --- /dev/null +++ b/.github/workflows/workflow_validate.yml @@ -0,0 +1,117 @@ +name: Workflow / Validate + +on: + push: + pull_request: + +jobs: + changes: + name: ๐Ÿ‘€ Source / Changed + runs-on: ubuntu-latest + outputs: + python: ${{ steps.changes.outputs.python }} + yaml: ${{ steps.changes.outputs.yaml }} + cpp: ${{ steps.changes.outputs.cpp }} + steps: + - name: โฌ‡๏ธ Check out Repo + uses: actions/checkout@v4 + + - name: โš™๏ธ Check for changes + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + python: + - '**.py' + - 'requirements.txt' + yaml: + - '**.yaml' + - '**.yml' + cpp: + - '**.cpp' + - '**.h' + + python: + name: ๐Ÿงน Python Ruff + if: ${{ needs.changes.outputs.python == 'true' }} + needs: + - changes + runs-on: ubuntu-latest + steps: + - name: โฌ‡๏ธ Check out Repo + uses: actions/checkout@v4 + + - name: ๐Ÿ Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: ๐Ÿ“ฆ Install requirements + run: python3 -m pip install -r .github/requirements.txt + + - name: โš™๏ธ Lint + run: python3 -m ruff check . + + - name: ๐Ÿ’… Format + run: python3 -m ruff format . --check + + - name: ๐Ÿ’… Format Diff + if: failure() + run: python3 -m ruff format . --check --diff + + yamllint: + name: ๐Ÿงน Yaml Lint + if: ${{ needs.changes.outputs.yaml == 'true' }} + needs: + - changes + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out Repo + uses: actions/checkout@v4 + + - name: ๐Ÿš€ Run yamllint + run: yamllint --strict . + + cpplinter: + name: ๐Ÿงน C++ Lint + if: ${{ needs.changes.outputs.cpp == 'true' }} + needs: + - changes + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out Repo + uses: actions/checkout@v4 + + - name: ๐Ÿš€ Run C++ linter + uses: cpp-linter/cpp-linter-action@v2 + id: linter + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: file + files-changed-only: false + thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} + + - name: Fail fast?! + if: steps.linter.outputs.checks-failed != 0 + run: | + echo "some linter checks failed. ${{ steps.linter.outputs.checks-failed }}" + # for actual deployment + # run: exit 1 + + ci-status: + name: ๐ŸŽญ Status + runs-on: ubuntu-latest + needs: + - python + - yamllint + - cpplinter + if: always() + steps: + - name: ๐ŸŽ‰ Success + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 + - name: โŒ Failure + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94d5881 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Build output +[Bb]in +[Oo]bj +[Dd]ebug +[Rr]elease + +# Visual Studio +.vs + +# User specific files +*.suo +*.user +*.log +*.bak \ No newline at end of file diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..8e4e353 --- /dev/null +++ b/.yamllint @@ -0,0 +1,21 @@ +--- +extends: default + +ignore-from-file: .gitignore + +rules: + document-start: disable + empty-lines: + level: error + max: 1 + max-start: 0 + max-end: 1 + indentation: + level: error + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + line-length: disable + truthy: disable + new-lines: disable + comments-indentation: disable