Skip to content

Commit

Permalink
Issue #101: Adding unified yaml linting rule to the yaml lint reusabl…
Browse files Browse the repository at this point in the history
…e workflow
  • Loading branch information
SonOfLope committed Mar 1, 2024
1 parent d8cdf97 commit cf8d999
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/workflow-yaml-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,30 @@

## Overview

This workflow is designed to maintain and enforce coding standards within YAML files across multiple projects within the organization. It ensures that any changes made to YAML files are consistent with the predefined standards set by the organization.
This workflow is designed to maintain and enforce coding standards within YAML
files across multiple projects within the organization. It ensures that any
changes made to YAML files are consistent with the predefined standards set by
the organization.

## Usage

- **Purpose:** Validate the organization's yaml standards across projects. It is triggered by **pull requests** to ensure that any new or altered YAML files comply with these standards.
- **Purpose:** Validate the organization's yaml standards across projects. It is
triggered by **pull requests** to ensure that any new or altered YAML files
comply with these standards.
- **Steps**
- YAML Lint Test: The workflow runs a linting test on the changed YAML files using the given configuration if specified.
- YAML Lint Test: The workflow runs a linting test on the changed YAML files
using the given configuration if specified.
- **Input:** You can specify specify a custom configuration file path for the
yaml link check. If you have specific rules or configurations for link
validation, you can create a configuration file in the project you are
calling this workflow from and input the path to this workflow. You can
find the documentation for this file
validation, you can create a configuration file in the project you are calling
this workflow from and input the path to this workflow. If you omit to specify
a file path, the default config file from current repository will be used. You
can find the documentation for this file
[here](https://yamllint.readthedocs.io/en/stable/configuration.html)

## YAML Linting Guidelines for Developers

- The [fnando.linter](https://marketplace.visualstudio.com/items?itemName=fnando.linter) extension for Visual Studio Code provides a flexible linter framework, which can be used for linting YAML files.
- The
[fnando.linter](https://marketplace.visualstudio.com/items?itemName=fnando.linter)
extension for Visual Studio Code provides a flexible linter framework, which
can be used for linting YAML files.
4 changes: 3 additions & 1 deletion .github/workflows/workflow-yaml-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
if [ -n "${{ github.event.inputs.config-file-path }}" ]; then
yamllint -c "${{ github.workspace }}/${{ github.event.inputs.config-file-path }}" "$file"
else
yamllint "$file"
default_config_url="https://raw.githubusercontent.com/ai-cfia/github-workflows/main/.yamllint.yml"
curl -s -O $default_config_url
yamllint -c "./$(basename $default_config_url)" "$file"
fi
fi
done
Expand Down
8 changes: 5 additions & 3 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
extends: default

ignore: |
.git/
rules:
line-length:
max: 120
allow-non-breakable-inline-mappings: true
line-length: disable
truthy: disable

0 comments on commit cf8d999

Please sign in to comment.