Skip to content

Commit

Permalink
[CONFIG] [FIX] yamllint warnings and errors fixed.
Browse files Browse the repository at this point in the history
False positive in "on:" adrienverge/yamllint#430 (comment)
Can't use "%YAML 1.2" directive because brakes Github Actions

How to split long command as multiple lines (cross-SO way) https://stackoverflow.com/a/65808412/6366150
  • Loading branch information
Gonzalo Diaz committed Jun 10, 2024
1 parent 901dace commit 14f4eef
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 79 deletions.
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/codecov-action@v4.4.1
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/codecov-action@v4.4.1
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 }}"
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
5 changes: 3 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
services:
algorithm-exercises-csharp:
image: algorithm-exercises-csharp:latest
Expand All @@ -17,8 +18,8 @@ services:
context: .
target: mdlint
# environment:
# LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug
# BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
#  LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug
#  BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
volumes:
- ./:/app
profiles: ["lint"]
Expand Down

0 comments on commit 14f4eef

Please sign in to comment.