Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MegaLinter GitHub Actions workflow #1203

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,36 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md, *.yml]
[*.{md,yml}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false

[configs/**CMakeLists.txt]
insert_final_newline = false

[*.scss]
end_of_line = lf

[*.{js,jsx,ts,tsx}]
quote_type = single

[{package-lock.json,CMakeLists.txt,www/public/manifest.json}]
indent_style = space
indent_size = 2

[src/**.c]
indent_style = space
indent_size = 4

[pico_sdk_import.cmake]
indent_style = space
indent_size = 4

[modules/**.cmake]
indent_style = space
insert_final_newline = false

[proto/**.proto]
indent_style = space
indent_size = 4
61 changes: 53 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
name: CMake

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
# pull_request_target:
# branches: [ "main" ]
branches: ["main"]
workflow_dispatch:

env:
Expand All @@ -23,10 +22,56 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
GP2040_BOARDCONFIG: [ARCController, Blank, Pico, PicoW, BentoBox, ergoSHIFTRev2, FightboardV3, FightboardV3Mirrored, FlatboxRev4, FlatboxRev5, FlatboxRev5RGB, FlatboxRev5USBPassthrough, FlatboxRev5Southpaw, Granola, KB2040, KeyboardConverter, Haute42COSMOX, Liatris, MavercadeRev1, MavercadeRev2, MiSTercadeV2, OpenCore0, OpenCore0WASD, OSUMGP-RP2040, PicoAnn, PicoFightingBoard, PXPGamepad, RanaTadpole, ReflexCtrlGenesis6, ReflexCtrlNES, ReflexCtrlSaturn, ReflexCtrlSNES, ReflexCtrlVB, ReflexEncodeV1.2, ReflexEncodeV2.0, RP2040AdvancedBreakoutBoard, RP2040AdvancedBreakoutBoardUSBPassthrough, RP2040MiniBreakoutBoard, SparkFunProMicro, WaveshareZero, Stress, SGFDevices, ZeroRhythm]
GP2040_BOARDCONFIG:
[
ARCController,
Blank,
Pico,
PicoW,
BentoBox,
ergoSHIFTRev2,
FightboardV3,
FightboardV3Mirrored,
FlatboxRev4,
FlatboxRev5,
FlatboxRev5RGB,
FlatboxRev5USBPassthrough,
FlatboxRev5Southpaw,
Granola,
KB2040,
KeyboardConverter,
Haute42COSMOX,
Liatris,
MavercadeRev1,
MavercadeRev2,
MiSTercadeV2,
OpenCore0,
OpenCore0WASD,
OSUMGP-RP2040,
PicoAnn,
PicoFightingBoard,
PXPGamepad,
RanaTadpole,
ReflexCtrlGenesis6,
ReflexCtrlNES,
ReflexCtrlSaturn,
ReflexCtrlSNES,
ReflexCtrlVB,
ReflexEncodeV1.2,
ReflexEncodeV2.0,
RP2040AdvancedBreakoutBoard,
RP2040AdvancedBreakoutBoardUSBPassthrough,
RP2040MiniBreakoutBoard,
SparkFunProMicro,
WaveshareZero,
Stress,
SGFDevices,
ZeroRhythm,
]

steps:
#Global Setup
# Global Setup
# yamllint disable-line rule:indentation
- name: Checkout GP2040-CE
uses: actions/checkout@v4.1.1
with:
Expand All @@ -44,8 +89,8 @@ jobs:

- name: Get core count
id: core_count
run : cat /proc/cpuinfo | grep processor | wc -l
#End Global Setup
run: cat /proc/cpuinfo | grep processor | wc -l
# End Global Setup

- name: Pico Build Configure CMake
shell: bash
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.io
---
name: MegaLinter

# Trigger mega-linter at every push.
# Action will also be visible from Pull Requests to main
on:
push:
branches-ignore:
- main
pull_request:
branches:
- main

# Commentted out env block because we do not want to apply fixes
# env:
# # Apply linter fixes configuration
# #
# # When active, APPLY_FIXES must also be defined as environment variable
# # (in github/workflows/mega-linter.yml or other CI tool)
# APPLY_FIXES: all

# # Decide which event triggers application of fixes in a commit or a PR
# # (pull_request, push, all)
# APPLY_FIXES_EVENT: pull_request

# # If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
# # or posted in a PR (pull_request)
# APPLY_FIXES_MODE: commit

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

jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest

steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
# improve performance
fetch-depth: 0

# MegaLinter
- name: MegaLinter
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses: oxsecurity/megalinter@v7
id: ml

# All available variables are described in documentation
# https://megalinter.io/configuration/
env:
# Validates all source when push on main, else just the git diff with
# main. Override with true if you always want to lint all sources
VALIDATE_ALL_CODEBASE: >-
${{
github.event_name == 'push' &&
contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
}}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Upload MegaLinter artifacts
- name: Archive production artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
4 changes: 3 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

Expand All @@ -10,8 +11,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
# yamllint disable-line rule:indentation
- uses: actions/checkout@v4.1.1

- name: Use Node.js
Expand Down
43 changes: 43 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
###########################
###########################
## Markdown Linter rules ##
###########################
###########################

# Linter rules doc:
# - https://github.com/DavidAnson/markdownlint
#
# Note:
# To comment out a single error:
# <!-- markdownlint-disable -->
# any violations you want
# <!-- markdownlint-restore -->
#

###############
# Rules by id #
###############
MD004: false # Unordered list style
MD007:
indent: 2 # Unordered list indentation
MD009: false # Trailing spaces
MD013:
line_length: 500 # Line length 80 is far to short
MD026:
punctuation: ".,;:!。,;" # List of not allowed
MD029: false # Ordered list item prefix
MD030:
ul_single: 1
ol_single: 1
ul_multi: 1
ol_multi: 1
MD033: false # Allow inline HTML
MD036: false # Emphasis used instead of a heading
MD041: false # First line in a file should be a top-level heading
MD045: false # Images without alt text

#################
# Rules by tags #
#################
blank_lines: false # Error on blank lines
34 changes: 34 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Configuration file for MegaLinter
# See all available variables at https://oxsecurity.github.io/megalinter/configuration/ and in linters documentation

# If you use ENABLE_LINTERS variable, all other linters will be disabled by default
ENABLE_LINTERS:
[
ACTION_ACTIONLINT,
EDITORCONFIG_EDITORCONFIG_CHECKER,
JSON_JSONLINT,
JSON_V8R,
MARKDOWN_MARKDOWNLINT,
REPOSITORY_DUSTILOCK,
REPOSITORY_GIT_DIFF,
REPOSITORY_GRYPE,
REPOSITORY_SECRETLINT,
REPOSITORY_SYFT,
REPOSITORY_TRIVY_SBOM,
REPOSITORY_TRUFFLEHOG,
YAML_V8R,
YAML_YAMLLINT,
]
DISABLE:
- COPYPASTE # Disable checks of excessive copy-pastes
- SPELL # Disable checks of spelling mistakes

DISABLE_ERRORS_LINTERS: [ACTION_ACTIONLINT, REPOSITORY_GRYPE, REPOSITORY_TRIVY, REPOSITORY_TRUFFLEHOG]
SHOW_ELAPSED_TIME: false
FILEIO_REPORTER: false
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
# Exclude certain files from linting
FILTER_REGEX_EXCLUDE: "(lib/.*)"
# If we enable ESLint in the future, use our ESLint rules file
TSX_ESLINT_CONFIG_FILE: www/.eslintrc.yml
21 changes: 21 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
###########################################
# These are the rules used for #
# linting all the yaml files in the stack #
# NOTE: #
# You can disable line with: #
# # yamllint disable-line #
###########################################
extends: default
rules:
braces:
max-spaces-inside: 1
new-lines:
level: warning
type: unix
line-length:
max: 500
comments:
min-spaces-from-content: 1 # Used to follow prettier standard: https://github.com/prettier/prettier/pull/10926
trailing-spaces: disable
truthy: disable
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ endif()
# set the version for webconfig, etc. based on git
find_package(Git)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=7
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_BUILD_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_BUILD_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "v([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" CMAKE_GIT_REPO_VERSION ${GIT_REPO_VERSION})
string(REGEX REPLACE "^(.......-.*)|(.......)$" "0.0.0" CMAKE_GIT_REPO_VERSION ${CMAKE_GIT_REPO_VERSION}) # fix if all we have is the git SHA
configure_file("headers/version.h.in" "headers/version.h")
Expand Down Expand Up @@ -307,5 +307,5 @@ install(FILES

if (NOT (DEFINED ENV(CI)) AND (EXISTS ${CMAKE_SOURCE_DIR}/modules/Custom.cmake))
message(STATUS "Found custom script.")
include(${CMAKE_SOURCE_DIR}/modules/Custom.cmake)
include(${CMAKE_SOURCE_DIR}/modules/Custom.cmake)
endif()
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ Visit the [GP2040-CE Usage](https://gp2040-ce.info/usage) page for more details.

## Performance

Input latency is tested using the methodology outlined at [WydD's inputlag.science website](https://inputlag.science/controller/methodology), using the default 1000 Hz (1 ms) polling rate in the firmware. You can read more about the setup we use to conduct latency testing [HERE](https://github.com/OpenStickCommunity/Site/blob/main/latency_testing/README.md) if you are interested in testing for yourself or would just like to know more about the devices used to do the testing.
Input latency is tested using the methodology outlined at [WydD's inputlag.science website](https://inputlag.science/controller/methodology), using the default 1000 Hz (1 ms) polling rate in the firmware.
You can read more about the setup we use to conduct latency testing [HERE](https://github.com/OpenStickCommunity/Site/blob/main/latency_testing/README.md) if you are interested in testing for yourself or would just like to know more about the devices used to do the testing.

| Version | Mode | Poll Rate | Min | Max | Avg | Stdev | % on time | %1f skip | %2f skip |
| ------- | ------- | --------- | ------- | ------- | ------- | ------- | --------- | -------- | -------- |
Expand Down
18 changes: 9 additions & 9 deletions proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ message ProfileOptions
message DisplayOptions
{
optional bool enabled = 1;

optional int32 deprecatedI2cBlock = 2 [deprecated = true];
optional int32 deprecatedI2cSDAPin = 3 [deprecated = true];
optional int32 deprecatedI2cSCLPin = 4 [deprecated = true];
Expand Down Expand Up @@ -438,7 +438,7 @@ message ReverseOptions
message AnalogADS1219Options
{
optional bool enabled = 1;

optional int32 deprecatedI2cBlock = 2 [deprecated = true];
optional int32 deprecatedI2cSDAPin = 3 [deprecated = true];
optional int32 deprecatedI2cSCLPin = 4 [deprecated = true];
Expand Down Expand Up @@ -764,14 +764,14 @@ message PCF8575Options

message DRV8833RumbleOptions
{
optional bool enabled = 1;
optional bool enabled = 1;

optional int32 leftMotorPin = 2;
optional int32 rightMotorPin = 3;
optional int32 motorSleepPin = 4;
optional uint32 pwmFrequency = 5;
optional float dutyMin = 6;
optional float dutyMax = 7;
optional int32 leftMotorPin = 2;
optional int32 rightMotorPin = 3;
optional int32 motorSleepPin = 4;
optional uint32 pwmFrequency = 5;
optional float dutyMin = 6;
optional float dutyMax = 7;
}

message ReactiveLEDInfo
Expand Down
Loading