gh: use shallow clones whenever possible (#2491)

* gh: use shallow clones whenever possible
* gh: reverted submodule checks
* gh: lint: joined linting scripts
* gh: renamed linter workflow
* check python linter output
* gh: reworked linter
* checking c linter
* gh: merged submodule check & lint
* gh: renamed step
* gh: removed redundant `submodules: false`

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger 2023-03-15 19:24:56 +04:00 committed by GitHub
parent c27d4d78f9
commit d8385b7f91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 98 deletions

View File

@ -27,7 +27,7 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
@ -177,8 +177,8 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
fetch-depth: 1
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -1,4 +1,4 @@
name: 'Check submodules branch'
name: 'Lint sources & check submodule integrity'
on:
push:
@ -9,9 +9,14 @@ on:
- '*'
pull_request:
env:
TARGETS: f7
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
check_protobuf:
runs-on: [self-hosted, FlipperZeroShell]
lint_sources_check_submodules:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
@ -22,9 +27,10 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check protobuf branch'
run: |
git submodule update --init
@ -36,12 +42,28 @@ jobs:
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 "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Too low 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 "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
exit 1;
fi
- name: 'Check Python code formatting'
id: syntax_check_py
run: ./fbt lint_py 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
- name: 'Check C++ code formatting'
if: always()
id: syntax_check_cpp
run: ./fbt lint 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
- 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;

View File

@ -1,47 +0,0 @@
name: 'Lint C/C++ with clang-format'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
TARGETS: f7
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
lint_c_cpp:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check code formatting'
id: syntax_check
run: ./fbt lint
- name: Report code formatting errors
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Please fix following code formatting errors:
```
${{ steps.syntax_check.outputs.errors }}
```
You might want to run `./fbt format` for an auto-fix.

View File

@ -1,33 +0,0 @@
name: 'Python Lint'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
lint_python:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check code formatting'
run: ./fbt lint_py

View File

@ -21,7 +21,7 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -28,7 +28,7 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -21,7 +21,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get flipper from device manager (mock)'

View File

@ -21,7 +21,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get flipper from device manager (mock)'
@ -62,7 +63,7 @@ jobs:
uses: actions/checkout@v3
if: failure()
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ steps.release_tag.outputs.tag }}
- name: 'Flash last release'

4
fbt
View File

@ -25,10 +25,10 @@ fi
if [ -z "$FBT_NO_SYNC" ]; then
if [ ! -d "$SCRIPT_PATH/.git" ]; then
echo "\".git\" directory not found, please clone repo via \"git clone --recursive\"";
echo "\".git\" directory not found, please clone repo via \"git clone\"";
exit 1;
fi
git submodule update --init;
git submodule update --init --depth 1;
fi
$SCONS_EP $SCONS_DEFAULT_FLAGS "$@"

View File

@ -5,9 +5,9 @@ set SCONS_EP=python -m SCons
if [%FBT_NO_SYNC%] == [] (
if exist ".git" (
git submodule update --init
git submodule update --init --depth 1
) else (
echo Not in a git repo, please clone with git clone --recursive
echo Not in a git repo, please clone with "git clone"
exit /b 1
)
)