Skip to content

Commit

Permalink
Merge remote-tracking branch 'HeMan/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Sep 14, 2023
2 parents a659596 + 38987d7 commit 9442e15
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 27 deletions.
133 changes: 133 additions & 0 deletions .github/scripts/install-platformio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/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 <board> <path-to-ino>
if [ "$#" -lt 2 ]; then
echo "ERROR: Illegal number of parameters"
echo "USAGE: build_pio_sketch <board> <path-to-ino>"
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 <examples-path>
{
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 <board> <examples-path> <chunk> <total-chunks>
{
if [ "$#" -lt 2 ]; then
echo "ERROR: Illegal number of parameters"
echo "USAGE: build_pio_sketches <board> <examples-path> [<chunk> <total-chunks>]"
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
}
20 changes: 20 additions & 0 deletions .github/scripts/on-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/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"
31 changes: 31 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.
30 changes: 30 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Async MQTT client for ESP8266 and ESP32
=============================

[![Build Status](https://img.shields.io/travis/marvinroger/async-mqtt-client/master.svg?style=flat-square)](https://travis-ci.org/marvinroger/async-mqtt-client)
[![Build Status](https://github.com/HeMan/async-mqtt-client/actions/workflows/push.yml/badge.svg)](https://github.com/HeMan/async-mqtt-client/actions/workflows/push.yml)

A maintained fork of the [AsyncMQTTClient](https://github.com/marvinroger/async-mqtt-client) library by [@marvinroger](https://github.com/marvinroger) for [ESPHome](https://esphome.io).

Expand Down
12 changes: 6 additions & 6 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
"repository":
{
"type": "git",
"url": "https://github.com/OttoWinter/async-mqtt-client.git"
"url": "https://github.com/HeMan/async-mqtt-client.git"
},
"version": "0.8.6",
"version": "1.1.1",
"frameworks": "arduino",
"platforms": ["espressif8266", "espressif32"],
"platforms": ["espressif8266", "espressif32","rp2040"],
"dependencies": [
{
"owner": "ottowinter",
"owner": "esphome",
"name": "ESPAsyncTCP-esphome",
"version": "^1.2.2",
"version": "^2.0.0",
"platforms": "espressif8266"
},
{
"owner": "esphome",
"name": "AsyncTCP-esphome",
"version": "^1.1.1",
"version": "^2.0.1",
"platforms": "espressif32"
}
]
Expand Down
5 changes: 5 additions & 0 deletions src/AsyncMqttClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <freertos/semphr.h>
#elif defined(ESP8266)
#include <ESPAsyncTCP.h>
#elif defined(USE_RP2040)
#include <AsyncTCP_RP2040W.h>
#elif defined(LIBRETUYA)
#include <AsyncTCP.h>
#include <semphr.h>
Expand Down Expand Up @@ -47,6 +49,9 @@
#elif defined(ESP8266)
#define SEMAPHORE_TAKE(X) void()
#define SEMAPHORE_GIVE() void()
#elif defined(USE_RP2040)
#define SEMAPHORE_TAKE(X) void()
#define SEMAPHORE_GIVE() void()
#endif

class AsyncMqttClient {
Expand Down

0 comments on commit 9442e15

Please sign in to comment.