2023-03-15 18:24:56 +03:00
|
|
|
name: 'Lint sources & check submodule integrity'
|
2022-01-12 17:06:39 +03:00
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
|
2023-03-15 18:24:56 +03:00
|
|
|
env:
|
|
|
|
TARGETS: f7
|
|
|
|
FBT_TOOLCHAIN_PATH: /runner/_work
|
|
|
|
SET_GH_OUTPUT: 1
|
|
|
|
|
2022-01-12 17:06:39 +03:00
|
|
|
jobs:
|
2023-03-15 18:24:56 +03:00
|
|
|
lint_sources_check_submodules:
|
2023-09-01 06:09:48 +03:00
|
|
|
runs-on: [self-hosted, FlipperZeroShell]
|
2022-01-12 17:06:39 +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 {} \;
|
2022-08-02 17:05:31 +03:00
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 16:10:51 +03:00
|
|
|
uses: actions/checkout@v3
|
2022-08-02 17:05:31 +03:00
|
|
|
with:
|
2023-08-25 17:38:41 +03:00
|
|
|
fetch-depth: 2
|
|
|
|
ref: ${{ github.sha }}
|
2023-03-15 18:24:56 +03:00
|
|
|
|
2022-08-02 17:05:31 +03:00
|
|
|
- name: 'Check protobuf branch'
|
|
|
|
run: |
|
2022-10-12 18:31:25 +03:00
|
|
|
git submodule update --init
|
2022-08-02 17:05:31 +03:00
|
|
|
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
|
2023-03-15 18:24:56 +03:00
|
|
|
echo "name=fails::error" >> $GITHUB_OUTPUT;
|
2023-04-19 14:08:13 +03:00
|
|
|
echo "::error::Error: Too few commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
|
2022-08-02 17:05:31 +03:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
|
2023-03-15 18:24:56 +03:00
|
|
|
echo "name=fails::error" >> $GITHUB_OUTPUT;
|
2022-08-02 17:05:31 +03:00
|
|
|
echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
|
|
|
|
exit 1;
|
|
|
|
fi
|
2023-03-15 18:24:56 +03:00
|
|
|
|
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;
|
2023-09-11 12:30:56 +03:00
|
|
|
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;
|
|
|
|
exit 1;
|
|
|
|
else
|
|
|
|
echo "No new TODOs without tickets found" >> $GITHUB_STEP_SUMMARY;
|
|
|
|
fi
|
|
|
|
|
2023-03-15 18:24:56 +03:00
|
|
|
- name: 'Check Python code formatting'
|
|
|
|
id: syntax_check_py
|
2023-08-25 17:38:41 +03:00
|
|
|
if: always()
|
2023-04-19 14:08:13 +03:00
|
|
|
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
|
2023-04-28 17:25:20 +03:00
|
|
|
|
2023-03-15 18:24:56 +03:00
|
|
|
- name: 'Check C++ code formatting'
|
|
|
|
id: syntax_check_cpp
|
2023-04-19 14:08:13 +03:00
|
|
|
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
|
2023-03-15 18:24:56 +03:00
|
|
|
|
|
|
|
- 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;
|