Skip to content

Commit

Permalink
ci: Quality gates and release management (#4)
Browse files Browse the repository at this point in the history
* ci: Initialize CI pipelines

Add release-please

* Add Arduino, C++ and PR title linters

* Test c++ linter

* Remove matrix

* Fix cpp lint style

* Define .clang-format style

* Clang format

* Refactor: clang-tidy compliant

* ci: cpp-linter adaptations

* Provide action permissions

* Move permissions

* test permissions #2

* Test permissions #3

* Test permissions  #4

* Ignore extras from quality

Extras are written following external library conventions

* Update clang-tidy version

* Install Arduino CLI

* Switch to PIO checks for consistency

* Fix clang-tidy

* Add clang-format

* Add voluntary format error

* clang-format

* Fix release-please

* Fix release-please missing files

* Remove testing branch from release

* Fix duplicate launched action: Quality Gates

* Enhance PIO build process

* Fix cast issues

* Allow all architectures

* Update example section

* Add arduino-lint

* Add CONTRIBUTING.md

* Publish to PlatformIO Library manager

* Switch Arduino lint to submit

Switch back to "update" when approved by the Arduino Team

* Rename scripts folder to pio-tools

* Set lib_deps per example

* Add sponsorship program

* Shortened sentence in "using display" section
  • Loading branch information
XavierBrassoud committed May 2, 2024
1 parent f624ea9 commit bb6dc68
Show file tree
Hide file tree
Showing 23 changed files with 707 additions and 325 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: Microsoft
46 changes: 46 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
Checks: >
-*,
clang-diagnostic-*,
clang-analyzer-*,
bugprone-*,
google-*,
cert-*-c,
misc-*,
performance-*,
portability-*,
readability-*,
modernize-*,
-modernize-use-trailing-return-type
WarningsAsErrors: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
HeaderFilterRegex: ''
CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.TemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.PointerParameterCase
value: CamelCase
- key: readability-identifier-naming.PointerParameterPrefix
value: p
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: paypal.me/XavierBrassoud
20 changes: 20 additions & 0 deletions .github/workflows/lint_git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
lint-git:
name: Validate PR title
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: Quality Gates

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI

permissions:
contents: write
pull-requests: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: arduino-lint
uses: arduino/arduino-lint-action@v1
with:
library-manager: submit # TODO: swith to "update" when approved by the Arduino Team
compliance: strict

- name: Code format
uses: jidicula/[email protected]
with:
clang-format-version: '15' # equals to PIO clang version
check-path: 'src'

- name: Cache pio and pip
uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install PlatformIO Core
run: pip install --upgrade platformio

- name: Code lint
run: pio check --fail-on-defect=high --fail-on-defect=medium
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:

release-please:
runs-on: ubuntu-22.04
steps:
# Add packages to update into release-please-config.json
- name: Write new version to packages
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.MAINTAINER_PAT }}
target-branch: ${{ github.ref_name }}

# Steps bellow occurs only when a version is created
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}

- name: Cache pio and pip
if: ${{ steps.release.outputs.release_created }}
uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio

- uses: actions/setup-python@v4
if: ${{ steps.release.outputs.release_created }}
with:
python-version: '3.9'

- name: Install PlatformIO Core
if: ${{ steps.release.outputs.release_created }}
run: pip install --upgrade platformio

- name: PlatformIO publish
if: ${{ steps.release.outputs.release_created }}
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PIO_PAT }}
run: pio package publish --type library --no-interactive
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.0"
}
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contribution Guidlines

The best way to ask for help or propose a new idea is to [create a new issue](https://github.com/XavierBrassoud/Arduino_Epson_PNL_CE02/issues/new) while creating a Pull Request with your code changes allows you to share your own innovations with the rest of the community.

The following are some guidelines to observe when creating issues or PRs:

- Be friendly; it is important that we can all enjoy a safe space as we are all working on the same project and it is okay for people to have different ideas

- [Use code blocks](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code); it helps us help you when we can read your code! On that note also refrain from pasting more than 30 lines of code in a post, instead [create a gist](https://gist.github.com/) if you need to share large snippets

- Titles follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) (eg. *feat: My Awesome Feature*, *fix(topic): Something bad*)

- Be detailed; refrain from mentioning code problems without sharing your source code and always give information regarding your board and version of the library

- Ensure your code are properly formed with `clang-format` and passes quality gates with `pio checks`

- Using [Visual Studio Code](https://code.visualstudio.com/) with the [PlatformIO](https://platformio.org/) [extension](https://platformio.org/install/ide?install=vscode) is highly recommended
Loading

0 comments on commit bb6dc68

Please sign in to comment.