unleashed-firmware/.github/workflows/lint_and_submodule_check.yml

120 lines
4.4 KiB
YAML
Raw Normal View History

name: 'Lint sources & check submodule integrity'
on:
pull_request:
env:
TARGETS: f7
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
lint_sources_check_submodules:
runs-on: [self-hosted, FlipperZeroShell]
steps:
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v4
with:
2023-08-25 17:38:41 +03:00
fetch-depth: 2
ref: ${{ github.sha }}
- name: 'Check protobuf branch'
run: |
[FL-3618] Infrared remote button index support (#3180) * Do not load all signals at once (Draft) * Minor cleanup * Refactor remote renaming * Improve function signatures * Rename infrared_remote functions * Optimise signal loading * Implement adding signals to remote * Add read_name() method * Deprecate a function * Partially implement deleting signals (draft) * Use m-array instead of m-list for signal name directory * Use plain C strings instead of furi_string * Implement deleting signals * Implement deleting signals via generalised callback * Implement renaming signals * Rename some types * Some more renaming * Remove unused type * Implement inserting signals (internal use) * Improve InfraredMoveView * Send an event to move a signal * Remove unused type * Implement moving signals * Implement creating new remotes with one signal * Un-deprecate and rename a function * Add InfraredRemote API docs * Add InfraredSignal API docs * Better error messages * Show progress pop-up when moving buttons in a remote * Copy labels to the InfraredMoveView to avoid pointer invalidation * Improve file selection scene * Show progress pop-up when renaming buttons in a remote * Refactor a scene * Show progress when deleting a button from remote * Use a random name for temp files * Add docs to infrared_brute_force.h * Rename Infrared type to InfraredApp * Add docs to infrared_app_i.h * Deliver event data via a callback * Bundle event data together with event type * Change DataExchange behaviour * Adapt RPC debug app to new API * Remove rogue output * Add Doxygen comments to rpc_app.h * Simplify rpc_app.c code * Remove superflous parameter * Do not allocate protobuf messages on the stack * Fix GetError response * Support for button indices * Comment out shallow submodules * Fix F18 api * Fix logical error and add more debug output * fbt: testing unshallow for protobuf * github: lint&checks: unshallow prior to checks * Fix a TODO * github: do not unshallow the unshallowed * fbt: assets: only attempt to unshallow if cannot describe * Do not use the name when loading a signal by index (duh) * Simplify loading infrared signals by name * Sync with protobuf release * Infrared: use compact furi_crash macros Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2023-11-10 10:22:34 +03:00
git submodule update --init;
SUB_PATH="assets/protobuf";
SUB_BRANCH="dev";
SUB_COMMITS_MIN=40;
cd "$SUB_PATH";
SUBMODULE_HASH="$(git rev-parse HEAD)";
BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
COMMITS_IN_BRANCH="$(git rev-list --count dev)";
if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
echo "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Too few commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
exit 1;
fi
if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
echo "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
exit 1;
fi
2023-08-25 17:38:41 +03:00
- name: 'Check for new TODOs'
id: check_todos
if: github.event_name == 'pull_request'
run: |
set +e;
git diff --unified=0 --no-color ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -E '^\+' | grep -i -E '(TODO|HACK|FIXME|XXX)[ :]' | grep -v -- '-nofl' > lines.log;
MISSING_TICKETS=$( grep -v -E 'FL-[0-9]+' lines.log );
2023-08-25 17:38:41 +03:00
if [ -n "$MISSING_TICKETS" ]; then
echo "Error: Missing ticket number in \`TODO\` comment(s)" >> $GITHUB_STEP_SUMMARY;
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY;
echo "$MISSING_TICKETS" >> $GITHUB_STEP_SUMMARY;
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY;
echo "Error: Missing issue number in comment(s):";
echo "$MISSING_TICKETS";
2023-08-25 17:38:41 +03:00
exit 1;
else
echo "No new TODOs without tickets found" >> $GITHUB_STEP_SUMMARY;
fi
- name: 'Check Python code formatting'
id: syntax_check_py
2023-08-25 17:38:41 +03:00
if: always()
run: |
set +e;
./fbt -s lint_py 2>&1 | tee lint-py.log;
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
# Save multiline output
echo "errors=1" >> $GITHUB_OUTPUT;
printf "Python Lint errors:\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
echo "$(cat lint-py.log)" >> $GITHUB_STEP_SUMMARY;
printf "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
exit 1;
else
echo "Python Lint: all good ✨" >> $GITHUB_STEP_SUMMARY;
fi
- name: 'Check C++ code formatting'
id: syntax_check_cpp
if: always()
run: |
set +e;
./fbt -s lint 2>&1 | tee lint-cpp.log;
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
# Save multiline output
echo "errors=1" >> $GITHUB_OUTPUT;
printf "C Lint errors:\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
echo "$(cat lint-cpp.log)" >> $GITHUB_STEP_SUMMARY;
printf "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
exit 1;
else
echo "C Lint: all good ✨" >> $GITHUB_STEP_SUMMARY;
fi
- name: 'Check image assets'
if: always()
run: |
set +e;
./fbt -s lint_img 2>&1 | tee lint-assets.log;
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
# Save multiline output
echo "errors=1" >> $GITHUB_OUTPUT;
printf "Image Lint errors:\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
echo "$(cat lint-assets.log)" >> $GITHUB_STEP_SUMMARY;
printf "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY;
exit 1;
else
echo "Image Lint: all good ✨" >> $GITHUB_STEP_SUMMARY;
fi
- name: Report code formatting errors
if: ( steps.syntax_check_py.outputs.errors || steps.syntax_check_cpp.outputs.errors ) && github.event.pull_request
run: |
echo "Code formatting errors found";
echo "Please run './fbt format' or './fbt format_py' to fix them";
exit 1;