Skip to content

Commit

Permalink
Merge #445
Browse files Browse the repository at this point in the history
445: 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 <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
  • Loading branch information
3 people authored Aug 3, 2023
2 parents 81d453b + 969dd71 commit 3dbbf29
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 72 deletions.
6 changes: 3 additions & 3 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
---
get_documents_post_1: |-
client.index('books').get_documents(
filter: '(rating > 3 AND (genres = Adventure OR genres = Fiction)) AND language = English',
limit: 3,
filter: '(rating > 3 AND (genres = Adventure OR genres = Fiction)) AND language = English',
limit: 3,
fields: ['title', 'genres', 'rating', 'language']
)
delete_documents_by_filter_1: |-
client.index('movies').get_documents(filter: 'genres = action OR genres adventure')
get_documents_1: |-
get_documents_1: |-
client.index('movies').get_documents(limit: 2, filter: 'genres = action')
getting_started_faceting: |-
client.index('movies').update_faceting(max_values_per_facet: 2)
Expand Down
36 changes: 18 additions & 18 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
labels:
- 'skip-changelog'
- 'dependencies'
rebase-strategy: disabled
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
labels:
- 'skip-changelog'
- 'dependencies'
rebase-strategy: disabled

- package-ecosystem: bundler
directory: "/"
schedule:
interval: "monthly"
time: "04:00"
open-pull-requests-limit: 10
labels:
- skip-changelog
- dependencies
rebase-strategy: disabled
- package-ecosystem: bundler
directory: "/"
schedule:
interval: "monthly"
time: "04:00"
open-pull-requests-limit: 10
labels:
- skip-changelog
- dependencies
rebase-strategy: disabled
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.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.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
26 changes: 13 additions & 13 deletions .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
name: integration-tests-against-rc (ruby ${{ matrix.ruby-version }})
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install ruby dependencies
run: bundle install --with test
- name: Get the latest Meilisearch RC
run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV
- name: Meilisearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
run: bundle exec rspec
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install ruby dependencies
run: bundle install --with test
- name: Get the latest Meilisearch RC
run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV
- name: Meilisearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
run: bundle exec rspec
50 changes: 30 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,38 @@ jobs:
name: integration-tests (ruby ${{ matrix.ruby-version }})
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install ruby dependencies
run: bundle install --with test
- name: Meilisearch (latest) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
run: bundle exec rspec
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install ruby dependencies
run: bundle install --with test
- name: Meilisearch (latest) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
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
with:
ruby-version: 3.0
- name: Install ruby dependencies
run: bundle install --with test
- name: Run linter
run: bundle exec rubocop lib/ spec/
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
- name: Install ruby dependencies
run: bundle install --with test
- 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
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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- bundle:/vendor/bundle

meilisearch:
image: getmeili/meilisearch:latest
image: getmeili/meilisearch:v1.3.0
ports:
- "7700"
environment:
Expand Down

0 comments on commit 3dbbf29

Please sign in to comment.