Amap workflow, "toolchain improvements" (#1685)
* fix quotes in amap * try to fix quotes * try to read "commit_message" * Add new actions anv parser * fix amap_anayse * fix script ssl error * test build with new get commit details method * fix build.yml * add fbt envs to get_env.py * fix envs * using new commit info "way" * try to fix report link in PR page * fix "pvs_studio.yml" again * fix vars * fix "build.yml" Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
a3932cfa6d
commit
53aa5c71a0
57
.github/workflows/amap_analyse.yml
vendored
57
.github/workflows/amap_analyse.yml
vendored
@ -35,8 +35,7 @@ jobs:
|
|||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]; then
|
if [ -d .git ]; then
|
||||||
git submodule status \
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
@ -45,44 +44,14 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: 'Escape pull request title'
|
- name: 'Get commit details'
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
run: |
|
run: |
|
||||||
import json
|
FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
|
||||||
import os
|
|
||||||
import shlex
|
|
||||||
with open('${{ github.event_path }}') as fh:
|
|
||||||
event = json.load(fh)
|
|
||||||
escaped = shlex.quote(event['pull_request']['title'])
|
|
||||||
with open(os.environ['GITHUB_ENV'], 'a') as fh:
|
|
||||||
print(f'PULL_NAME={escaped}', file=fh)
|
|
||||||
shell: python3 {0}
|
|
||||||
|
|
||||||
- name: 'Generate prefixes by commit'
|
|
||||||
id: names
|
|
||||||
run: |
|
|
||||||
REF="${{github.ref}}"
|
|
||||||
COMMIT_HASH="$(git rev-parse HEAD)"
|
|
||||||
SHA="$(git rev-parse --short HEAD)"
|
|
||||||
COMMIT_MSG="${{github.event.head_commit.message}}"
|
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
||||||
REF="${{github.head_ref}}"
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--is_pull"
|
||||||
COMMIT_HASH="$(git log -1 --pretty=oneline | awk '{print $1}')"
|
else
|
||||||
SHA="$(cut -c -8 <<< "$COMMIT_HASH")"
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}"
|
||||||
COMMIT_MSG="$(git log -1 --pretty=format:"%s")"
|
|
||||||
PULL_ID="${{github.event.pull_request.number}}"
|
|
||||||
fi
|
fi
|
||||||
BRANCH_NAME=${REF#refs/*/}
|
|
||||||
SUFFIX=${BRANCH_NAME//\//_}-$(date +'%d%m%Y')-${SHA}
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
||||||
SUFFIX=${BRANCH_NAME//\//_}
|
|
||||||
fi
|
|
||||||
echo "::set-output name=commit-hash::${COMMIT_HASH}"
|
|
||||||
echo "::set-output name=commit-msg::${COMMIT_MSG}"
|
|
||||||
echo "::set-output name=pull-id::${PULL_ID}"
|
|
||||||
echo "::set-output name=pull-name::${PULL_NAME}"
|
|
||||||
echo "::set-output name=branch-name::${BRANCH_NAME}"
|
|
||||||
echo "::set-output name=suffix::${SUFFIX}"
|
|
||||||
|
|
||||||
- name: 'Make artifacts directory'
|
- name: 'Make artifacts directory'
|
||||||
run: |
|
run: |
|
||||||
@ -95,13 +64,13 @@ jobs:
|
|||||||
chmod 600 ./deploy_key;
|
chmod 600 ./deploy_key;
|
||||||
rsync -avzP \
|
rsync -avzP \
|
||||||
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
||||||
${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${{steps.names.outputs.branch-name}}/" artifacts/;
|
${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/" artifacts/;
|
||||||
rm ./deploy_key;
|
rm ./deploy_key;
|
||||||
|
|
||||||
- name: 'Make .map file analyze'
|
- name: 'Make .map file analyze'
|
||||||
run: |
|
run: |
|
||||||
cd artifacts/
|
cd artifacts/
|
||||||
/Applications/amap/Contents/MacOS/amap -f flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map
|
/Applications/amap/Contents/MacOS/amap -f "flipper-z-f7-firmware-${SUFFIX}.elf.map"
|
||||||
|
|
||||||
- name: 'Upload report to DB'
|
- name: 'Upload report to DB'
|
||||||
run: |
|
run: |
|
||||||
@ -110,20 +79,14 @@ jobs:
|
|||||||
{
|
{
|
||||||
SECTION="$1";
|
SECTION="$1";
|
||||||
arm-none-eabi-size \
|
arm-none-eabi-size \
|
||||||
-A artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf \
|
-A artifacts/flipper-z-f7-firmware-$SUFFIX.elf \
|
||||||
| grep "^$SECTION" | awk '{print $2}'
|
| grep "^$SECTION" | awk '{print $2}'
|
||||||
}
|
}
|
||||||
export COMMIT_HASH="${{steps.names.outputs.commit-hash}}"
|
|
||||||
export COMMIT_MSG="${{steps.names.outputs.commit-msg}}"
|
|
||||||
export BRANCH_NAME="${{steps.names.outputs.branch-name}}"
|
|
||||||
export BSS_SIZE="$(get_size ".bss")"
|
export BSS_SIZE="$(get_size ".bss")"
|
||||||
export TEXT_SIZE="$(get_size ".text")"
|
export TEXT_SIZE="$(get_size ".text")"
|
||||||
export RODATA_SIZE="$(get_size ".rodata")"
|
export RODATA_SIZE="$(get_size ".rodata")"
|
||||||
export DATA_SIZE="$(get_size ".data")"
|
export DATA_SIZE="$(get_size ".data")"
|
||||||
export FREE_FLASH_SIZE="$(get_size ".free_flash")"
|
export FREE_FLASH_SIZE="$(get_size ".free_flash")"
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
|
||||||
export PULL_ID="${{steps.names.outputs.pull-id}}"
|
|
||||||
fi
|
|
||||||
python3 -m pip install mariadb
|
python3 -m pip install mariadb
|
||||||
python3 scripts/amap_mariadb_insert.py \
|
python3 scripts/amap_mariadb_insert.py \
|
||||||
${{ secrets.AMAP_MARIADB_USER }} \
|
${{ secrets.AMAP_MARIADB_USER }} \
|
||||||
@ -131,4 +94,4 @@ jobs:
|
|||||||
${{ secrets.AMAP_MARIADB_HOST }} \
|
${{ secrets.AMAP_MARIADB_HOST }} \
|
||||||
${{ secrets.AMAP_MARIADB_PORT }} \
|
${{ secrets.AMAP_MARIADB_PORT }} \
|
||||||
${{ secrets.AMAP_MARIADB_DATABASE }} \
|
${{ secrets.AMAP_MARIADB_DATABASE }} \
|
||||||
artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map.all
|
artifacts/flipper-z-f7-firmware-$SUFFIX.elf.map.all
|
||||||
|
104
.github/workflows/build.yml
vendored
104
.github/workflows/build.yml
vendored
@ -19,10 +19,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]
|
if [ -d .git ]; then
|
||||||
then
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
git submodule status \
|
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
@ -33,51 +31,44 @@ jobs:
|
|||||||
|
|
||||||
- name: 'Make artifacts directory'
|
- name: 'Make artifacts directory'
|
||||||
run: |
|
run: |
|
||||||
test -d artifacts && rm -rf artifacts || true
|
rm -rf artifacts
|
||||||
mkdir artifacts
|
mkdir artifacts
|
||||||
|
|
||||||
- name: 'Generate suffix and folder name'
|
- name: 'Get commit details'
|
||||||
|
run: |
|
||||||
|
FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
|
||||||
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
||||||
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--is_pull"
|
||||||
|
else
|
||||||
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 'Generate suffixes for comment'
|
||||||
id: names
|
id: names
|
||||||
run: |
|
run: |
|
||||||
REF=${{ github.ref }}
|
echo "::set-output name=branch_name::${BRANCH_NAME}"
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
echo "::set-output name=commit_sha::${COMMIT_SHA}"
|
||||||
REF=${{ github.head_ref }}
|
echo "::set-output name=default_target::${DEFAULT_TARGET}"
|
||||||
fi
|
|
||||||
BRANCH_OR_TAG=${REF#refs/*/}
|
|
||||||
SHA=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}
|
|
||||||
else
|
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}-$(date +'%d%m%Y')-${SHA}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
|
|
||||||
echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
|
|
||||||
echo "::set-output name=artifacts-path::${BRANCH_OR_TAG}"
|
|
||||||
echo "::set-output name=suffix::${SUFFIX}"
|
echo "::set-output name=suffix::${SUFFIX}"
|
||||||
echo "::set-output name=short-hash::${SHA}"
|
|
||||||
echo "::set-output name=default-target::${DEFAULT_TARGET}"
|
|
||||||
|
|
||||||
- name: 'Bundle scripts'
|
- name: 'Bundle scripts'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
tar czpf artifacts/flipper-z-any-scripts-${{steps.names.outputs.suffix}}.tgz scripts
|
tar czpf artifacts/flipper-z-any-scripts-${SUFFIX}.tgz scripts
|
||||||
|
|
||||||
- name: 'Build the firmware'
|
- name: 'Build the firmware'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}; do
|
||||||
do
|
FBT_TOOLCHAIN_PATH=/opt ./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
|
||||||
FBT_TOOLCHAIN_PATH=/opt ./fbt TARGET_HW=`echo ${TARGET} | sed 's/f//'` updater_package ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
|
updater_package ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: 'Move upload files'
|
- name: 'Move upload files'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}; do
|
||||||
do
|
|
||||||
mv dist/${TARGET}-*/* artifacts/
|
mv dist/${TARGET}-*/* artifacts/
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -85,12 +76,11 @@ jobs:
|
|||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
for UPDATEBUNDLE in artifacts/*/
|
for UPDATEBUNDLE in artifacts/*/; do
|
||||||
do
|
BUNDLE_NAME="$(echo "$UPDATEBUNDLE" | cut -d'/' -f2)"
|
||||||
BUNDLE_NAME=`echo $UPDATEBUNDLE | cut -d'/' -f2`
|
echo Packaging "${BUNDLE_NAME}"
|
||||||
echo Packaging ${BUNDLE_NAME}
|
tar czpf "artifacts/flipper-z-${BUNDLE_NAME}.tgz" -C artifacts "${BUNDLE_NAME}"
|
||||||
tar czpf artifacts/flipper-z-${BUNDLE_NAME}.tgz -C artifacts ${BUNDLE_NAME}
|
rm -rf "artifacts/${BUNDLE_NAME}"
|
||||||
rm -rf artifacts/${BUNDLE_NAME}
|
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: "Check for uncommitted changes"
|
- name: "Check for uncommitted changes"
|
||||||
@ -100,17 +90,17 @@ jobs:
|
|||||||
- name: 'Bundle resources'
|
- name: 'Bundle resources'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
tar czpf artifacts/flipper-z-any-resources-${{steps.names.outputs.suffix}}.tgz -C assets resources
|
tar czpf "artifacts/flipper-z-any-resources-${SUFFIX}.tgz" -C assets resources
|
||||||
|
|
||||||
- name: 'Bundle core2 firmware'
|
- name: 'Bundle core2 firmware'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
FBT_TOOLCHAIN_PATH=/opt ./fbt copro_dist
|
FBT_TOOLCHAIN_PATH=/opt ./fbt copro_dist
|
||||||
tar czpf artifacts/flipper-z-any-core2_firmware-${{steps.names.outputs.suffix}}.tgz -C assets core2_firmware
|
tar czpf "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz" -C assets core2_firmware
|
||||||
|
|
||||||
- name: 'Copy .map file'
|
- name: 'Copy .map file'
|
||||||
run: |
|
run: |
|
||||||
cp build/f7-firmware-*/firmware.elf.map artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map
|
cp build/f7-firmware-*/firmware.elf.map "artifacts/flipper-z-f7-firmware-${SUFFIX}.elf.map"
|
||||||
|
|
||||||
- name: 'Upload artifacts to update server'
|
- name: 'Upload artifacts to update server'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
@ -119,7 +109,7 @@ jobs:
|
|||||||
chmod 600 ./deploy_key;
|
chmod 600 ./deploy_key;
|
||||||
rsync -avzP --delete --mkpath \
|
rsync -avzP --delete --mkpath \
|
||||||
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
||||||
artifacts/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${{steps.names.outputs.artifacts-path}}/";
|
artifacts/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/";
|
||||||
rm ./deploy_key;
|
rm ./deploy_key;
|
||||||
|
|
||||||
- name: 'Trigger update server reindex'
|
- name: 'Trigger update server reindex'
|
||||||
@ -142,10 +132,10 @@ jobs:
|
|||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
body: |
|
body: |
|
||||||
**Compiled firmware for commit `${{steps.names.outputs.short-hash}}`:**
|
**Compiled firmware for commit `${{steps.names.outputs.commit_sha}}`:**
|
||||||
- [📦 Update package](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-update-${{steps.names.outputs.suffix}}.tgz)
|
- [📦 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.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-full-${{steps.names.outputs.suffix}}.dfu)
|
- [📥 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)
|
||||||
- [☁️ Web updater](https://my.flipp.dev/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.artifacts-path}}&version=${{steps.names.outputs.short-hash}})
|
- [☁️ Web updater](https://my.flipp.dev/?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}})
|
||||||
edit-mode: replace
|
edit-mode: replace
|
||||||
|
|
||||||
compact:
|
compact:
|
||||||
@ -157,7 +147,7 @@ jobs:
|
|||||||
if [ -d .git ]
|
if [ -d .git ]
|
||||||
then
|
then
|
||||||
git submodule status \
|
git submodule status \
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|| git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
@ -167,29 +157,21 @@ jobs:
|
|||||||
submodules: true
|
submodules: true
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: 'Generate suffix and folder name'
|
- name: 'Get commit details'
|
||||||
id: names
|
|
||||||
run: |
|
run: |
|
||||||
REF=${{ github.ref }}
|
FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
||||||
REF=${{ github.head_ref }}
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--is_pull"
|
||||||
fi
|
|
||||||
BRANCH_OR_TAG=${REF#refs/*/}
|
|
||||||
SHA=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}
|
|
||||||
else
|
else
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}-$(date +'%d%m%Y')-${SHA}
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}"
|
||||||
fi
|
fi
|
||||||
|
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_NAME}" >> $GITHUB_ENV
|
||||||
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
|
|
||||||
echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
|
echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: 'Build the firmware'
|
- name: 'Build the firmware'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}; do
|
||||||
do
|
FBT_TOOLCHAIN_PATH=/opt ./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
|
||||||
FBT_TOOLCHAIN_PATH=/opt ./fbt TARGET_HW=`echo ${TARGET} | sed 's/f//'` updater_package DEBUG=0 COMPACT=1
|
updater_package DEBUG=0 COMPACT=1
|
||||||
done
|
done
|
||||||
|
6
.github/workflows/check_submodules.yml
vendored
6
.github/workflows/check_submodules.yml
vendored
@ -15,10 +15,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]
|
if [ -d .git ]; then
|
||||||
then
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
git submodule status \
|
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
|
6
.github/workflows/lint_c.yml
vendored
6
.github/workflows/lint_c.yml
vendored
@ -18,10 +18,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]
|
if [ -d .git ]; then
|
||||||
then
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
git submodule status \
|
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
|
6
.github/workflows/lint_python.yml
vendored
6
.github/workflows/lint_python.yml
vendored
@ -15,10 +15,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]
|
if [ -d .git ]; then
|
||||||
then
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
git submodule status \
|
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
|
47
.github/workflows/pvs_studio.yml
vendored
47
.github/workflows/pvs_studio.yml
vendored
@ -20,10 +20,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 'Decontaminate previous build leftovers'
|
- name: 'Decontaminate previous build leftovers'
|
||||||
run: |
|
run: |
|
||||||
if [ -d .git ]
|
if [ -d .git ]; then
|
||||||
then
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
||||||
git submodule status \
|
|
||||||
|| git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Checkout code'
|
- name: 'Checkout code'
|
||||||
@ -32,28 +30,23 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: 'Generate suffix and folder name'
|
- name: 'Get commit details'
|
||||||
|
run: |
|
||||||
|
FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
|
||||||
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
||||||
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--is_pull"
|
||||||
|
else
|
||||||
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 'Generate suffixes for comment'
|
||||||
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
|
||||||
id: names
|
id: names
|
||||||
run: |
|
run: |
|
||||||
REF=${{ github.ref }}
|
echo "::set-output name=branch_name::${BRANCH_NAME}"
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
echo "::set-output name=commit_sha::${COMMIT_SHA}"
|
||||||
REF=${{ github.head_ref }}
|
echo "::set-output name=default_target::${DEFAULT_TARGET}"
|
||||||
fi
|
|
||||||
BRANCH_OR_TAG=${REF#refs/*/}
|
|
||||||
SHA=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}
|
|
||||||
else
|
|
||||||
SUFFIX=${BRANCH_OR_TAG//\//_}-$(date +'%d%m%Y')-${SHA}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
|
|
||||||
echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV
|
|
||||||
echo "::set-output name=artifacts-path::${BRANCH_OR_TAG}"
|
|
||||||
echo "::set-output name=suffix::${SUFFIX}"
|
echo "::set-output name=suffix::${SUFFIX}"
|
||||||
echo "::set-output name=short-hash::${SHA}"
|
|
||||||
echo "::set-output name=default-target::${DEFAULT_TARGET}"
|
|
||||||
|
|
||||||
- name: 'Make reports directory'
|
- name: 'Make reports directory'
|
||||||
run: |
|
run: |
|
||||||
@ -75,7 +68,7 @@ jobs:
|
|||||||
-o PVS-Studio.log
|
-o PVS-Studio.log
|
||||||
|
|
||||||
- name: 'Convert PVS-Studio output to html page'
|
- name: 'Convert PVS-Studio output to html page'
|
||||||
run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${{steps.names.outputs.default-target}}-${{steps.names.outputs.suffix}}
|
run: plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o reports/${DEFAULT_TARGET}-${SUFFIX}
|
||||||
|
|
||||||
- name: 'Upload artifacts to update server'
|
- name: 'Upload artifacts to update server'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
@ -84,7 +77,7 @@ jobs:
|
|||||||
chmod 600 ./deploy_key;
|
chmod 600 ./deploy_key;
|
||||||
rsync -avrzP --mkpath \
|
rsync -avrzP --mkpath \
|
||||||
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
||||||
reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${{steps.names.outputs.artifacts-path}}/";
|
reports/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/";
|
||||||
rm ./deploy_key;
|
rm ./deploy_key;
|
||||||
|
|
||||||
- name: 'Find Previous Comment'
|
- name: 'Find Previous Comment'
|
||||||
@ -103,6 +96,6 @@ jobs:
|
|||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
body: |
|
body: |
|
||||||
**PVS-Studio report for commit `${{steps.names.outputs.short-hash}}`:**
|
**PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
|
||||||
- [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.artifacts-path}}/${{steps.names.outputs.default-target}}-${{steps.names.outputs.suffix}}/index.html)
|
- [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
|
||||||
edit-mode: replace
|
edit-mode: replace
|
||||||
|
87
scripts/get_env.py
Normal file
87
scripts/get_env.py
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import ssl
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import shlex
|
||||||
|
import re
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
# event_file = open('${{ github.event_path }}')
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--event_file", help="Current GitHub event file", required=True)
|
||||||
|
parser.add_argument(
|
||||||
|
"--is_pull", help="Is it Pull Request", default=False, action="store_true"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def get_commit_json(event):
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
with urllib.request.urlopen(
|
||||||
|
event["pull_request"]["_links"]["commits"]["href"], context=context
|
||||||
|
) as commit_file:
|
||||||
|
commit_json = json.loads(commit_file.read().decode("utf-8"))
|
||||||
|
return commit_json
|
||||||
|
|
||||||
|
|
||||||
|
def get_details(event, args):
|
||||||
|
data = {}
|
||||||
|
current_time = datetime.datetime.utcnow().date()
|
||||||
|
if args.is_pull:
|
||||||
|
commit_json = get_commit_json(event)
|
||||||
|
data["commit_comment"] = shlex.quote(commit_json[-1]["commit"]["message"])
|
||||||
|
data["commit_hash"] = commit_json[-1]["sha"]
|
||||||
|
ref = event["pull_request"]["head"]["ref"]
|
||||||
|
data["pull_id"] = event["pull_request"]["number"]
|
||||||
|
data["pull_name"] = shlex.quote(event["pull_request"]["title"])
|
||||||
|
else:
|
||||||
|
data["commit_comment"] = shlex.quote(event["commits"][-1]["message"])
|
||||||
|
data["commit_hash"] = event["commits"][-1]["id"]
|
||||||
|
ref = event["ref"]
|
||||||
|
data["commit_sha"] = data["commit_hash"][:8]
|
||||||
|
data["branch_name"] = re.sub("refs/\w+/", "", ref)
|
||||||
|
data["suffix"] = (
|
||||||
|
data["branch_name"].replace("/", "_")
|
||||||
|
+ "-"
|
||||||
|
+ current_time.strftime("%d%m%Y")
|
||||||
|
+ "-"
|
||||||
|
+ data["commit_sha"]
|
||||||
|
)
|
||||||
|
if ref.startswith("refs/tags/"):
|
||||||
|
data["suffix"] = data["branch_name"].replace("/", "_")
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def add_envs(data, env_file, args):
|
||||||
|
print(f'COMMIT_MSG={data["commit_comment"]}', file=env_file)
|
||||||
|
print(f'COMMIT_HASH={data["commit_hash"]}', file=env_file)
|
||||||
|
print(f'COMMIT_SHA={data["commit_sha"]}', file=env_file)
|
||||||
|
print(f'SUFFIX={data["suffix"]}', file=env_file)
|
||||||
|
print(f'BRANCH_NAME={data["branch_name"]}', file=env_file)
|
||||||
|
print(f'DIST_SUFFIX={data["suffix"]}', file=env_file)
|
||||||
|
print(f'WORKFLOW_BRANCH_OR_TAG={data["branch_name"]}', file=env_file)
|
||||||
|
if args.is_pull:
|
||||||
|
print(f'PULL_ID={data["pull_id"]}', file=env_file)
|
||||||
|
print(f'PULL_NAME={data["pull_name"]}', file=env_file)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
event_file = open(args.event_file)
|
||||||
|
event = json.load(event_file)
|
||||||
|
env_file = open(os.environ["GITHUB_ENV"], "a")
|
||||||
|
data = get_details(event, args)
|
||||||
|
add_envs(data, env_file, args)
|
||||||
|
event_file.close()
|
||||||
|
env_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -13,7 +13,7 @@ if not [%FBT_NOENV%] == [] (
|
|||||||
exit /b 0
|
exit /b 0
|
||||||
)
|
)
|
||||||
|
|
||||||
set "FLIPPER_TOOLCHAIN_VERSION=9"
|
set "FLIPPER_TOOLCHAIN_VERSION=12"
|
||||||
set "FBT_TOOLCHAIN_ROOT=%FBT_ROOT%\toolchain\i686-windows"
|
set "FBT_TOOLCHAIN_ROOT=%FBT_ROOT%\toolchain\i686-windows"
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# public variables
|
# public variables
|
||||||
DEFAULT_SCRIPT_PATH="$(pwd -P)";
|
DEFAULT_SCRIPT_PATH="$(pwd -P)";
|
||||||
SCRIPT_PATH="${SCRIPT_PATH:-$DEFAULT_SCRIPT_PATH}";
|
SCRIPT_PATH="${SCRIPT_PATH:-$DEFAULT_SCRIPT_PATH}";
|
||||||
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"8"}";
|
FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"12"}";
|
||||||
FBT_TOOLCHAIN_PATH="${FBT_TOOLCHAIN_PATH:-$SCRIPT_PATH}";
|
FBT_TOOLCHAIN_PATH="${FBT_TOOLCHAIN_PATH:-$SCRIPT_PATH}";
|
||||||
|
|
||||||
fbtenv_show_usage()
|
fbtenv_show_usage()
|
||||||
|
Loading…
Reference in New Issue
Block a user