Skip to content

Commit

Permalink
Merge #265
Browse files Browse the repository at this point in the history
265: Add yaml linting check in CI r=brunoocasali a=meili-bot

_This PR is auto-generated._

To avoid mistakes in the `yaml` files, for example, duplicated keys or wrong indentation, we decided to add a lint check on `yaml` files.

Additional to the `.yamllint` files added in this pr, the following must be added as well:
  - Linting check in CI:
    Example in `tests.yml create a new job:
    ```yaml
    yaml-lint:
      name: Yaml linting check
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v3
        - name: Yaml lint check
          uses: ibiqlik/action-yamllint@v3
          with:
            config_file: .yamllint.yml
    ```
  - Inside `.yamllint`, you might want to ignore some folders. For example `node_modules` in JS repos
    Example in `.yamllint`:
    ```yaml
    ignore: |
      node_modules
    ````

Since `yamllint` is a python package, we cannot add a local check unless you download [`.yamllint`](https://github.com/adrienverge/yamllint).
In which case, you can check if the yaml files are correctly linted by running the following command: `yamllint .`

Additionally, you can use the VSCode extension [`YAML` by redhat](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) which automatically highlights errors.

To help users be aware of this, we recommend adding this to your contributing guide:

```
To check if your `yaml` files are correctly formatted, you need to [install yamllint](https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint) and then run `yamllint .`
````

## TODO
- [ ] Add the directories or files to ignore in `.yamllint`
- [ ] Add information in the contributing guide on this new check.


Co-authored-by: meili-bot <[email protected]>
Co-authored-by: Bruno Casali <[email protected]>
  • Loading branch information
3 people committed Aug 3, 2023
2 parents cb3e7d1 + ae73bb2 commit 4b77938
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 37 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/gempush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Check release validity
run: sh .github/scripts/check-release.sh
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build meilisearch-rails.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Check release validity
run: sh .github/scripts/check-release.sh
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build meilisearch-rails.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
50 changes: 30 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,41 @@ jobs:
RAILS_VERSION: ${{ matrix.rails-version }}
name: integration-tests (Rails ${{ matrix.rails-version }} with Ruby ${{ matrix.ruby-version }})
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Meilisearch (latest) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run tests
run: bundle exec rspec
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Meilisearch (latest) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run tests
run: bundle exec rspec

linter_check:
name: linter-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
BUNDLE_WITH: test
with:
ruby-version: 2.6
bundler-cache: true
- name: Run linter
run: bundle exec rubocop lib/ spec/
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
BUNDLE_WITH: test
with:
ruby-version: 2.6
bundler-cache: true
- name: Run linter
run: bundle exec rubocop lib/ spec/

yaml-lint:
name: Yaml linting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Yaml lint check
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yml

smoke-test:
name: smoke-test
Expand Down
9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default
ignore: |
node_modules
rules:
comments-indentation: disable
line-length: disable
document-start: disable
brackets: disable
truthy: disable

0 comments on commit 4b77938

Please sign in to comment.