1.2.8 (#186) #193
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PlatformIOBuild | |
env: | |
PROJECT_DIR: examples/Test/build_test | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
on: | |
push: | |
paths: | |
- '**.ino' | |
- '**.ini' | |
- '**.cpp' | |
- '**.hpp' | |
- '**.h' | |
- '**.c' | |
- '**PlatformioBuild.yml' | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
set_matrix: | |
name: Version planner ⊹ | |
runs-on: ubuntu-latest | |
env: | |
max-versions: 3 # maximum core versions to test, starting at latest | |
outputs: | |
matrix: ${{steps.set-matrix.outputs.matrix}} | |
project_dir: ${{steps.set-matrix.outputs.project_dir}} | |
branch_name: ${{steps.set-matrix.outputs.branch_name}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup matrix | |
id: set-matrix | |
run: | | |
json=`curl -s "https://espressif.github.io/arduino-esp32/package_esp32_index.json"` # get a list of arduino-esp32 packages | |
core_versions_arr=(`echo $json | jq -r .packages[0].platforms[].version | awk "NR <= ${{ env.max-versions}}"`) # extract platform versions | |
core_versions_json=`printf '%s\n' "${core_versions_arr[@]}" | jq -R . | jq -s .` # convert to json | |
pio_envs_arr=(`cat ${{env.PROJECT_DIR}}/platformio.ini | awk 'match($0, /^\[env:([a-zA-Z0-9\-_])+/){print substr($0, RSTART+5, RLENGTH-5)}'`) # get pio [env:*] names | |
pio_envs_json=`printf '%s\n' "${pio_envs_arr[@]}" | jq -R . | jq -s .` # convert to json array | |
matrix=`printf '{"pio-env":%s,"platform-version":%s}' "$pio_envs_json" "$core_versions_json"` # create the matrix array | |
matrix="${matrix//'%'/'%25'}" # escape percent entities | |
matrix="${matrix//$'\n'/''}" # remove lf | |
matrix="${matrix//$'\r'/''}" # remove cr | |
echo "matrix=${matrix}" >> $GITHUB_OUTPUT | |
echo "project_dir=${{env.PROJECT_DIR}}" >> $GITHUB_OUTPUT | |
echo "branch_name=${{env.BRANCH_NAME}}" >> $GITHUB_OUTPUT | |
build: | |
name: ${{ matrix.pio-env }}@${{ matrix.platform-version }} | |
needs: set_matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{fromJSON(needs.set_matrix.outputs.matrix)}} | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Cache pip | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Cache PlatformIO | |
uses: actions/cache@v3 | |
with: | |
path: ~/.platformio | |
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install PlatformIO | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade platformio | |
pio update | |
pio upgrade | |
- name: Run PlatformIO | |
run: | | |
cd ${{ needs.set_matrix.outputs.project_dir }} | |
export pio_ver=${{ matrix.platform-version }} | |
# append "test" profile to the current platformio.ini | |
echo "[env:test]">>platformio.ini | |
echo "extends = env:${{ matrix.pio-env }}">>platformio.ini | |
echo "platform = https://github.com/tasmota/platform-espressif32">>platformio.ini | |
echo "platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32/releases/download/${pio_ver}/esp32-${pio_ver}.zip">>platformio.ini | |
echo "">>platformio.ini | |
# keep cache and dev_lib_deps.ini unless running from the master branch | |
[[ "${{ needs.set_matrix.outputs.branch_name }}" == "master" ]] && rm dev_lib_deps.ini || echo "Develop!" && pio system prune -f | |
# install local version of the library | |
pio pkg install -e test --no-save --library file://$(realpath ../../../) | |
pio run -e test |