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 11, 2024
1 parent bbb9da2 commit d883f27
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 143 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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:
Expand Down
83 changes: 50 additions & 33 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,33 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
---

name: "CodeQL"

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ "main", "develop", "feature/*" ]
branches: ["main", "develop", "feature/*"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '22 11 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
runs-on:
${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
actions: read
contents: read
Expand All @@ -32,45 +44,50 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ['javascript']
# yamllint disable rule:line-length
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

# yamllint enable rule:line-length
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# yamllint disable rule:line-length

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# yamllint enable rule:line-length

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# yamllint disable rule:line-length
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# yamllint enable rule:line-length

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
59 changes: 34 additions & 25 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---

name: Docker Image CI

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

jobs:

Expand All @@ -14,28 +16,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Build the Docker image
run: make compose/rebuild
- name: Run test in Docker image
run: make compose/run
- name: Tag Docker image
run: docker tag algorithm-exercises-js:latest algorithm-exercises-js:${{ github.sha }}
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Build the Docker image
run: make compose/rebuild
- name: Run test in Docker image
run: make compose/run
- name: Tag Docker image
run: >
docker tag
algorithm-exercises-js:latest
algorithm-exercises-js:${{ 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:
# 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
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
- 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-js:latest
args: --file=Dockerfile
# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: snyk.sarif
# 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
25 changes: 20 additions & 5 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
# More details at https://github.com/eslint/eslint
# and https://eslint.org

---

name: ESLint

on:

on: # yamllint disable-line rule:truthy
push:
branches: [ "main", "develop" ]
branches: ["main", "develop", "feature/*"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '23 15 * * 2'

jobs:
Expand All @@ -25,7 +37,9 @@ jobs:
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
# only required for a private repository by
# github/codeql-action/upload-sarif to get the Action run status
actions: read
steps:
- name: Checkout code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
Expand All @@ -36,7 +50,8 @@ jobs:
npm install @microsoft/eslint-formatter-sarif@3.0.0
- name: Run ESLint
run: npx eslint .
run: >
npx eslint .
--config .eslintrc
--ext .js,.jsx,.ts,.tsx
--format @microsoft/eslint-formatter-sarif
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
---

name: gitleaks
on:

on: # yamllint disable-line rule:truthy
pull_request:
push:
workflow_dispatch:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: "0 4 * * *" # run once a day at 4 AM
jobs:
scan:
Expand All @@ -16,4 +28,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}}
40 changes: 21 additions & 19 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
---

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"]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
os: ["ubuntu-latest"]
node-version: [20.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@a5ac7e51b41094c92402da3b24376905380afc29 # v4
runs-on: ubuntu-latest

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 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.'
Loading

0 comments on commit d883f27

Please sign in to comment.