From 23076222f75c4c491037e54dd204dac8953a8b9d Mon Sep 17 00:00:00 2001 From: karniv00l Date: Sat, 13 Nov 2021 19:46:37 +0100 Subject: [PATCH] Initial commit --- README.md | 31 ++++++++++++++++++++++ action.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 README.md create mode 100644 action.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ad6c3b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# PlatformIO Run + +GitHub Action for PlatformIO Run. + +## Usage + +`.github/workflows/platformio-build.yml` + +```yml +name: PlatformIO + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: PlatformIO Run + - uses: karniv00l/platformio-run-action@0.1.0 + with: + environments: "teensy35,teensy36,teensy41" + targets: "teensy35,teensy36,teensy41" + project-dir: "./some_dir" + project-conf: "./some_dir/custom.ini" + jobs: 6 + silent: false + verbose: true + disable-auto-clean: false +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..635e3f8 --- /dev/null +++ b/action.yml @@ -0,0 +1,78 @@ +name: PlatformIO Run +description: Run project targets over environments declared in platformio.ini +author: Piotr Rogowski +branding: + icon: cpu + color: orange +inputs: + environments: + description: Process specified environments (comma separated). + required: false + targets: + description: Process specified targets (comma separated). + required: false + project-dir: + description: Specify the path to project directory. By default, project-dir is equal to current working directory (CWD). + required: false + project-conf: + description: Process project with a custom platformio.ini + required: false + jobs: + description: Control a number of parallel build jobs. Default is a number of CPUs in a system. + required: false + silent: + description: Suppress progress reporting. + required: false + verbose: + description: Shows detailed information when processing environments. + required: false + disable-auto-clean: + description: Disable auto-clean of build_dir when platformio.ini or src_dir (project structure) have been modified. + required: false + +runs: + using: composite + steps: + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Cache PlatformIO + uses: actions/cache@v2 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + - name: Set up Python + uses: actions/setup-python@v2 + - name: Install PlatformIO + shell: bash + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + - name: Run PlatformIO + shell: bash + run: | + environments=${{ inputs.environments }} + targets=${{ inputs.targets }} + project_dir=${{ inputs.project-dir }} + project_conf=${{ inputs.project-conf }} + jobs=${{ inputs.jobs }} + silent=${{ inputs.silent }} + verbose=${{ inputs.verbose }} + disable_auto_clean=${{ inputs.disable-auto-clean }} + + args=() + + if [ -n "$environments" ]; then args+=("--environment ${environments//,/ -e }"); fi + if [ -n "$targets" ]; then args+=("--target ${targets//,/ -t }"); fi + if [ -n "$project_dir" ]; then args+=("--project-dir $project_dir"); fi + if [ -n "$project_conf" ]; then args+=("--project-conf $project_conf"); fi + if [ -n "$jobs" ]; then args+=("--jobs $jobs"); fi + if [ -n "$silent" ]; then args+=("--silent"); fi + if [ -n "$verbose" ]; then args+=("--verbose"); fi + if [ -n "$disable_auto_clean" ]; then args+=("--disable-auto-clean"); fi + + echo $args | xargs pio run