Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
hedger committed Mar 6, 2024
2 parents 64bcd93 + 6237e46 commit e7cd349
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 33 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test_ufbt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests for ufbt action
name: Testsuite

on:
workflow_call:
Expand All @@ -22,10 +22,10 @@ on:
jobs:
test-ufbt-action:
runs-on: ubuntu-latest
name: Test ufbt action
name: Test action
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup ufbt
uses: ./ # Uses an action in the root directory
Expand All @@ -51,7 +51,7 @@ jobs:
app-dir: 'test'

- name: Upload app artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: fap-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
Expand Down Expand Up @@ -82,3 +82,7 @@ jobs:
- name: Fail if lint or build of broken app succeeded
if: steps.lint-broken-app.outcome == 'success' || steps.build-broken-app.outcome == 'success'
run: exit 1

- name: Fail if lint or build of broken app did not produce error output
if: steps.lint-broken-app.outputs.lint-messages == '' || steps.build-broken-app.outputs.build-errors == ''
run: exit 1
12 changes: 9 additions & 3 deletions .github/workflows/test_with_dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: Test ufbt action with dev SDK
name: Action tests

on:
[push, pull_request]
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:

jobs:
run-test-on-latest:
name: Test ufbt action with dev SDK
name: Using dev sdk
uses: ./.github/workflows/test_ufbt.yml
with:
ufbt-version: prerelease
Expand Down
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ jobs:
name: 'ufbt: Build for Dev branch'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build with ufbt
uses: flipperdevices/[email protected].0
uses: flipperdevices/[email protected]
id: build-app
with:
# Set to 'release' to build for latest published release version
sdk-channel: dev
- name: Upload app artifacts
uses: actions/upload-artifact@v3
with:
name: fap-${{ steps.build-app.outputs.suffix }}
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
# You can remove this step if you don't want to check source code formatting
- name: Lint sources
uses: flipperdevices/[email protected].0
uses: flipperdevices/[email protected]
with:
# skip SDK setup, we already did it in previous step
skip-setup: true
Expand All @@ -52,11 +52,19 @@ jobs:
### Advanced example: build for multiple SDK sources
This example will build your application for 3 different SDK sources: `dev` and `release` channels of official firmware, and for an SDK from an unofficial source. It will upload generated binaries to GitHub artifacts.
This example will build your application for 3 different SDK sources: `dev` and `release` channels of official firmware, and for an SDK from an unofficial source. It will upload generated binaries to GitHub artifacts. It will also do a build every day, even if there are no new commits in the repository, so you can be sure that your application is always up to date with the latest SDK.

```yaml
name: "FAP: Build for multiple SDK sources"
on: [push, pull_request]
on:
push:
## put your main branch name under "braches"
#branches:
# - master
pull_request:
schedule:
# do a build every day
- cron: "1 1 * * *"
jobs:
ufbt-build-action:
runs-on: ubuntu-latest
Expand All @@ -70,51 +78,53 @@ jobs:
- name: Unofficial firmware
# example URL, replace with a valid one
# you can also use other modes for specifying SDK sources
sdk-index-url: https://up.unofficialflip.com/directory.json
sdk-index-url: https://flipper.example.com/directory.json
sdk-channel: dev
name: 'ufbt: Build for ${{ matrix.name }}'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build with ufbt
uses: flipperdevices/[email protected].0
uses: flipperdevices/[email protected]
id: build-app
with:
sdk-channel: ${{ matrix.sdk-channel }}
sdk-index-url: ${{ matrix.sdk-index-url }}
- name: Upload app artifacts
uses: actions/upload-artifact@v3
with:
name: fap-${{ steps.build-app.outputs.suffix }}
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
```

## Inputs

All inputs are **optional**. If you don't specify any inputs, `ufbt` will build your application for the latest release version of official firmware. You can use [fap-artifacts](#fap-artifacts) output to get a list of built files to [upload them](https://github.com/marketplace/actions/upload-a-build-artifact).

#### `task`

**Optional** Task to run. Can be `setup`, `build` or `lint`. Default is `"build"`.
Task to run. Can be `setup`, `build` or `lint`. Default is `"build"`.

#### `app-dir`

**Optional** Path to application's source code. Default is `"."` - the root of the repository.
Path to application's source code. Default is `"."` the root of the repository.

#### `ufbt-version`

**Optional** Version of `ufbt` to use. Default is `"latest"` - the latest version available on PyPI. If set to `prerelease`, this action will fetch the latest [pre-release version](https://pypi.org/project/ufbt/#history). You can also use a PyPI version specifier, such as `">=0.2.1,<0.3.0"`.
Version of `ufbt` to use. Default is `"latest"` the latest version available on PyPI. If set to `prerelease`, this action will fetch the latest [pre-release version](https://pypi.org/project/ufbt/#history). You can also use a PyPI version specifier, such as `">=0.2.1,<0.3.0"`.

#### `ufbt-args`

**Optional** Additional arguments to pass to `ufbt`. Default is `-s` - which suppresses build system output, only leaving subcommands' outputs, such as compiler messages. Set to `""` for extra verbosity.
Additional arguments to pass to `ufbt`. Default is `-s` which suppresses build system output, only leaving subcommands' outputs, such as compiler messages. Set to `""` for extra verbosity.
Only handled when `task` is set to `build` or `lint`. See `ufbt` documentation for details.

#### `skip-setup`

**Optional** If set to `true`, skips SDK setup. Useful when running multiple action multiple times. Default is `false`.
If set to `true`, skips SDK setup. Useful when running multiple action multiple times. Default is `false`.

#### SDK source options

Table below describes options for SDK update. See ufbt documentation on available [SDK update modes](https://github.com/flipperdevices/flipperzero-ufbt/blob/dev/README.md#managing-the-sdk) for details. All these inputs are **optional**.
Table below describes options for SDK update. See ufbt documentation on available [SDK update modes](https://github.com/flipperdevices/flipperzero-ufbt/blob/dev/README.md#managing-the-sdk) for details.

| Input name | `ufbt update` argument | Description |
| --- | --- | --- |
Expand Down Expand Up @@ -147,6 +157,10 @@ A suffix to use in artifact names, includes hardware target, API and SDK version

A list of linter messages, in case of any formatting errors. Only available in `lint` mode.

#### `build-errors`

A list of build errors, in case of any. Only available in `build` mode.

#### `ufbt-status`

A string, JSON object with ufbt status. Contains `ufbt status --json` output. Useful for extracting information about ufbt's directories, configured modes, etc. Useful in combination with [fromJSON() function](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) to extract information from the output. For example, `${{ fromJSON(steps.<build>.ufbt-status).toolchain_dir }}`. Available in all modes.
Expand All @@ -157,4 +171,4 @@ A version of the toolchain used to build the application. Defined by current SDK

## Acknowledgements

First version of this action was created by [Oleksii Kutuzov](https://github.com/oleksiikutuzov) and is available [here](https://github.com/oleksiikutuzov/flipperzero-ufbt-action). However, it no longer works with the latest version of `ufbt`. This version is a complete rewrite, with problem matcher borrowed from original verison.
First version of this action was created by [Oleksii Kutuzov](https://github.com/oleksiikutuzov) and is available [here](https://github.com/oleksiikutuzov/flipperzero-ufbt-action). However, it no longer works with the latest version of `ufbt`. This version is a complete rewrite, with problem matcher borrowed from original verison.
23 changes: 14 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "Build Flipper Application Package (.fap)"

author: "@flipperdevices"
description: |
Provides a composite action to install `ufbt`, build and lint applications for Flipper Zero.
Expand Down Expand Up @@ -84,6 +85,10 @@ outputs:
description: Linter output. Set by lint task
value: ${{ steps.lint-app.outputs.lint-messages }}

build-errors:
description: Build errors. Set by build task
value: ${{ steps.build-fap.outputs.build-messages }}

ufbt-status:
description: JSON status object for ufbt. Use with fromJSON()
value: ${{ steps.ufbt-status.outputs.json }}
Expand All @@ -97,22 +102,22 @@ runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
if: inputs.skip-setup == 'false'
with:
python-version: '3.8'
python-version: '3.11'

- name: Install ufbt
if: inputs.skip-setup == 'false'
shell: bash
run: |
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
if [ "${{ inputs.ufbt-version }}" == "prerelease" ]; then
pip install --upgrade --pre ufbt
python3 -m pip install --upgrade --pre ufbt
elif [ "${{ inputs.ufbt-version }}" == "latest" ]; then
pip install --upgrade ufbt
python3 -m pip install --upgrade ufbt
else
pip install --upgrade ufbt${{ inputs.ufbt-version }}
python3 -m pip install --upgrade ufbt${{ inputs.ufbt-version }}
fi
- name: Update ufbt
Expand Down Expand Up @@ -153,7 +158,7 @@ runs:
echo "deployed-version=`cat ${{ fromJSON(steps.ufbt-status.outputs.json).toolchain_dir }}/*/VERSION 2>/dev/null || echo 0`" >> $GITHUB_OUTPUT
- name: Cache toolchain
uses: actions/cache@v3
uses: actions/cache@v4
if: steps.get-tooclhain-version.outputs.required-version != steps.get-tooclhain-version.outputs.deployed-version
with:
path: ${{ fromJSON(steps.ufbt-status.outputs.json).toolchain_dir }}
Expand All @@ -170,7 +175,7 @@ runs:
shell: bash
run: |
set +e
FAP_SRC_PATH=`realpath $GITHUB_WORKSPACE/${{ inputs.app-dir }}`
FAP_SRC_PATH=`realpath ${{ inputs.app-dir }}`
DIST_PATH=$FAP_SRC_PATH/dist
cd $FAP_SRC_PATH
BUILD_MESSAGES="$(ufbt ${{ inputs.ufbt-args }} 2>&1 | tee /dev/stderr)"
Expand Down Expand Up @@ -200,7 +205,7 @@ runs:
shell: bash
run: |
set +e
cd $GITHUB_WORKSPACE/${{ inputs.app-dir }}
cd ${{ inputs.app-dir }}
LINT_MESSAGES="$(ufbt lint ${{ inputs.ufbt-args }} 2>&1 | tee /dev/stderr)"
LINT_STATUS=${PIPESTATUS[0]}
if [ "$LINT_STATUS" -eq 0 ]; then
Expand Down

0 comments on commit e7cd349

Please sign in to comment.