Skip to content

Commit

Permalink
Add validation
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Jun 19, 2024
1 parent d4cfaae commit 6731da7
Show file tree
Hide file tree
Showing 15 changed files with 504 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release_tag.yml
Original file line number Diff line number Diff line change
@@ -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
...
26 changes: 26 additions & 0 deletions .github/workflows/validate_clang_format.yml
Original file line number Diff line number Diff line change
@@ -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"
...
116 changes: 116 additions & 0 deletions .github/workflows/validate_esphome.yml
Original file line number Diff line number Diff line change
@@ -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 }}
...
101 changes: 101 additions & 0 deletions .github/workflows/validate_esphome_beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
name: Validate ESPHome (Beta)

Check failure on line 2 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

2:3 [indentation] wrong indentation: expected 0 but found 2

Check failure on line 3 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

3:1 [trailing-spaces] trailing spaces
# yamllint disable-line rule:truthy
on:
workflow_dispatch:

Check failure on line 7 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

7:1 [trailing-spaces] trailing spaces
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

Check failure on line 11 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

11:1 [trailing-spaces] trailing spaces
jobs:
setup_dependencies:
name: Setup & Cache Dependencies
runs-on: ubuntu-latest
outputs:
cache-hit-arduino: ${{ steps.cache-arduino.outputs.cache-hit }}

Check failure on line 18 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

18:1 [trailing-spaces] trailing spaces
steps:
- name: Checkout repository
uses: actions/checkout@main

Check failure on line 22 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

22:1 [trailing-spaces] trailing spaces
- 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-

Check failure on line 34 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

34:1 [trailing-spaces] trailing spaces
code_scan:
name: Code scan (YAML)
runs-on: "ubuntu-latest"
needs: setup_dependencies
steps:
- name: Checkout Code
uses: actions/checkout@main

Check failure on line 42 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

42:1 [trailing-spaces] trailing spaces
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: '3.8'

Check failure on line 47 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

47:1 [trailing-spaces] trailing spaces
- name: Install Yamllint
run: pip install yamllint

Check failure on line 50 in .github/workflows/validate_esphome_beta.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

50:1 [trailing-spaces] trailing spaces
- 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
...

58 changes: 58 additions & 0 deletions .github/workflows/validate_markdown.yml
Original file line number Diff line number Diff line change
@@ -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'
...
30 changes: 30 additions & 0 deletions .github/workflows/validate_python.yml
Original file line number Diff line number Diff line change
@@ -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"
...
Loading

0 comments on commit 6731da7

Please sign in to comment.