jupyter-xeus / cpp-terminal

C++ library for writing multiplatform terminal applications
https://jupyter-xeus.github.io/cpp-terminal/
Other
530 stars 55 forks source link

improve CI testing #182

Open MCWertGaming opened 2 years ago

MCWertGaming commented 2 years ago

We should improve the CI testing coverage by doing:

Other things

Analysis tools

Compilers

flagarde commented 2 years ago

Hi, This is the pre-commit I use for other project :

It deals with most the analysis tools you asked + some others

1) For the ones which need CI

---
name: pre-commit

on:
  pull_request:
  push:
    paths-ignore:
    - docs/**
    branches: [main]

jobs:
  pre-commit:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install packages
      run: sudo apt-get install clang-tidy cppcheck iwyu cmake

    - name: 🔧 Configure
      run: cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_NUMBER_JOBS=2 -DCMAKE_NUMBER_JOBS_TESTS=1

    - uses: pre-commit/action@v2.0.3

2) .pre-commit-config.yaml

---
ci:
  skip: [cppcheck, include-what-you-use, clang-tidy]

default_install_hook_types:
- pre-commit
- pre-merge-commit
- pre-push
- prepare-commit-msg
- commit-msg
- post-commit
- post-checkout
- post-merge
- post-rewrite

fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.3.0
  hooks:
  - id: check-added-large-files
    args: [--maxkb=200]
  - id: check-case-conflict
  - id: check-merge-conflict
  - id: check-symlinks
  - id: check-vcs-permalinks
  - id: destroyed-symlinks
  - id: detect-private-key
  - id: double-quote-string-fixer
  - id: end-of-file-fixer
  - id: fix-byte-order-marker
  - id: mixed-line-ending
    args: [--fix=lf]
  - id: trailing-whitespace
    args: [--markdown-linebreak-ext=md]
  - id: check-yaml
    args: [--allow-multiple-documents]

- repo: https://github.com/jumanjihouse/pre-commit-hooks
  rev: 3.0.0
  hooks:
  - id: check-mailmap
    name: detect if an email address needs to be added to mailmap
  - id: git-check
    name: check for conflict markers and core.whitespace errors

- repo: https://github.com/Lucas-C/pre-commit-hooks
  rev: v1.3.0
  hooks:
  - id: remove-crlf
  - id: remove-tabs
    name: tabs remover
    args: [--whitespaces-count, '2']

- repo: https://github.com/codespell-project/codespell
  rev: v2.1.0
  hooks:
  - id: codespell

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
  rev: 0.2.2
  hooks:
  - id: yamlfmt
    name: format YAML files
    args: [--mapping, '2', --sequence, '2', --offset, '0', --width, '250']

- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
  rev: 2.4.0
  hooks:
  - id: editorconfig-checker
    name: check .editorconfig rules

- repo: https://github.com/igorshubovych/markdownlint-cli
  rev: v0.32.1
  hooks:
  - id: markdownlint
    args: [--config=.markdownlint.yml, scan]

- repo: https://github.com/Kr4is/cmake-format-precommit
  rev: v0.6.14
  hooks:
  - id: cmake-format
    args: [--config=.cmake-format.yml]
  - id: cmake-lint
    args: [--config=.cmake-linter.yml]

- repo: https://github.com/Takishima/cmake-pre-commit-hooks
  rev: v1.5.3
  hooks:
  - id: clang-tidy
    args: [-Bbuild, --config=]
  - id: cppcheck
    args: [-Bbuild, --suppressions-list=.cppcheck]
  - id: include-what-you-use
    args: [-Bbuild, -p, build, --jobs, '10']
  - id: lizard
    args: [--CCN, '50', --length, '150', --arguments, '20', --warnings_only, -x, '*/*tests*/*', -x, '*/*build*/*', ./]

- repo: https://gitlab.com/daverona/pre-commit/cpp
  rev: 0.8.0
  hooks:
  - id: cpplint

- repo: https://github.com/pre-commit/mirrors-clang-format
  rev: v14.0.6
  hooks:
  - id: clang-format

Feel free to skip what is irrelevant, useless to you :)

For the config files you can adapt some from here : https://github.com/flagarde/Khaos and tune them for your needs

flagarde commented 2 years ago

For the tests with Ubuntu clang +gcc you can use https://github.com/flagarde/Khaos/blob/main/.github/workflows/Ubuntu.yml clang3.9 clang4 are buggy on ubuntu so you can skip them or comment them.

The docker containers are done by https://github.com/flagarde/ci . It still in very beta but you can have a try. the containers are by design very limited in software you need to install them on the CI

flagarde commented 2 years ago

MacOS clang: https://github.com/yaodaq/YAODAQ/blob/main/.github/workflows/MacOS-Clang.yml

MacOS GCC: https://github.com/yaodaq/YAODAQ/blob/main/.github/workflows/MacOS-GCC.yml

Windows: https://github.com/yaodaq/YAODAQ/blob/main/.github/workflows/Windows-MSVC.yml https://github.com/yaodaq/YAODAQ/blob/main/.github/workflows/Windows-MSYS2.yml

MinGW - GCC, clang, Cygwin - GCC, clang I tried and I gave up :(

Fell free to copy and adapt. I'm would be really happy if you fin some improvments too :)

MCWertGaming commented 2 years ago

Really nice! Thank you. I have looked briefly over them and they all look really great. We might want to stick with the official github template though, but I'll look into that when the window class stuff is done.