2021-07-24 16:53:02 +03:00
|
|
|
name: 'Build'
|
|
|
|
|
2021-12-24 22:35:25 +03:00
|
|
|
on:
|
2021-08-17 17:45:23 +03:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- dev
|
|
|
|
tags:
|
2021-08-19 12:56:42 +03:00
|
|
|
- '*'
|
2021-08-17 17:45:23 +03:00
|
|
|
pull_request:
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
env:
|
2023-06-08 09:16:01 +03:00
|
|
|
TARGETS: f7 f18
|
2021-10-12 18:30:55 +03:00
|
|
|
DEFAULT_TARGET: f7
|
2022-12-19 16:07:23 +03:00
|
|
|
FBT_TOOLCHAIN_PATH: /runner/_work
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
jobs:
|
2021-12-24 22:35:25 +03:00
|
|
|
main:
|
2022-08-02 17:05:31 +03:00
|
|
|
runs-on: [self-hosted,FlipperZeroShell]
|
2021-07-24 16:53:02 +03:00
|
|
|
steps:
|
2023-03-22 14:26:40 +03:00
|
|
|
- name: 'Wipe workspace'
|
2023-04-28 17:25:20 +03:00
|
|
|
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 16:10:51 +03:00
|
|
|
uses: actions/checkout@v3
|
2021-07-24 16:53:02 +03:00
|
|
|
with:
|
2023-03-15 18:24:56 +03:00
|
|
|
fetch-depth: 1
|
2021-08-26 20:59:23 +03:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2021-07-24 16:53:02 +03:00
|
|
|
|
2022-09-03 10:09:03 +03:00
|
|
|
- name: 'Get commit details'
|
2022-12-10 16:10:51 +03:00
|
|
|
id: names
|
2021-08-20 20:31:07 +03:00
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2021-08-20 20:31:07 +03:00
|
|
|
else
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="other"
|
2021-08-20 20:31:07 +03:00
|
|
|
fi
|
2023-04-06 12:06:19 +03:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" || cat "${{ github.event_path }}"
|
2022-12-26 23:22:22 +03:00
|
|
|
echo random_hash=$(openssl rand -base64 40 | shasum -a 256 | awk '{print $1}') >> $GITHUB_OUTPUT
|
|
|
|
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-03-05 08:17:33 +03:00
|
|
|
- name: 'Check API versions'
|
|
|
|
run: |
|
|
|
|
set -e
|
|
|
|
N_API_HEADER_SIGNATURES=`ls -1 firmware/targets/f*/api_symbols.csv | xargs -I {} sh -c "head -n2 {} | md5sum" | sort -u | wc -l`
|
|
|
|
if [ $N_API_HEADER_SIGNATURES != 1 ] ; then
|
|
|
|
echo API versions aren\'t matching for available targets. Please update!
|
|
|
|
head -n2 firmware/targets/f*/api_symbols.csv
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-12-26 23:22:22 +03:00
|
|
|
- name: 'Make artifacts directory'
|
|
|
|
run: |
|
2023-06-08 15:43:05 +03:00
|
|
|
rm -rf artifacts map_analyser_files
|
|
|
|
mkdir artifacts map_analyser_files
|
2022-04-13 23:50:25 +03:00
|
|
|
|
2021-12-01 13:21:26 +03:00
|
|
|
- name: 'Bundle scripts'
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
run: |
|
2023-05-09 02:31:44 +03:00
|
|
|
tar czpf artifacts/flipper-z-any-scripts-${SUFFIX}.tgz scripts
|
2021-12-01 13:21:26 +03:00
|
|
|
|
2022-08-02 17:05:31 +03:00
|
|
|
- name: 'Build the firmware'
|
|
|
|
run: |
|
|
|
|
set -e
|
2022-09-03 10:09:03 +03:00
|
|
|
for TARGET in ${TARGETS}; do
|
2023-06-08 15:43:05 +03:00
|
|
|
TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \
|
|
|
|
./fbt TARGET_HW=$TARGET_HW copro_dist updater_package \
|
|
|
|
${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
|
2022-08-02 17:05:31 +03:00
|
|
|
mv dist/${TARGET}-*/* artifacts/
|
2023-06-08 15:43:05 +03:00
|
|
|
tar czpf "artifacts/flipper-z-${TARGET}-resources-${SUFFIX}.tgz" \
|
|
|
|
-C assets resources
|
|
|
|
./fbt TARGET_HW=$TARGET_HW fap_dist
|
|
|
|
tar czpf "artifacts/flipper-z-${TARGET}-debugapps-${SUFFIX}.tgz" \
|
|
|
|
-C dist/${TARGET}-*/apps/Debug .
|
2022-08-02 17:05:31 +03:00
|
|
|
done
|
2021-07-24 16:53:02 +03:00
|
|
|
|
2022-08-24 18:14:27 +03:00
|
|
|
- name: "Check for uncommitted changes"
|
2022-08-02 16:29:16 +03:00
|
|
|
run: |
|
|
|
|
git diff --exit-code
|
|
|
|
|
2021-08-17 12:41:08 +03:00
|
|
|
- name: 'Bundle core2 firmware'
|
2021-08-17 19:46:12 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-02 17:05:31 +03:00
|
|
|
run: |
|
2022-10-12 19:12:05 +03:00
|
|
|
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
|
2021-08-17 12:41:08 +03:00
|
|
|
|
2022-12-26 23:22:22 +03:00
|
|
|
- name: 'Copy map analyser files'
|
2022-12-27 10:35:57 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-23 14:29:26 +03:00
|
|
|
run: |
|
2023-06-08 09:16:01 +03:00
|
|
|
cp build/${DEFAULT_TARGET}-firmware-*/firmware.elf.map map_analyser_files/firmware.elf.map
|
|
|
|
cp build/${DEFAULT_TARGET}-firmware-*/firmware.elf map_analyser_files/firmware.elf
|
2022-12-26 23:22:22 +03:00
|
|
|
cp ${{ github.event_path }} map_analyser_files/event.json
|
|
|
|
|
2023-06-05 13:25:43 +03:00
|
|
|
- name: 'Analyse map file'
|
2022-12-27 10:35:57 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2023-06-05 13:25:43 +03:00
|
|
|
run: |
|
|
|
|
source scripts/toolchain/fbtenv.sh
|
|
|
|
get_size()
|
|
|
|
{
|
|
|
|
SECTION="$1";
|
|
|
|
arm-none-eabi-size \
|
|
|
|
-A map_analyser_files/firmware.elf \
|
|
|
|
| grep "^$SECTION" | awk '{print $2}'
|
|
|
|
}
|
|
|
|
export BSS_SIZE="$(get_size ".bss")"
|
|
|
|
export TEXT_SIZE="$(get_size ".text")"
|
|
|
|
export RODATA_SIZE="$(get_size ".rodata")"
|
|
|
|
export DATA_SIZE="$(get_size ".data")"
|
|
|
|
export FREE_FLASH_SIZE="$(get_size ".free_flash")"
|
|
|
|
python3 -m pip install mariadb==1.1.6 cxxfilt==0.3.0
|
|
|
|
python3 scripts/map_parser.py map_analyser_files/firmware.elf.map map_analyser_files/firmware.elf.map.all
|
|
|
|
python3 scripts/map_mariadb_insert.py \
|
|
|
|
${{ secrets.AMAP_MARIADB_USER }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_PASSWORD }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_HOST }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_PORT }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_DATABASE }} \
|
|
|
|
map_analyser_files/firmware.elf.map.all
|
2022-12-26 23:22:22 +03:00
|
|
|
|
2021-07-24 16:53:02 +03:00
|
|
|
- name: 'Upload artifacts to update server'
|
2021-08-17 19:46:12 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-02 17:05:31 +03:00
|
|
|
run: |
|
2023-05-19 12:32:30 +03:00
|
|
|
FILES=$(for CUR in $(ls artifacts/); do echo "-F files=@artifacts/$CUR"; done)
|
|
|
|
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
|
|
|
-F "branch=${BRANCH_NAME}" \
|
|
|
|
${FILES[@]} \
|
|
|
|
"${{ secrets.INDEXER_URL }}"/firmware/uploadfiles
|
2021-07-24 16:53:02 +03:00
|
|
|
|
2021-09-10 15:05:09 +03:00
|
|
|
- name: 'Find Previous Comment'
|
2021-08-26 20:59:23 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
|
2023-04-19 14:08:13 +03:00
|
|
|
uses: peter-evans/find-comment@v2
|
2021-08-26 20:59:23 +03:00
|
|
|
id: fc
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-author: 'github-actions[bot]'
|
2022-07-03 18:01:24 +03:00
|
|
|
body-includes: 'Compiled firmware for commit'
|
2021-08-26 20:59:23 +03:00
|
|
|
|
2021-09-10 15:05:09 +03:00
|
|
|
- name: 'Create or update comment'
|
2021-08-26 20:59:23 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
|
2023-04-19 14:08:13 +03:00
|
|
|
uses: peter-evans/create-or-update-comment@v3
|
2021-08-26 20:59:23 +03:00
|
|
|
with:
|
|
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
2022-09-03 10:09:03 +03:00
|
|
|
**Compiled firmware for commit `${{steps.names.outputs.commit_sha}}`:**
|
|
|
|
- [📦 Update package](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
|
|
|
|
- [📥 DFU file](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-full-${{steps.names.outputs.suffix}}.dfu)
|
2022-10-26 01:48:33 +03:00
|
|
|
- [☁️ Web/App updater](https://lab.flipper.net/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
|
2021-08-26 20:59:23 +03:00
|
|
|
edit-mode: replace
|
2022-01-03 00:39:56 +03:00
|
|
|
|
2021-12-24 22:35:25 +03:00
|
|
|
compact:
|
|
|
|
if: ${{ !startsWith(github.ref, 'refs/tags') }}
|
2022-08-02 17:05:31 +03:00
|
|
|
runs-on: [self-hosted,FlipperZeroShell]
|
2023-04-19 14:08:13 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
target: [f7, f18]
|
2021-12-24 22:35:25 +03:00
|
|
|
steps:
|
2023-03-22 14:26:40 +03:00
|
|
|
- name: 'Wipe workspace'
|
2023-04-28 17:25:20 +03:00
|
|
|
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
|
2021-12-24 22:35:25 +03:00
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 16:10:51 +03:00
|
|
|
uses: actions/checkout@v3
|
2021-12-24 22:35:25 +03:00
|
|
|
with:
|
2023-03-15 18:24:56 +03:00
|
|
|
fetch-depth: 1
|
|
|
|
submodules: false
|
2021-12-24 22:35:25 +03:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
|
2022-09-03 10:09:03 +03:00
|
|
|
- name: 'Get commit details'
|
2021-12-24 22:35:25 +03:00
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2021-12-24 22:35:25 +03:00
|
|
|
else
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="other"
|
2021-12-24 22:35:25 +03:00
|
|
|
fi
|
2023-04-06 12:06:19 +03:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" || cat "${{ github.event_path }}"
|
2021-12-24 22:35:25 +03:00
|
|
|
|
2022-08-02 17:05:31 +03:00
|
|
|
- name: 'Build the firmware'
|
2023-04-19 14:08:13 +03:00
|
|
|
id: build-fw
|
2022-08-02 17:05:31 +03:00
|
|
|
run: |
|
|
|
|
set -e
|
2023-04-19 14:08:13 +03:00
|
|
|
TARGET="$(echo '${{ matrix.target }}' | sed 's/f//')"; \
|
|
|
|
./fbt TARGET_HW=$TARGET DEBUG=0 COMPACT=1 fap_dist updater_package
|
|
|
|
echo "sdk-file=$(ls dist/${{ matrix.target }}-*/flipper-z-${{ matrix.target }}-sdk-*.zip)" >> $GITHUB_OUTPUT
|
2023-05-03 08:48:49 +03:00
|
|
|
echo "hw-target-code=$TARGET" >> $GITHUB_OUTPUT
|
2023-04-19 14:08:13 +03:00
|
|
|
|
|
|
|
- name: Deploy uFBT with SDK
|
|
|
|
uses: flipperdevices/flipperzero-ufbt-action@v0.1.0
|
|
|
|
with:
|
|
|
|
task: setup
|
|
|
|
sdk-file: ${{ steps.build-fw.outputs.sdk-file }}
|
2023-05-03 08:48:49 +03:00
|
|
|
sdk-hw-target: ${{ steps.build-fw.outputs.hw-target-code }}
|
2023-04-19 14:08:13 +03:00
|
|
|
|
|
|
|
- name: Build test app with SDK
|
|
|
|
run: |
|
|
|
|
mkdir testapp
|
|
|
|
cd testapp
|
|
|
|
ufbt create APPID=testapp
|
|
|
|
ufbt
|
2023-04-28 17:25:20 +03:00
|
|
|
|
2023-04-19 14:08:13 +03:00
|
|
|
- name: Build example & external apps with uFBT
|
|
|
|
run: |
|
|
|
|
for appdir in 'applications/external' 'applications/examples'; do
|
|
|
|
for app in $(find "$appdir" -maxdepth 1 -mindepth 1 -type d); do
|
|
|
|
pushd $app
|
|
|
|
TARGETS_FAM=$(grep "targets" application.fam || echo "${{ matrix.target }}")
|
|
|
|
if ! grep -q "${{ matrix.target }}" <<< $TARGETS_FAM ; then
|
|
|
|
echo Skipping unsupported app: $app
|
|
|
|
popd
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo Building $app
|
|
|
|
ufbt
|
|
|
|
popd
|
|
|
|
done
|
2022-08-02 17:05:31 +03:00
|
|
|
done
|
2023-04-19 14:08:13 +03:00
|
|
|
|