diff --git a/.github/workflows/release_tag.yml b/.github/workflows/release_tag.yml new file mode 100644 index 0000000..94df2cf --- /dev/null +++ b/.github/workflows/release_tag.yml @@ -0,0 +1,32 @@ +--- +name: Update Tags + +# yamllint disable-line rule:truthy +on: + release: + types: [published] + +jobs: + update-tags: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + with: + fetch-depth: '0' + + - name: Set up Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Move and push stable tag + run: | + git tag -f stable ${{ github.event.release.tag_name }} + git push -f origin stable + + - name: Move and push latest tag + run: | + git tag -f latest ${{ github.event.release.tag_name }} + git push -f origin latest +... diff --git a/.github/workflows/validate_clang_format.yml b/.github/workflows/validate_clang_format.yml new file mode 100644 index 0000000..4379668 --- /dev/null +++ b/.github/workflows/validate_clang_format.yml @@ -0,0 +1,26 @@ +--- +name: Validate C++ (Clang Format) + +# yamllint disable-line rule:truthy +on: + push: + paths: + - '**/*.h' + - '**/*.c' + - '**/*.cpp' + pull_request: + paths: + - '**/*.h' + - '**/*.c' + - '**/*.cpp' + workflow_dispatch: + +jobs: + clang-format-checking: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: RafikFarhad/clang-format-github-action@v3 + with: + sources: "components/tx_ultimate_easy/*.h,components/tx_ultimate_easy/*.cpp" +... diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml new file mode 100644 index 0000000..cdf5473 --- /dev/null +++ b/.github/workflows/validate_esphome.yml @@ -0,0 +1,116 @@ +--- +name: Validate and Build ESPHome + +# yamllint disable-line rule:truthy +on: + push: + paths: + - "*.yaml" + - "prebuilt/*.yaml" + - ".test/*.yaml" + - "*.h" + - "*.c" + - "*.cpp" + - "*.py" + pull_request: + paths: + - "*.yaml" + - "prebuilt/*.yaml" + - ".test/*.yaml" + - "*.h" + - "*.c" + - "*.cpp" + - "*.py" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + setup_dependencies: + name: Setup & Cache Dependencies + runs-on: ubuntu-latest + outputs: + cache-hit-arduino: ${{ steps.cache-arduino.outputs.cache-hit }} + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Cache Arduino Dependencies + id: cache-arduino + uses: actions/cache@main + with: + path: | + ~/.esphome/cache + ~/.platformio/packages + ~/.platformio/platforms + key: ${{ runner.os }}-arduino-${{ hashFiles('**/esphome_ard_basic.yaml') }} + restore-keys: | + ${{ runner.os }}-arduino- + + code_scan: + name: Code scan (YAML) + runs-on: "ubuntu-latest" + needs: setup_dependencies + steps: + - name: Checkout Code + uses: actions/checkout@main + + - name: Setup Python + uses: actions/setup-python@main + with: + python-version: '3.8' + + - name: Install Yamllint + run: pip install yamllint + + - name: Validate YAML files + run: find . -name "*.yaml" -exec yamllint -c ./.rules/yamllint.yml {} + + + build_basic: + name: Basic + needs: [code_scan, setup_dependencies] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - id: ard + yaml_file: ".test/esphome_ard_basic.yaml" + cache-hit: ${{ needs.setup_dependencies.outputs.cache-hit-arduino }} + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Firmware + if: steps.matrix.outputs.cache-hit != 'true' + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: ${{ matrix.yaml_file }} + + build_bluetooth_proxy: + name: Bluetooth Proxy + needs: build_basic + runs-on: ubuntu-latest + strategy: + matrix: + include: + - id: idf_v4 + base: idf_v4 + yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" + - id: idf_v5 + base: idf_v5 + yaml_file: ".test/esphome_idf5_bluetooth_proxy.yaml" + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Build Bluetooth Proxy Firmware + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: ${{ matrix.yaml_file }} +... diff --git a/.github/workflows/validate_esphome_beta.yml b/.github/workflows/validate_esphome_beta.yml new file mode 100644 index 0000000..36f3adf --- /dev/null +++ b/.github/workflows/validate_esphome_beta.yml @@ -0,0 +1,101 @@ +--- + name: Validate ESPHome (Beta) + + # yamllint disable-line rule:truthy + on: + workflow_dispatch: + + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + + jobs: + setup_dependencies: + name: Setup & Cache Dependencies + runs-on: ubuntu-latest + outputs: + cache-hit-arduino: ${{ steps.cache-arduino.outputs.cache-hit }} + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Cache Arduino Dependencies + id: cache-arduino + uses: actions/cache@main + with: + path: | + ~/.esphome/cache + ~/.platformio/packages + ~/.platformio/platforms + key: ${{ runner.os }}-arduino-${{ hashFiles('**/esphome_ard_basic.yaml') }} + restore-keys: | + ${{ runner.os }}-arduino- + + code_scan: + name: Code scan (YAML) + runs-on: "ubuntu-latest" + needs: setup_dependencies + steps: + - name: Checkout Code + uses: actions/checkout@main + + - name: Setup Python + uses: actions/setup-python@main + with: + python-version: '3.8' + + - name: Install Yamllint + run: pip install yamllint + + - name: Validate YAML files + run: find . -name "*.yaml" -exec yamllint -c ./.rules/yamllint.yml {} + + + build_basic: + name: Basic + needs: [code_scan, setup_dependencies] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - id: ard + yaml_file: ".test/esphome_ard_basic.yaml" + cache-hit: ${{ needs.setup_dependencies.outputs.cache-hit-arduino }} + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Firmware + if: steps.matrix.outputs.cache-hit != 'true' + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: ${{ matrix.yaml_file }} + version: beta + + build_bluetooth_proxy: + name: Bluetooth Proxy + needs: build_basic + runs-on: ubuntu-latest + strategy: + matrix: + include: + - id: idf_v4 + base: idf_v4 + yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" + - id: idf_v5 + base: idf_v5 + yaml_file: ".test/esphome_idf5_bluetooth_proxy.yaml" + + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Build Bluetooth Proxy Firmware + uses: barndawgie/build-action@v1.9.0 + with: + yaml_file: ${{ matrix.yaml_file }} + version: beta +... + \ No newline at end of file diff --git a/.github/workflows/validate_markdown.yml b/.github/workflows/validate_markdown.yml new file mode 100644 index 0000000..1991d59 --- /dev/null +++ b/.github/workflows/validate_markdown.yml @@ -0,0 +1,58 @@ +--- +name: Validate Markdown + +# yamllint disable-line rule:truthy +on: + pull_request: + paths: + - '**/*.md' + push: + paths: + - '**/*.md' + workflow_dispatch: + +jobs: + markdown-lint: + name: Markdown Lint + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + with: + fetch-depth: '0' + + # https://github.com/marketplace/actions/markdownlint-cli2-action + - name: Identify changed files + uses: tj-actions/changed-files@v41 + id: changed-files + with: + files: '**/*.md' + separator: "," + # https://github.com/marketplace/actions/markdownlint-cli2-action + - name: Markdown Lint + uses: DavidAnson/markdownlint-cli2-action@v14 + if: steps.changed-files.outputs.any_changed == 'true' + with: + globs: ${{ steps.changed-files.outputs.all_changed_files }} + separator: "," + config: '.rules/.markdownlint.jsonc' + fix: true + + markdown-links: + name: Check links + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + with: + fetch-depth: '0' + + # https://github.com/gaurav-nelson/github-action-markdown-link-check + - name: Markdown links + uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + # yamllint disable-line rule:truthy + check-modified-files-only: yes + config-file: '.rules/mlc_config.json' + base-branch: 'main' +... diff --git a/.github/workflows/validate_python.yml b/.github/workflows/validate_python.yml new file mode 100644 index 0000000..4804b57 --- /dev/null +++ b/.github/workflows/validate_python.yml @@ -0,0 +1,30 @@ +--- +name: Validate Python (flake8) + +# yamllint disable-line rule:truthy +on: + push: + paths: + - '*.py' + pull_request: + paths: + - '*.py' + workflow_dispatch: + +jobs: + flake8-lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Check out source repository + uses: actions/checkout@main + - name: Set up Python environment + uses: actions/setup-python@main + with: + python-version: "3.11" + - name: flake8 Lint + uses: py-actions/flake8@v2 + with: + max-line-length: "200" + path: "components/tx_ultimate_easy" +... diff --git a/.github/workflows/validate_yamllint.yml b/.github/workflows/validate_yamllint.yml new file mode 100644 index 0000000..87a2c71 --- /dev/null +++ b/.github/workflows/validate_yamllint.yml @@ -0,0 +1,47 @@ +--- +name: Validate YAML (secondary files) + +# yamllint disable-line rule:truthy +on: + push: + paths: + - '**/*.yml' + - '**/*.yaml' + pull_request: + paths: + - '**/*.yml' + - '**/*.yaml' + workflow_dispatch: + +jobs: + code_scan: + name: Validate YAML + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + with: + fetch-depth: '0' + + - name: Identify changed files + uses: tj-actions/changed-files@v41 + id: changed-files + with: + files: '**/*.y*ml' + separator: "," + + - name: Validate YAML + if: steps.changed-files.outputs.any_changed == 'true' + run: | + IFS=',' read -ra FILES <<< "${{ steps.changed-files.outputs.all_changed_files }}" + for file in "${FILES[@]}"; do + if [[ "$file" =~ ^*\.yaml$ ]] || \ + [[ "$file" =~ ^ESPHome/*\.yaml$ ]]; then + echo "Skipping $file" + continue + fi + echo "::group::Validating $file" + yamllint -c "./.rules/yamllint.yml" "$file" + echo "::endgroup::" + done +... diff --git a/.rules/.markdownlint.jsonc b/.rules/.markdownlint.jsonc new file mode 100644 index 0000000..e2a6e5b --- /dev/null +++ b/.rules/.markdownlint.jsonc @@ -0,0 +1,4 @@ +{ + "MD013": { "line_length": 200 } +} + \ No newline at end of file diff --git a/.rules/markdownlint.yml b/.rules/markdownlint.yml new file mode 100644 index 0000000..77abf70 --- /dev/null +++ b/.rules/markdownlint.yml @@ -0,0 +1,2 @@ +MD013: + line_length: 200 diff --git a/.rules/mlc_config.json b/.rules/mlc_config.json new file mode 100644 index 0000000..d66eb2f --- /dev/null +++ b/.rules/mlc_config.json @@ -0,0 +1,13 @@ +{ + "ignorePatterns": [ + { + "pattern": "^http://homeassistant\\.local.*$" + }, + { + "pattern": "^https://sonoff.tech/product/central-control-panel/nspanel/$" + }, + { + "pattern": "^https://sonoff.tech/wp-content/uploads/2021/11/%E4%BA%A7%E5%93%81%E5%8F%82%E6%95%B0%E8%A1%A8-NSPanel-20210831.pdf$" + } + ] +} diff --git a/.rules/yamllint.yml b/.rules/yamllint.yml new file mode 100644 index 0000000..0c1d80e --- /dev/null +++ b/.rules/yamllint.yml @@ -0,0 +1,42 @@ +# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration +--- +yaml-files: + - '*.yaml' + - '*.yml' + - '.yamllint' + +rules: + anchors: + forbid-undeclared-aliases: true + forbid-duplicated-anchors: true + braces: enable + brackets: enable + colons: enable + commas: enable + comments: + level: warning + comments-indentation: + level: warning + document-end: + level: warning + document-start: + level: warning + empty-lines: enable + empty-values: disable + float-values: + level: warning + hyphens: enable + indentation: enable + key-duplicates: enable + key-ordering: disable + line-length: + max: 200 + new-line-at-end-of-file: enable + new-lines: enable + octal-values: + level: warning + quoted-strings: disable + trailing-spaces: enable + truthy: + level: warning +... diff --git a/.test/esphome_ard_basic.yaml b/.test/esphome_ard_basic.yaml new file mode 100644 index 0000000..dbda8d8 --- /dev/null +++ b/.test/esphome_ard_basic.yaml @@ -0,0 +1,8 @@ +--- +packages: + basic_package: !include ../TX-Ultimate-Easy-ESPHome.yaml # Basic package + +esp32: + framework: + type: arduino +... diff --git a/.test/esphome_idf5_bluetooth_proxy.yaml b/.test/esphome_idf5_bluetooth_proxy.yaml new file mode 100644 index 0000000..1ca452f --- /dev/null +++ b/.test/esphome_idf5_bluetooth_proxy.yaml @@ -0,0 +1,11 @@ +--- +packages: + basic_package: !include ../TX-Ultimate-Easy-ESPHome.yaml # Core package + addon_bluetooth_proxy: !include ../ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml + +esp32: + framework: + type: esp-idf + version: 5.0.2 + platform_version: 6.3.2 +... diff --git a/.test/esphome_idf_bluetooth_proxy.yaml b/.test/esphome_idf_bluetooth_proxy.yaml new file mode 100644 index 0000000..a2f9a0b --- /dev/null +++ b/.test/esphome_idf_bluetooth_proxy.yaml @@ -0,0 +1,5 @@ +--- +packages: + basic_package: !include ../TX-Ultimate-Easy-ESPHome.yaml # Core package + addon_bluetooth_proxy: !include ../ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml +... diff --git a/.test/secrets.yaml b/.test/secrets.yaml new file mode 100644 index 0000000..e6b6199 --- /dev/null +++ b/.test/secrets.yaml @@ -0,0 +1,9 @@ +--- +api_encryption_key: MSANehPIH8kCp/vGcpPcKPSkYnv3zchyxkXCleXJinM= +mysntpserver: 192.168.0.1 +web_server_password: NotASecret01 +web_server_username: NotASecret01 +wifi_password: NotASecret01 +wifi_password_backup: NotASecret01 +wifi_ssid_backup: NotASecret01 +...