From 9e33931b7e3d13721ed25a393c669bf299e35695 Mon Sep 17 00:00:00 2001 From: Anton Afanasyev Date: Tue, 28 Apr 2026 14:34:46 -0700 Subject: [PATCH] ci: modernize platformio workflow --- .github/dependabot.yml | 13 +++ .github/scripts/install-platformio.sh | 133 -------------------------- .github/scripts/on-push.sh | 20 ---- .github/stale.yml | 31 ------ .github/workflows/ci.yml | 52 ++++++++++ .github/workflows/publish.yml | 31 ++++++ .github/workflows/push.yml | 30 ------ 7 files changed, 96 insertions(+), 214 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 .github/scripts/install-platformio.sh delete mode 100755 .github/scripts/on-push.sh delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/push.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b288043 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + commit-message: + prefix: "ci" + include: "scope" + labels: + - "dependencies" diff --git a/.github/scripts/install-platformio.sh b/.github/scripts/install-platformio.sh deleted file mode 100644 index 61c94fe..0000000 --- a/.github/scripts/install-platformio.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash - -echo "Installing Python Wheel ..." -pip install wheel > /dev/null 2>&1 - -echo "Installing PlatformIO ..." -pip install -U platformio > /dev/null 2>&1 - -echo "PlatformIO has been installed" -echo "" - - -function build_pio_sketch(){ # build_pio_sketch - if [ "$#" -lt 2 ]; then - echo "ERROR: Illegal number of parameters" - echo "USAGE: build_pio_sketch " - return 1 - fi - - local board="$1" - local sketch="$2" - local sketch_dir=$(dirname "$sketch") - echo "" - echo "Compiling '"$(basename "$sketch")"' ..." - python -m platformio ci -l '.' --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv" -} - -function count_sketches() # count_sketches -{ - local examples="$1" - rm -rf sketches.txt - if [ ! -d "$examples" ]; then - touch sketches.txt - return 0 - fi - local sketches=$(find $examples -name *.ino) - local sketchnum=0 - for sketch in $sketches; do - local sketchdir=$(dirname $sketch) - local sketchdirname=$(basename $sketchdir) - local sketchname=$(basename $sketch) - if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then - continue - fi; - if [[ -f "$sketchdir/.test.skip" ]]; then - continue - fi - echo $sketch >> sketches.txt - sketchnum=$(($sketchnum + 1)) - done - return $sketchnum -} - -function build_pio_sketches() # build_pio_sketches -{ - if [ "$#" -lt 2 ]; then - echo "ERROR: Illegal number of parameters" - echo "USAGE: build_pio_sketches [ ]" - return 1 - fi - - local board=$1 - local examples=$2 - local chunk_idex=$3 - local chunks_num=$4 - - if [ "$#" -lt 4 ]; then - chunk_idex="0" - chunks_num="1" - fi - - if [ "$chunks_num" -le 0 ]; then - echo "ERROR: Chunks count must be positive number" - return 1 - fi - if [ "$chunk_idex" -ge "$chunks_num" ]; then - echo "ERROR: Chunk index must be less than chunks count" - return 1 - fi - - set +e - count_sketches "$examples" - local sketchcount=$? - set -e - local sketches=$(cat sketches.txt) - rm -rf sketches.txt - - local chunk_size=$(( $sketchcount / $chunks_num )) - local all_chunks=$(( $chunks_num * $chunk_size )) - if [ "$all_chunks" -lt "$sketchcount" ]; then - chunk_size=$(( $chunk_size + 1 )) - fi - - local start_index=$(( $chunk_idex * $chunk_size )) - if [ "$sketchcount" -le "$start_index" ]; then - echo "Skipping job" - return 0 - fi - - local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) - if [ "$end_index" -gt "$sketchcount" ]; then - end_index=$sketchcount - fi - - local start_num=$(( $start_index + 1 )) - echo "Found $sketchcount Sketches"; - echo "Chunk Count : $chunks_num" - echo "Chunk Size : $chunk_size" - echo "Start Sketch: $start_num" - echo "End Sketch : $end_index" - - local sketchnum=0 - for sketch in $sketches; do - local sketchdir=$(dirname $sketch) - local sketchdirname=$(basename $sketchdir) - local sketchname=$(basename $sketch) - if [ "${sketchdirname}.ino" != "$sketchname" ] \ - || [ -f "$sketchdir/.test.skip" ]; then - continue - fi - sketchnum=$(($sketchnum + 1)) - if [ "$sketchnum" -le "$start_index" ] \ - || [ "$sketchnum" -gt "$end_index" ]; then - continue - fi - build_pio_sketch "$board" "$sketch" - local result=$? - if [ $result -ne 0 ]; then - return $result - fi - done - return 0 -} diff --git a/.github/scripts/on-push.sh b/.github/scripts/on-push.sh deleted file mode 100755 index 66f3024..0000000 --- a/.github/scripts/on-push.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -e - -if [ ! -z "$TRAVIS_BUILD_DIR" ]; then - export GITHUB_WORKSPACE="$TRAVIS_BUILD_DIR" - export GITHUB_REPOSITORY="$TRAVIS_REPO_SLUG" -elif [ -z "$GITHUB_WORKSPACE" ]; then - export GITHUB_WORKSPACE="$PWD" - export GITHUB_REPOSITORY="esphome/async-mqtt-client" -fi - -# PlatformIO Test -source ./.github/scripts/install-platformio.sh - -echo "Installing ESPAsyncTCP ..." -python -m platformio lib --storage-dir "$GITHUB_WORKSPACE" install - -build_pio_sketches "esp12e" "$GITHUB_WORKSPACE/examples/FullyFeatured-ESP8266" -build_pio_sketches "esp32dev" "$GITHUB_WORKSPACE/examples/FullyFeatured-ESP32" diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index ce7a8e3..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale - -daysUntilStale: 60 -daysUntilClose: 14 -limitPerRun: 30 -staleLabel: stale -exemptLabels: - - pinned - - security - - "to be implemented" - - "for reference" - - "move to PR" - - "enhancement" - -only: issues -onlyLabels: [] -exemptProjects: false -exemptMilestones: false -exemptAssignees: false - -markComment: > - [STALE_SET] This issue has been automatically marked as stale because it has not had - recent activity. It will be closed in 14 days if no further activity occurs. Thank you - for your contributions. - -unmarkComment: > - [STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. - -closeComment: > - [STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..32da7f0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +--- +name: CI + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + platformio: + name: PlatformIO Build (${{ matrix.name }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: ESP8266 + board: esp12e + example: examples/FullyFeatured-ESP8266 + - name: ESP32 + board: esp32dev + example: examples/FullyFeatured-ESP32 + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: "3.12" + + - name: Cache PlatformIO + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + with: + path: ~/.platformio + key: pio-${{ runner.os }}-${{ matrix.name }}-${{ hashFiles('library.json', '.github/workflows/ci.yml') }} + restore-keys: | + pio-${{ runner.os }}-${{ matrix.name }}- + pio-${{ runner.os }}- + + - name: Install PlatformIO + run: pip install platformio + + - name: Validate PlatformIO package metadata + run: pio package pack --output /tmp + + - name: Build ${{ matrix.name }} example + run: python -m platformio ci -l . --board ${{ matrix.board }} ${{ matrix.example }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..08ab1d6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +--- +name: Publish + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + publish-platformio: + name: Publish to PlatformIO + runs-on: ubuntu-latest + environment: platformio + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: "3.x" + + - name: Install PlatformIO + run: pip install --upgrade platformio + + - name: Publish package + env: + PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} + run: pio package publish --owner esphome --non-interactive diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 29bbe0f..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Async MQTT client CI - -on: - push: - branches: - pull_request: - -jobs: - - build-pio: - name: PlatformIO on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: | - ~/.cache/pip - ~/.platformio/.cache - key: ${{ runner.os }}-pio - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Install PlatformIO Core - run: pip install --upgrade platformio - - name: Build Tests - run: bash ./.github/scripts/on-push.sh