From db3d66544dde3c8ada4cee48fabe627d2e9aadec Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Tue, 17 Jan 2023 16:35:26 +1000 Subject: [PATCH] Setup Trunk (#2143) Co-authored-by: Ben Meadors --- .github/workflows/main_matrix.yml | 11 ++- .github/workflows/nightly.yml | 19 +++++ .trunk/.gitignore | 7 ++ .clang-format => .trunk/configs/.clang-format | 0 .trunk/configs/.hadolint.yaml | 4 + .trunk/configs/.markdownlint.yaml | 10 +++ .trunk/configs/.shellcheckrc | 7 ++ .trunk/configs/svgo.config.js | 14 ++++ .trunk/trunk.yaml | 32 ++++++++ .vscode/extensions.json | 6 +- .vscode/settings.json | 82 +------------------ 11 files changed, 105 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 100644 .trunk/.gitignore rename .clang-format => .trunk/configs/.clang-format (100%) create mode 100644 .trunk/configs/.hadolint.yaml create mode 100644 .trunk/configs/.markdownlint.yaml create mode 100644 .trunk/configs/.shellcheckrc create mode 100644 .trunk/configs/svgo.config.js create mode 100644 .trunk/trunk.yaml diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 1953619c8..420ad0e35 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -33,7 +33,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - board: tlora-t3s3-v1 - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,6 +41,9 @@ jobs: id: base uses: ./.github/actions/setup-base + - name: Trunk Check + uses: trunk-io/trunk-action@v1 + - name: Check ${{ matrix.board }} run: bin/check-all.sh ${{ matrix.board }} @@ -132,11 +135,11 @@ jobs: path: | release/device-*.sh release/device-*.bat - + - name: Docker login if: ${{ github.event_name == 'workflow_dispatch' }} uses: docker/login-action@v2 - with: + with: username: meshtastic password: ${{ secrets.DOCKER_TOKEN }} @@ -152,7 +155,7 @@ jobs: file: ./Dockerfile push: true tags: meshtastic/device-simulator:latest - + after-checks: runs-on: ubuntu-latest needs: [check] diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..d9d52a2a4 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,19 @@ +name: Nightly +on: + schedule: + - cron: 0 8 * * 1-5 + workflow_dispatch: {} + +jobs: + trunk_check: + name: Trunk Check Upload + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Trunk Check + uses: trunk-io/trunk-action@v1 + with: + trunk-token: ${{ secrets.TRUNK_TOKEN }} diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 000000000..cf2f25470 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,7 @@ +*out +*logs +*actions +*notifications +plugins +user_trunk.yaml +user.yaml diff --git a/.clang-format b/.trunk/configs/.clang-format similarity index 100% rename from .clang-format rename to .trunk/configs/.clang-format diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml new file mode 100644 index 000000000..98bf0cd2e --- /dev/null +++ b/.trunk/configs/.hadolint.yaml @@ -0,0 +1,4 @@ +# Following source doesn't work in most setups +ignored: + - SC1090 + - SC1091 diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 000000000..fb940393d --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,10 @@ +# Autoformatter friendly markdownlint config (all formatting rules disabled) +default: true +blank_lines: false +bullet: false +html: false +indentation: false +line_length: false +spaces: false +url: false +whitespace: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 000000000..8c7b1ada8 --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/svgo.config.js b/.trunk/configs/svgo.config.js new file mode 100644 index 000000000..b257d1349 --- /dev/null +++ b/.trunk/configs/svgo.config.js @@ -0,0 +1,14 @@ +module.exports = { + plugins: [ + { + name: "preset-default", + params: { + overrides: { + removeViewBox: false, // https://github.com/svg/svgo/issues/1128 + sortAttrs: true, + removeOffCanvasPaths: true, + }, + }, + }, + ], +}; diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 000000000..3ba9cca33 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,32 @@ +version: 0.1 +cli: + version: 1.3.1 +plugins: + sources: + - id: trunk + ref: v0.0.8 + uri: https://github.com/trunk-io/plugins +lint: + enabled: + - shellcheck@0.9.0 + - shfmt@3.5.0 + - oxipng@8.0.0 + - actionlint@1.6.22 + - git-diff-check + - gitleaks@8.15.2 + - markdownlint@0.33.0 + - hadolint@2.12.0 + - clang-format@14.0.0 + - prettier@2.8.3 + - svgo@3.0.2 +runtimes: + enabled: + - go@1.18.3 + - node@18.12.1 +actions: + disabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + enabled: + - trunk-upgrade-available diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9a91518aa..4fc84fa78 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,10 +2,8 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ + "ms-vscode.cpptools", "platformio.platformio-ide", - "xaver.clang-format" + "trunk.io" ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 21b7b97b7..3b489975b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,80 +1,4 @@ { - "files.associations": { - "type_traits": "cpp", - "array": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "istream": "cpp", - "limits": "cpp", - "memory": "cpp", - "new": "cpp", - "ostream": "cpp", - "numeric": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "cinttypes": "cpp", - "utility": "cpp", - "typeinfo": "cpp", - "string": "cpp", - "*.xbm": "cpp", - "list": "cpp", - "atomic": "cpp", - "memory_resource": "cpp", - "optional": "cpp", - "string_view": "cpp", - "cassert": "cpp", - "iterator": "cpp", - "shared_mutex": "cpp", - "iostream": "cpp", - "esp_nimble_hci.h": "c", - "map": "cpp", - "random": "cpp", - "*.tpp": "cpp" - }, - "cSpell.words": [ - "Blox", - "EINK", - "HFSR", - "Meshtastic", - "NEMAGPS", - "NMEAGPS", - "RDEF", - "Ublox", - "bkpt", - "cfsr", - "descs", - "ocrypto", - "protobufs", - "wifi" - ], - "C_Cpp.dimInactiveRegions": true, - "cmake.configureOnOpen": true, - "protoc": { - "compile_on_save": false, - } -} \ No newline at end of file + "editor.formatOnSave": true, + "editor.defaultFormatter": "trunk.io" +}