Skip to content

ci: bump actions/cache from 3 to 4 #53

ci: bump actions/cache from 3 to 4

ci: bump actions/cache from 3 to 4 #53

name: Build Examples with PlatformIO
# Triggers the workflow on push or pull request events
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
example:
[
examples/GetValues/,
]
steps:
- uses: actions/checkout@v3
- name: Set environment variable for library installation source
run: |
if [[ -z "${GITHUB_HEAD_REF}" ]]; then
echo "::debug::Push to commit ${GITHUB_SHA}"
echo "LIBRARY_INSTALL_SOURCE=https://github.com/${GITHUB_REPOSITORY}.git#${GITHUB_SHA}" >> $GITHUB_ENV
else
echo "::debug::Pull Request from the ${GITHUB_HEAD_REF} branch"
echo "LIBRARY_INSTALL_SOURCE=https://github.com/${GITHUB_REPOSITORY}.git#${GITHUB_HEAD_REF}" >> $GITHUB_ENV
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Restore PlatformIO Platforms and Libraries
uses: actions/cache@v4
id: cache_libraries
with:
path: ~/.platformio
# if nothing in the library.json file has changed, then it will
# be a "cache hit" and we can restore libraries from cache and not
# download them. If it has changed we have to re-download.
key: ${{ hashFiles('**/library.json') }}
# Install the dependencies for PlatformIO
- name: Install the PlatformIO dependencies at global level
if: steps.cache_libraries.outputs.cache-hit != 'true'
run: |
pio lib -g install envirodiy/SensorModbusMaster
pio lib -g install https://github.com/PaulStoffregen/AltSoftSerial.git
pio lib -g install https://github.com/switchdoclabs/SDL_Arduino_SSD1306.git
# Install YosemitechModbus at the Global level for PlatformIO
# Force install to get the right version
- name: Install the testing version of Yosemitech Modbus for PlatformIO
run: |
pio lib -g install -f ${{ env.LIBRARY_INSTALL_SOURCE }}
pio lib show YosemitechModbus
- name: Run PlatformIO
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
run: |
echo "${{ env.LIBRARY_INSTALL_SOURCE }}"
platformio ci --project-conf="continuous_integration/platformio.ini"
# NOTE: Don't uninstall for PlatformIO because the library manager will clean up the
# dependencies leaving nothing for the cache
# - name: Uninstall testing version of Yosemitech Modbus before caching
# run: pio lib -g uninstall YosemitechModbus