Skip to content

Feature/yamllint #65

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

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

---
version: 2
updates:
# Maintain dependencies for GitHub Actions
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Docker Image CI

on:
on: # yamllint disable-line rule:truthy
push:
branches: [main, develop, feature/*]
pull_request:
Expand All @@ -23,22 +24,29 @@ jobs:
- name: Run test in Docker image
run: make compose/run
- name: Tag Docker image
run: docker tag algorithm-exercises-csharp:latest algorithm-exercises-csharp:${{ github.sha }}
run: >
docker tag
algorithm-exercises-csharp:latest
algorithm-exercises-csharp:${{ github.sha }}

- name: Run Snyk to check Docker image for vulnerabilities
# Snyk can be used to break the build when it detects vulnerabilities.
# In this case we want to upload the issues to GitHub Code Scanning
continue-on-error: true
uses: snyk/actions/docker@master
env:
# yamllint disable rule:line-length
# In order to use the Snyk Action you will need to have a Snyk API token.
# See https://docs.snyk.io/integrations/ci-cd-integrations/github-actions-integration#getting-your-snyk-token
# or you can sign up for free at https://snyk.io/login
# yamllint enable rule:line-length
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: algorithm-exercises-csharp:latest
args: --file=Dockerfile
# yamllint disable rule:comments-indentation
# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: snyk.sarif
# yamllint enable rule:comments-indentation
46 changes: 25 additions & 21 deletions .github/workflows/dotnet-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
# yamllint disable rule:line-length
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
# yamllint enable rule:line-length

---

name: .NET Coverage

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ main, develop, feature/* ]
branches: ["main", "develop", "feature/*"]
pull_request:
branches: [ main ]
branches: ["main"]

jobs:
build:
name: "Run CI"
strategy:
fail-fast: false
matrix:
os: ["windows-latest"]
fail-fast: false
matrix:
os: ["windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore --verbosity normal
- name: Build
run: dotnet build --no-restore --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore --verbosity normal
- name: Build
run: dotnet build --no-restore --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 11 additions & 4 deletions .github/workflows/dotnet-snyk.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# yamllint disable rule:line-length
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
# yamllint enable rule:line-length

---

name: .NET Snyk Code analysis

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ main, develop, feature/* ]
branches: ["main", "develop", "feature/*"]
pull_request:
branches: [ main ]
branches: ["main"]

jobs:
security:
Expand All @@ -22,6 +26,9 @@ jobs:
- name: Restore dependencies
run: dotnet restore algorithm-exercises-csharp.sln
- name: Run Snyk to check for vulnerabilities
run: snyk test algorithm-exercises-csharp/ algorithm-exercises-csharp-test/
run: >
snyk test
algorithm-exercises-csharp/
algorithm-exercises-csharp-test/
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
50 changes: 27 additions & 23 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# yamllint disable rule:line-length
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
# yamllint enable rule:line-length

---

name: .NET Tests

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ main, develop, feature/* ]
branches: ["main", "develop", "feature/*"]
pull_request:
branches: [ main ]
branches: ["main"]

jobs:
build:
name: "Run CI"
strategy:
fail-fast: false
matrix:
os: [
"windows-latest",
"ubuntu-latest",
"macOS-latest"
]
fail-fast: false
matrix:
os: [
"windows-latest",
"ubuntu-latest",
"macOS-latest"
]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Lint (codestyle)
run: dotnet format --verify-no-changes --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Lint (codestyle)
run: dotnet format --verify-no-changes --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
8 changes: 6 additions & 2 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---

name: gitleaks
on:

on: # yamllint disable-line rule:truthy
pull_request:
push:
workflow_dispatch:
Expand All @@ -16,4 +19,5 @@ jobs:
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.
# Only required for Organizations, not personal accounts.
# GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
34 changes: 19 additions & 15 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---

name: Markdown Lint

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ main, develop, feature/* ]
branches: ["main", "develop", "feature/*"]
pull_request:
branches: [ main ]
branches: ["main"]

permissions: read-all

Expand All @@ -17,20 +19,22 @@ jobs:
matrix:
os: [ubuntu-latest]
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# See supported Node.js release schedule
# at https://nodejs.org/en/about/releases/

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: npm install -g markdownlint-cli
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Lint
run: markdownlint '**/*.md' --ignore node_modules && echo '✔ Your code looks good.'
- name: Install dependencies
run: npm install -g markdownlint-cli

- name: Lint
run: >
markdownlint '**/*.md' --ignore node_modules
&& echo '✔ Your code looks good.'
22 changes: 16 additions & 6 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---

name: SonarCloud

on:
on: # yamllint disable-line rule:truthy
push:
branches:
- main
Expand All @@ -16,10 +18,12 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin' # Alternative distribution options are available.
# Alternative distribution options are available.
distribution: 'temurin'
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
Expand All @@ -41,13 +45,19 @@ jobs:
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Needed to get PR information, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"sir-gon_algorithm-exercises-csharp" /o:"sir-gon" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
.\.sonar\scanner\dotnet-sonarscanner begin `
/k:"sir-gon_algorithm-exercises-csharp" `
/o:"sir-gon" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
/d:sonar.host.url="https://sonarcloud.io" `
/d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml

dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
.\.sonar\scanner\dotnet-sonarscanner end `
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
23 changes: 23 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: YAML lint

on: # yamllint disable-line rule:truthy
push:
branches: ["main", "develop", "feature/*"]
pull_request:
branches: ["main"]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML files
run: >
yamllint --strict .
&& echo '✔ Your code looks good.'
8 changes: 5 additions & 3 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
# yamllint disable rule:line-length

# Example markdownlint configuration with all properties set to their default value

# Default state for all rules
Expand Down Expand Up @@ -203,9 +206,7 @@ MD042: true
# MD043/required-headings/required-headers - Required heading structure
MD043:
# List of headings
headings: [
"*"
]
headings: ["*"]
# Match case of headings
match_case: false

Expand Down Expand Up @@ -255,3 +256,4 @@ MD053:
# Ignored definitions
ignored_definitions:
- "//"
# yamllint enable rule:line-length
1 change: 1 addition & 0 deletions .yamlignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.trunk/*
19 changes: 19 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
extends: default

ignore-from-file: .yamlignore

rules:
comments:
min-spaces-from-content: 1

# yamllint disable rule:line-length
#
# References:
# False positive: interpreting GitHub actions "on:" as a truthy value #430
# https://github.com/adrienverge/yamllint/issues/430
#
# YAML formatting not compliant with yamllint "spaces before comments" requirement #433
# https://github.com/redhat-developer/vscode-yaml/issues/433#issuecomment-1235681987
#
# yamllint enable rule:line-length
Loading