From a77328f1c75c92bf7799c8b1b2874517ec2129e4 Mon Sep 17 00:00:00 2001 From: Ashish Bhatia Date: Wed, 18 Sep 2024 00:12:40 -0700 Subject: [PATCH] ci: add YAML linter (#31) Also, fix YAML lint issues --- .github/workflows/lint-yaml.yaml | 53 ++++++++++++++++++++++++++++++++ .github/workflows/lint.xml | 38 +++++++++++------------ .github/workflows/test.yaml | 33 ++++++++++---------- 3 files changed, 89 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/lint-yaml.yaml diff --git a/.github/workflows/lint-yaml.yaml b/.github/workflows/lint-yaml.yaml new file mode 100644 index 0000000..c15ba83 --- /dev/null +++ b/.github/workflows/lint-yaml.yaml @@ -0,0 +1,53 @@ +# Generated by Gabo (https://github.com/ashishb/gabo) +--- +# Run this locally with act - https://github.com/nektos/act +# act -j lintYaml +name: Lint YAML + +on: # yamllint disable-line rule:truthy + push: + branches: [main, master] + paths: + - '**.yml' + - '**.yaml' + - '.github/workflows/**.yml' + - '.github/workflows/**.yaml' + pull_request: + branches: [main, master] + paths: + - '**.yml' + - '**.yaml' + - '.github/workflows/**.yml' + - '.github/workflows/**.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lintYaml: + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check YAML files with linter + uses: ibiqlik/action-yamllint@v3 + with: + # All files under base dir + file_or_dir: "." + config_data: | + extends: default + yaml-files: + - '*.yaml' + - '*.yml' + rules: + document-start: + level: warning + line-length: + level: warning + new-line-at-end-of-file: + level: warning + trailing-spaces: + level: warning diff --git a/.github/workflows/lint.xml b/.github/workflows/lint.xml index b0b370c..8ace3a4 100644 --- a/.github/workflows/lint.xml +++ b/.github/workflows/lint.xml @@ -1,35 +1,35 @@ -This workflow uses actions that are not certified by GitHub. +--- +# This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby - name: Lint on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: test: - runs-on: ubuntu-latest + timeout-minutes: 15 steps: - - uses: actions/checkout@v2 - - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - name: Install dependencies - run: gem install mdl - - name: Run tests - run: | - # Lint - disable some rules - https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md - mdl -r ~MD013,~MD029,~MD033 README.md + - uses: actions/checkout@v2 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + # uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Install dependencies + run: gem install mdl + - name: Run tests + run: | + # Lint - disable some rules - https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md + mdl -r ~MD013,~MD029,~MD033 README.md diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 64369e9..b9053f1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,3 +1,4 @@ +--- # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support @@ -9,9 +10,9 @@ name: Test on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: test: @@ -19,17 +20,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - name: Install dependencies - run: gem install awesome_bot - - name: Run tests - run: | - # Some URLs could be flaky, try twice in case the first execution fails. - bash run_awesome_bot.sh || bash run_awesome_bot.sh + - uses: actions/checkout@v2 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + # uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Install dependencies + run: gem install awesome_bot + - name: Run tests + run: | + # Some URLs could be flaky, try twice in case the first execution fails. + bash run_awesome_bot.sh || bash run_awesome_bot.sh