Skip to content

Commit

Permalink
Add GitHub workflows (#1147)
Browse files Browse the repository at this point in the history
* remove CI scripts
* add linkcheck workflow
* linter
* update config
* fix md
* fix lint issues
* nightly/weekly workflows
* remove DCO check as we already have the Github integrated one
* build job
* vale and updated styles
* move images and assets to assets/ to exclude easily
* fix vale errors
* add case check
* fix filename case

Signed-off-by: Alexandra Tran <[email protected]>
Signed-off-by: Nicolas MASSART <[email protected]>
Co-authored-by: Nicolas MASSART <[email protected]>
  • Loading branch information
alexandratran and NicolasMassart authored Sep 14, 2022
1 parent b9d08d2 commit b9e467f
Show file tree
Hide file tree
Showing 289 changed files with 8,084 additions and 30,342 deletions.
173 changes: 6 additions & 167 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,178 +1,17 @@
---
version: 2.1
executors:
python_executor:
docker:
- image: cimg/python:3.9
node_executor:
docker:
- image: cimg/node:lts
shell_executor:
docker:
- image: cimg/base:2022.06

commands:
install_node_dependencies:
description: "Install Node dependencies"
steps:
- restore_cache:
keys:
- deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "package-lock.json" }}
- run:
name: Install Node dependencies
command: |
npm ci
save_node_cache:
description: "Save Node dependencies"
steps:
- save_cache:
paths:
- ./node_modules
key: deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "package-lock.json" }}

jobs:
dco:
executor: shell_executor
steps:
- checkout
- run:
name: check
command: |
status=0
while IFS= read -r -a line; do
my_array+=( "$line" )
done < <( git branch -r | grep -v origin/HEAD )
for branch in "${my_array[@]}"
do
branch=$(echo "$branch" | xargs)
echo "Checking commits in branch $branch for commits missing DCO..."
while read -r results; do
status=1
commit_hash="$(echo "$results" | cut -d' ' -f1)"
>&2 echo "$commit_hash is missing Signed-off-by line."
done < <(git log "$branch" --no-merges --pretty="%H %ae" --grep 'Signed-off-by' --invert-grep -- )
done
exit $status
# test the build with regular non-insider MkDocs Material theme for compatibility
build:
executor: python_executor
steps:
- checkout
- restore_cache:
keys:
- deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "CI/requirements.txt" }}
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -q -r CI/requirements-mkdocs-material.txt -r CI/requirements.txt
- save_cache:
paths:
- ./venv
key: deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "CI/requirements.txt" }}
- run:
name: Run MkDocs
command: |
. venv/bin/activate
mkdocs build -s
vale:
executor: python_executor
steps:
- checkout
- run:
name: Install Vale
command: |
wget https://github.com/errata-ai/vale/releases/download/v2.6.0/vale_2.6.0_Linux_64-bit.tar.gz
mkdir bin && tar -xvzf vale_2.6.0_Linux_64-bit.tar.gz -C bin vale
- run:
name: Run Vale
command: |
./bin/vale --config ./CI/vale/.vale.ini --glob='*.{md}' . | tee ./vale.out
- store_artifacts:
path: ./vale.out
destination: ./vale.out

linkchecker:
executor: node_executor
steps:
- checkout
- install_node_dependencies
- run:
name: Run markdown link checker
command: |
npm run test:links
- save_node_cache
- store_artifacts:
path: ./linkchecker.out
destination: linkchecker.out

markdownlint:
executor: node_executor
steps:
- checkout
- install_node_dependencies
- run:
shell: /bin/bash #this is a non breaking command so it will always return success
name: Run Markdownlint info checks
command: |
npm run test:markdown:info
- run:
name: Run Markdownlint
command: |
npm run test:markdown
- save_node_cache
- store_artifacts:
path: ./markdownlint.out
destination: ./markdownlint.out
- store_artifacts:
path: ./markdownlint_info.out
destination: ./markdownlint_info.out

repolint:
executor: node_executor
dummy:
docker:
- image: cimg/base:2022.06
steps:
- checkout
- install_node_dependencies
- run:
shell: /bin/bash #this is a non breaking command so it will always return success
name: Run repolinter
command: |
npm run lint:repo
- save_node_cache
name: dummy
command: echo "dummy step to prevent Circle from failing"

workflows:
version: 2
default:
jobs:
- dco
- build
- vale
- markdownlint
- linkchecker
- repolint

nightly:
triggers:
- schedule: # GMT
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- linkchecker

weekly:
triggers:
- schedule:
cron: "0 0 * * 0"
filters:
branches:
only:
- main
jobs:
- repolint
- dummy
41 changes: 41 additions & 0 deletions .github/workflows/build-no-insider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-License-Identifier: Apache-2.0
---
name: Build without insider

on: [pull_request]

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: Run build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies

- name: Install dependencies
shell: sh
run: pip install -q -r CI/requirements-mkdocs-material.txt -r CI/requirements.txt

- name: MkDocs Material non insider build
shell: sh
run: mkdocs build -s

- name: Site artifacts
uses: actions/upload-artifact@v3
with:
name: site-no-insider
path: site
34 changes: 34 additions & 0 deletions .github/workflows/case.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Check file name case

on: [pull_request]

concurrency:
group: case-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Check file name case
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Check pages file name case
shell: sh
run: |
echo "Testing file case in docs."
passed=true
for filename in $(find docs -name "*.md" | ( ! grep -P -v "^[[:lower:][:digit:]\/\-_]+\.md$" ))
do
echo "$filename"
echo "::error file=$filename ::File path must be only lowercase letters, digits, - (dash) and _ (underscore)"
passed=false
done;
if [ "$passed" = false ] ; then
echo "::error ::Some files path are incorrect. Check error annotations in the pull request."
echo "Correct example: my-folder/my-file-name_new2.md"
echo "Wrong example: My-Folder/MyFile-NAME.old.md"
exit 1
fi
13 changes: 9 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
---
name: "CodeQL"

Expand All @@ -10,6 +11,10 @@ on:
schedule:
- cron: '19 15 * * 6'

concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand All @@ -22,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

Expand All @@ -38,11 +43,11 @@ jobs:
# 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.

# 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


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -51,7 +56,7 @@ jobs:
# ℹ️ 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.
# 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: |
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: Apache-2.0
---
name: Verify links

on: [pull_request]

concurrency:
group: links-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: Run check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout tools repo
uses: actions/checkout@v3

- name: Test changed files links
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: yes
use-verbose-mode: yes
check-modified-files-only: yes
base-branch: main
config-file: ./CI/linkchecker/link_check_conf.json
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: Apache-2.0
---
name: Lint Code Base

on: [pull_request]

concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: Run check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
# VALIDATE_ALL_CODEBASE: "false"
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: ./CI/lint
MARKDOWN_CONFIG_FILE: .markdown.yml
LOG_LEVEL: ERROR
CSS_FILE_NAME: .stylelintrc.yaml
FILTER_REGEX_EXCLUDE: (/CI/vale/vale_styles/*|LICENSE)
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_PYTHON: 'false'
IGNORE_GITIGNORED_FILES: 'true'
Loading

0 comments on commit b9e467f

Please sign in to comment.