Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-188: YAML Linting #302

Merged
merged 64 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
93c976c
Set yaml-linting step as a reusable action
tteguayco Dec 11, 2023
ef69227
Add workflow extension
tteguayco Dec 11, 2023
cbfe603
Point to actions in feature branch
tteguayco Dec 11, 2023
23ddd43
Fix wrong workflow path
tteguayco Dec 11, 2023
5aa9ee3
Fix indentation
tteguayco Dec 11, 2023
eb66182
Add 'shell' missing param for GH action
tteguayco Dec 11, 2023
79c11ec
Add path to yamllint config file in trunk folder
tteguayco Dec 11, 2023
7726c35
Fix path to yamllint config file in trunk folder
tteguayco Dec 11, 2023
172d3a6
Comment out linting step for Linux
tteguayco Dec 11, 2023
4343038
Fix path for Windows step
tteguayco Dec 11, 2023
1ca5f97
Add parameters to linting action
tteguayco Dec 11, 2023
660e5fe
Fix typo
tteguayco Dec 11, 2023
5636c13
Add type property to action inputs
tteguayco Dec 11, 2023
8c79a09
Same step for both OS
tteguayco Dec 11, 2023
96f4085
Remove references to feature branch
tteguayco Dec 11, 2023
5a626e1
Fix trailing whitespaces in Lombiq.GitHub.Actions
tteguayco Dec 16, 2023
64422f7
Add YAML linting instructions
tteguayco Dec 16, 2023
d59d9d5
Remove unsed yamllint.yaml files
tteguayco Dec 16, 2023
4bcdde3
Merge branch 'dev' of https://github.com/Lombiq/GitHub-Actions into i…
tteguayco Dec 16, 2023
7d94d84
Add file-existance safe check to Get-GHA-Items-From-File-List.ps1 script
tteguayco Dec 18, 2023
1f1fea1
Update YAML Linting Job Name
tteguayco Dec 18, 2023
fc7c708
Change references to new feature branch in new yaml linting workflow
tteguayco Dec 18, 2023
602d694
Change references to new feature branch in new yaml linting workflow
tteguayco Dec 18, 2023
f631ab4
Remove extra whitespaces
tteguayco Dec 18, 2023
0e0fb42
Open brances in new line
tteguayco Dec 18, 2023
fd8dcee
Change reference to feature branch for get-changed-files-from-git-dif…
tteguayco Dec 18, 2023
3fbd2f7
Change reference to feature branch for get-changed-files-from-git-dif…
tteguayco Dec 18, 2023
b086325
Typo
tteguayco Dec 18, 2023
e3f78e6
Add runtimes as valid work for spell checker
tteguayco Dec 23, 2023
8ebff7e
Replace if-else with Test-Path by Try-Catch
tteguayco Dec 23, 2023
b7fabb9
Add previous if-else to workflow filtering logic
tteguayco Dec 23, 2023
e04870d
Update target branch in GHA workflow
tteguayco Dec 23, 2023
c3911c8
update target branch ref in failing workflows
tteguayco Dec 23, 2023
de782d4
update target branch ref in failing workflows
tteguayco Dec 23, 2023
cdcef75
Revert Get-GHA-Items-From-File.ps1 script changes
tteguayco Dec 23, 2023
d3c6304
Revert Get-GHA-Items-From-File.ps1 script changes
tteguayco Dec 23, 2023
ce87cac
Start brace in a new line
tteguayco Dec 23, 2023
483f193
Remove machine-type parameter from GHA workflow
tteguayco Dec 28, 2023
9fdd830
Set quotes style for YAML linting
tteguayco Dec 28, 2023
e1bb753
Improve documentation for YAML linting workflow
tteguayco Dec 28, 2023
21ad035
Fix markdown styles
tteguayco Dec 28, 2023
64a16c3
Update search-path for yaml linting
tteguayco Dec 28, 2023
df13251
Merge branch 'dev' of https://github.com/Lombiq/GitHub-Actions into i…
tteguayco Jan 8, 2024
dcb4a77
Update Docs/Workflows/Productivity/YamlLinting.md
tteguayco Jan 8, 2024
e9fcb59
Add required new line
tteguayco Jan 8, 2024
4fcbc3d
Update Docs/Workflows/Productivity/YamlLinting.md
tteguayco Jan 9, 2024
dcaed62
Update Docs/Workflows/Productivity/YamlLinting.md
tteguayco Jan 9, 2024
bbc455b
Merge branch 'dev' of https://github.com/Lombiq/GitHub-Actions into i…
tteguayco Jan 16, 2024
1dee81b
Update doc
tteguayco Jan 16, 2024
046f74f
Update doc
tteguayco Jan 16, 2024
319b9aa
Rename ps script file
tteguayco Jan 16, 2024
49b59f1
Replacing issue actions with dev
DemeSzabolcs Jan 17, 2024
b7ef6dc
Apply file lookup only on .github folder
tteguayco Jan 23, 2024
d11532b
Merge branch 'issue/OSOE-188' of https://github.com/Lombiq/GitHub-Act…
tteguayco Jan 23, 2024
18d44a4
Update branch ref
tteguayco Jan 23, 2024
9b2b004
Revert branch ref
tteguayco Jan 23, 2024
8a8896b
Changing actions/get-changed-gha-items to issue branch
DemeSzabolcs Jan 24, 2024
04fe7df
Revert "Changing actions/get-changed-gha-items to issue branch"
DemeSzabolcs Jan 24, 2024
c5ab129
Revert "Replacing issue actions with dev"
DemeSzabolcs Jan 24, 2024
f7b2809
Using issue branch
DemeSzabolcs Jan 24, 2024
f1624b9
Remove unnecessary try-catch block
tteguayco Jan 25, 2024
4625c0b
Merge branch 'issue/OSOE-188' of https://github.com/Lombiq/GitHub-Act…
tteguayco Jan 25, 2024
d69fcd5
Merge remote-tracking branch 'origin/dev' into issue/OSOE-188
DemeSzabolcs Jan 26, 2024
70e6288
Using dev branch in workflows
DemeSzabolcs Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
shell: pwsh
run: |
(Resolve-Path "${{ github.action_path }}/../../../Scripts").Path >> $Env:GITHUB_PATH

- name: Check Current Workflow Equals Latest
shell: pwsh
id: check-current-workflow-equals-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/check-merge-queue-adds/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check Merge Queue Adds
description: >
Checks current pull request timeline add events to determine if it was ever added to a
merge queue. Intentionally not documented in Actions.md since it's only meant for
Checks current pull request timeline add events to determine if it was ever added to a
merge queue. Intentionally not documented in Actions.md since it's only meant for
internal use.

outputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,38 @@ param(

# Filter actions based on files in action directory.
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
[array]$actionFiles = $FileIncludeList | Where-Object -FilterScript {
(Get-Item $PSitem).Directory.GetFiles('action.yml').Count -gt 0 -or
(Get-Item $PSitem).Directory.GetFiles('action.yaml').Count -gt 0
try
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
{
$itemDirectory = (Get-Item $PSItem).Directory.FullName
$isInGitHubDir = $itemDirectory -like '*/.github/*' -or $itemDirectory -eq '*/.github'
if (-not $isInGitHubDir) {
return $false
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
}

(Get-Item $PSitem).Directory.GetFiles('action.yml').Count -gt 0 -or
(Get-Item $PSitem).Directory.GetFiles('action.yaml').Count -gt 0
}
catch
{
return $false
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
}
}

# GitHub Actions are called by directory name. Get directory and de-duplicate list.
[array]$actions = $actionFiles.ForEach({ $PSItem.Replace('/' + $(Get-Item $PSItem).Name, '') }) | Select-Object -Unique

# Filter workflow files excluding action yaml file names.
[array]$workflows = $FileIncludeList | Where-Object -FilterScript {
(Get-Item $PSitem).BaseName -ne 'action' -and
((Get-Item $PSitem).Extension -eq '.yml' -or
(Get-Item $PSitem).Extension -eq '.yaml')
try
{
(Get-Item $PSitem).BaseName -ne 'action' -and
((Get-Item $PSitem).Extension -eq '.yml' -or
(Get-Item $PSitem).Extension -eq '.yaml')
}
catch
{
return $false
}
}

# Combine actions and workflows.
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/get-changed-gha-items/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: false
default: '@()'
description: >
PowerShell string array of file names to return corresponding GitHub Actions (GHA) items. The
PowerShell string array of file names to return corresponding GitHub Actions (GHA) items. The
parameter must be a PowerShell string array.
outputs:
changed-items:
Expand All @@ -20,12 +20,12 @@ runs:
shell: pwsh
run: |
"${{ github.action_path }}" >> $Env:GITHUB_PATH

- name: Get GHA Items
id: get-gha-items
shell: pwsh
run: |
$params = @{
FileIncludeList = ${{ inputs.file-include-list }}
}
Get-GHA-Items-From-File-List @params
Get-GhaItemsFromFileList @params
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
runtimes
21 changes: 21 additions & 0 deletions .github/actions/yaml-lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: YAML Linting
description: Runs a linter on YAML files.


inputs:
config-file-path:
description: 'Path to the yamllint configuration file'
required: true
default: '.yamllint.yaml'

search-path:
description: 'Path to search for YAML files'
required: true
default: '.'

runs:
using: "composite"
steps:
- name: Run yamllint
run: yamllint -c "${{ inputs.config-file-path }}" "${{ inputs.search-path }}"
shell: pwsh
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:

- name: Verify that .NET packages are consolidated
if: ${{ inputs.verify-dotnet-consolidation }}
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@issue/OSOE-188
with:
directory: ${{ inputs.build-directory }}
exclude-version-regex: ${{ inputs.dotnet-consolidation-exclude-version-regex }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:

- name: Verify that .NET packages are consolidated
if: ${{ inputs.verify-dotnet-consolidation }}
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@issue/OSOE-188
with:
directory: ${{ inputs.build-directory }}
exclude-version-regex: ${{ inputs.dotnet-consolidation-exclude-version-regex }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:

- name: Verify that .NET packages are consolidated
if: ${{ inputs.verify-dotnet-consolidation }}
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@issue/OSOE-188
with:
directory: ${{ inputs.build-directory }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/post-pull-request-checks-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
steps:
- name: Check Further Steps Should Run
if: inputs.run-only-latest-workflow == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/check-current-workflow-is-latest@dev
uses: Lombiq/GitHub-Actions/.github/actions/check-current-workflow-is-latest@issue/OSOE-188
id: check-steps-should-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -72,15 +72,15 @@ jobs:

- name: Automatically Merge Pull Request
if: steps.check-steps-should-run.outputs.is-latest != 'false'
uses: Lombiq/GitHub-Actions/.github/actions/auto-merge-pull-request@dev
uses: Lombiq/GitHub-Actions/.github/actions/auto-merge-pull-request@issue/OSOE-188
env:
GITHUB_TOKEN: ${{ env.MERGE_TOKEN }}
with:
merge-method: ${{ inputs.merge-method }}

- name: Automatically Resolve or Done Jira issue
if: steps.check-steps-should-run.outputs.is-latest != 'false'
uses: Lombiq/GitHub-Actions/.github/actions/auto-resolve-done-jira-issue@dev
uses: Lombiq/GitHub-Actions/.github/actions/auto-resolve-done-jira-issue@issue/OSOE-188
env:
GITHUB_TOKEN: ${{ env.MERGE_TOKEN }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling-this-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ on:
jobs:
spelling:
name: Spelling
uses: Lombiq/GitHub-Actions/.github/workflows/spelling.yml@dev
uses: Lombiq/GitHub-Actions/.github/workflows/spelling.yml@issue/OSOE-188
6 changes: 3 additions & 3 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:

- name: Check Spelling
id: check-spelling-action
uses: Lombiq/GitHub-Actions/.github/actions/spelling@dev
uses: Lombiq/GitHub-Actions/.github/actions/spelling@issue/OSOE-188
with:
merge-file-excludes: ${{ inputs.merge-file-excludes }}
merge-forbidden-patterns: ${{ inputs.merge-forbidden-patterns }}
Expand All @@ -125,7 +125,7 @@ jobs:

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/cancel-workflow@dev
uses: Lombiq/GitHub-Actions/.github/actions/cancel-workflow@issue/OSOE-188
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -138,7 +138,7 @@ jobs:
if: always() && needs.check-spelling.outputs.followup && github.event_name == 'pull_request'
steps:
- name: Comment (PR)
uses: Lombiq/GitHub-Actions/.github/actions/spelling@dev
uses: Lombiq/GitHub-Actions/.github/actions/spelling@issue/OSOE-188
with:
post-comment: 1
task: ${{ needs.check-spelling.outputs.followup }}
14 changes: 7 additions & 7 deletions .github/workflows/validate-this-gha-refs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:

- name: Checkout Repository (Push)
if: github.event_name == 'push'
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-188

- name: Check Merge Queue Adds
id: check-merge-queue-adds
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
uses: Lombiq/GitHub-Actions/.github/actions/check-merge-queue-adds@dev
uses: Lombiq/GitHub-Actions/.github/actions/check-merge-queue-adds@issue/OSOE-188
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -44,7 +44,7 @@ jobs:
- name: Get Applicable Git File Changes
id: git-diff
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || github.event_name == 'merge_group'
uses: Lombiq/GitHub-Actions/.github/actions/get-changed-files-from-git-diff@dev
uses: Lombiq/GitHub-Actions/.github/actions/get-changed-files-from-git-diff@issue/OSOE-188
with:
left-commit: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || github.event.pull_request.base.sha }}
right-commit: ${{ github.sha }}
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Get GitHub Actions Item Changes from File Changes
id: changed-items
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || github.event_name == 'merge_group'
uses: Lombiq/GitHub-Actions/.github/actions/get-changed-gha-items@dev
uses: Lombiq/GitHub-Actions/.github/actions/get-changed-gha-items@issue/OSOE-188
DemeSzabolcs marked this conversation as resolved.
Show resolved Hide resolved
with:
file-include-list: '${{ steps.git-diff.outputs.changed-files }}'

Expand All @@ -72,7 +72,7 @@ jobs:
- name: Check PR Reviews
id: check-pr-reviews
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
uses: Lombiq/GitHub-Actions/.github/actions/check-pull-request-reviews@dev
uses: Lombiq/GitHub-Actions/.github/actions/check-pull-request-reviews@issue/OSOE-188
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -112,11 +112,11 @@ jobs:

- name: Verify GitHub Actions Items Match Expected Ref (Pull & Approve/Merge PR)
if: (github.event_name == 'pull_request' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || github.event_name == 'merge_group') && steps.add-prefix.outputs.prefixed-files != '@()'
uses: Lombiq/GitHub-Actions/.github/actions/verify-gha-refs@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-gha-refs@issue/OSOE-188
with:
called-repo-base-include-list: '${{ steps.add-prefix.outputs.prefixed-files }}'
expected-ref: ${{ steps.determine-ref.outputs.expected-ref }}

- name: Verify GitHub Actions Items Match Expected Ref (Push)
if: github.event_name == 'push'
uses: Lombiq/GitHub-Actions/.github/actions/verify-gha-refs@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-gha-refs@issue/OSOE-188
16 changes: 16 additions & 0 deletions .github/workflows/yaml-lint-this-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: YAML Linting

# Runs for PRs opened for any branch, and pushes to the dev branch.
on:
pull_request:
push:
branches:
- dev

jobs:
yaml-linting:
name: YAML Linting
uses: Lombiq/GitHub-Actions/.github/workflows/yaml-lint.yml@issue/OSOE-188
with:
config-file-path: '.trunk/configs/.yamllint.yaml'
search-path: '.'
55 changes: 55 additions & 0 deletions .github/workflows/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: YAML Linting

on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.

inputs:
timeout-minutes:
required: false
type: number
default: 10
description: Configuration for the timeout-minutes parameter of the workflow. GitHub's default is 360.
cancel-workflow-on-failure:
description: If set to "true", this will cancel the current workflow run with all jobs if this workflow fails.
required: false
type: string
default: "true"
config-file-path:
description: 'Path to the yamllint configuration file'
required: true
type: string
default: '.yamllint.yaml'
search-path:
description: 'Path to search for YAML files'
required: true
type: string
default: '.'

jobs:
yaml-linting:
runs-on: ubuntu-22.04
name: YAML Linting Job
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

- name: YAML Linting
uses: Lombiq/GitHub-Actions/.github/actions/yaml-lint@issue/OSOE-188
with:
config-file-path: ${{ inputs.config-file-path }}
search-path: ${{ inputs.search-path }}

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/cancel-workflow@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
16 changes: 16 additions & 0 deletions .trunk/configs/.yamllint.yaml
tteguayco marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

ignore: |
**/node_modules/**
**/.trunk/**

rules:
trailing-spaces: {}
key-duplicates: {}
quoted-strings: {
quote-type: any,
required: false
tteguayco marked this conversation as resolved.
Show resolved Hide resolved
}
20 changes: 20 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.17.2
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.3.0
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
1 change: 1 addition & 0 deletions Docs/Workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ These features are designed to reduce resource usage (like paid GitHub Actions m
- [Spell-checking](Workflows/Productivity/SpellChecking.md)
- [Validate pull request](Workflows/Productivity/ValidatePullRequest.md)
- [Validate submodule](Workflows/Productivity/ValidateSubmodule.md)
- [Lint YAML files](Workflows/Productivity/YamlLinting.md)

## Azure hosting

Expand Down
Loading
Loading