ci: bump up sdk version from v5.0.2 to v5.2 (#16) #128
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
build-on-esp-idf-v5_2: | |
name: Build on ESP-IDF v5.2 | |
runs-on: ubuntu-latest | |
container: espressif/idf:v5.2 | |
steps: | |
- name: Clone | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Prepare | |
run: | | |
apt-get update && apt-get -y install cppcheck python3-dev | |
git config --system --add safe.directory '*' | |
git fetch | |
echo "CODECHECKER_RESULT=$(echo .github/codechecker_result.txt)" >> $GITHUB_ENV | |
echo "CODECHECKER_BASE=$(echo .github/codechecker.baseline)" >> $GITHUB_ENV | |
echo "CODECHECKER_BASE_TMP=$(echo .github/codechecker_tmp.baseline)" >> $GITHUB_ENV | |
echo "MEMSEG_RESULT=$(echo .github/memsize.txt)" >> $GITHUB_ENV | |
echo "MEMSEG_BASE=$(echo .github/memsize.baseline)" >> $GITHUB_ENV | |
echo "MEMSEG_BASE_TMP=$(echo .github/memsize_tmp.baseline)" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
. $IDF_PATH/export.sh | |
idf.py set-target esp32s3 | |
idf.py build | |
- name: Process Memory Usage | |
continue-on-error: true | |
run: | | |
git checkout origin/main $MEMSEG_BASE || cp $MEMSEG_BASE.template $MEMSEG_BASE | |
. $IDF_PATH/export.sh | |
xtensa-esp32s3-elf-size build/*.elf > $MEMSEG_BASE_TMP | |
echo -n "\`\`\`\n " > $MEMSEG_RESULT | |
cat $MEMSEG_BASE_TMP | sed -n 1p >> $MEMSEG_RESULT | |
echo -n "current " >> $MEMSEG_RESULT | |
cat $MEMSEG_BASE_TMP | sed -n 2p >> $MEMSEG_RESULT | |
echo -n "base " >> $MEMSEG_RESULT | |
cat $MEMSEG_BASE | sed -n 2p >> $MEMSEG_RESULT | |
echo -n "diff " >> $MEMSEG_RESULT | |
paste $MEMSEG_BASE $MEMSEG_BASE_TMP | \ | |
sed -n 2p | \ | |
awk '{printf "%7d %7d %7d", $7-$1, $8-$2, $9-$3}' >> $MEMSEG_RESULT | |
echo "\n\`\`\`" >> $MEMSEG_RESULT | |
cp $MEMSEG_BASE_TMP $MEMSEG_BASE | |
- name: Comment Memory Size | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require("fs"); | |
const filepath = "${{ env.MEMSEG_RESULT }}"; | |
const body = fs.readFileSync(filepath, "utf-8"); | |
github.rest.issues.createComment({ | |
issue_number: ${{ github.event.number }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}) | |
- name: Static Analysis | |
id: analysis | |
run: | | |
$IDF_PATH/tools/idf_tools.py install xtensa-clang | |
. $IDF_PATH/export.sh | |
pip3 install codechecker | |
sed -i 's/-fno-tree-switch-conversion//g' build/compile_commands.json | |
sed -i 's/-fstrict-volatile-bitfields//g' build/compile_commands.json | |
sed -i 's/-std=gnu17//g' build/compile_commands.json | |
CodeChecker analyze ./build/compile_commands.json --enable sensitive \ | |
--output ./reports --ignore .codechecker.exclude | |
git checkout main $CODECHECKER_BASE || true | |
CodeChecker parse ./reports -e baseline -o $CODECHECKER_BASE_TMP || true | |
CodeChecker cmd diff -b $CODECHECKER_BASE \ | |
-n ./reports --new > $CODECHECKER_RESULT || | |
CodeChecker parse reports > $CODECHECKER_RESULT | |
- name: Process Analysis Result | |
if: always() | |
run: | | |
sed -i '1s/^/```\n/' $CODECHECKER_RESULT | |
echo "\n\`\`\`" >> $CODECHECKER_RESULT | |
cp $CODECHECKER_BASE_TMP $CODECHECKER_BASE | |
- name: Comment Static Analysis Result | |
if: always() && github.event_name == 'pull_request' && steps.analysis.outcome != 'success' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require("fs"); | |
const filepath = "${{ env.CODECHECKER_RESULT }}"; | |
const body = fs.readFileSync(filepath, "utf-8"); | |
github.rest.issues.createComment({ | |
issue_number: ${{ github.event.number }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}) | |
- name: Store codechecker baseline | |
if: always() && github.event_name == 'pull_request' | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: '[${{ env.CODECHECKER_BASE }}, ${{ env.MEMSEG_BASE }}]' | |
default_author: github_actions | |
push: origin HEAD:${{ github.head_ref }} --force |