Merge pull request #2023 from cesanta/push

Reduce the number of redundant test runs. Disable SNTP test on macos …
This commit is contained in:
Sergio R. Caprile 2023-02-06 11:25:33 -03:00 committed by GitHub
commit 8edc8610dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 21 deletions

View File

@ -4,14 +4,20 @@ jobs:
Fuzzing: Fuzzing:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3
with: { fetch-depth: 2 }
- id: check
run: /bin/bash test/check.sh '^src/'
- name: Build Fuzzers - name: Build Fuzzers
id: build id: build
if: steps.check.outputs.MATCH == 1
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with: with:
oss-fuzz-project-name: 'mongoose' oss-fuzz-project-name: 'mongoose'
dry-run: false dry-run: false
language: c++ language: c++
- name: Run Fuzzers - name: Run Fuzzers
if: steps.check.outputs.MATCH == 1
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with: with:
oss-fuzz-project-name: 'mongoose' oss-fuzz-project-name: 'mongoose'
@ -20,7 +26,7 @@ jobs:
language: c++ language: c++
- name: Upload Crash - name: Upload Crash
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success' if: steps.check.outputs.MATCH == 1 && failure() && steps.build.outcome == 'success'
with: with:
name: artifacts name: artifacts
path: ./out/artifacts path: ./out/artifacts

View File

@ -1,5 +1,10 @@
name: build name: build
on: [push, pull_request] on:
push:
paths:
- "**Makefile"
- "**.c"
- "**.h"
env: env:
IPV6: 0 IPV6: 0
jobs: jobs:
@ -18,9 +23,15 @@ jobs:
SSL: ${{ matrix.ssl }} SSL: ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: ./test/setup_ga_network.sh with: { fetch-depth: 2 }
- run: sudo apt-get update ; sudo apt-get install libmbedtls-dev - id: check
- run: make ${{ matrix.target }} run: /bin/bash test/check.sh '^test|^src'
- if: steps.check.outputs.MATCH == 1
run: ./test/setup_ga_network.sh
- if: steps.check.outputs.MATCH == 1
run: sudo apt-get update ; sudo apt-get install libmbedtls-dev
- if: steps.check.outputs.MATCH == 1
run: make ${{ matrix.target }}
s390: s390:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -55,24 +66,28 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install jq mbedtls openssl - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install jq mbedtls openssl
- run: make test upload-coverage SSL=OPENSSL ASAN_OPTIONS= OPENSSL=`echo /usr/local/Cellar/openssl*/*` - run: make test upload-coverage TFLAGS=-DNO_SNTP_CHECK SSL=OPENSSL ASAN_OPTIONS= OPENSSL=`echo /usr/local/Cellar/openssl*/*`
- run: make test SSL=MBEDTLS ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*` - run: make test SSL=MBEDTLS TFLAGS=-DNO_SNTP_CHECK ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*`
#- run: make mip_test ASAN_OPTIONS= #- run: make mip_test ASAN_OPTIONS=
- run: make mg_prefix - run: make mg_prefix
windows: windows:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: make vc98 with: { fetch-depth: 2 }
- run: make vc17 - id: check
- run: make vc22 run: /bin/bash test/check.sh '^test|^src'
- run: make mingw - if: steps.check.outputs.MATCH == 1
- run: make mingw++ run: make vc98 vc17 vc22 mingw mingw++
arduino-xiao: arduino-xiao:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: make arduino-xiao with: { fetch-depth: 2 }
- id: check
run: /bin/bash test/check.sh '^examples/arduino|^src'
- if: steps.check.outputs.MATCH == 1
run: make arduino-xiao
arm: arm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -138,21 +153,37 @@ jobs:
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: sudo apt -y install gcc-arm-none-eabi with: { fetch-depth: 2 }
- id: check
run: /bin/bash test/check.sh '^src|^examples/${{ matrix.example.path }}'
- if: steps.check.outputs.MATCH == 1
run: sudo apt -y install gcc-arm-none-eabi
- name: ${{ matrix.example.path }} - name: ${{ matrix.example.path }}
if: steps.check.outputs.MATCH == 1
run: make -C examples/${{ matrix.example.path }} ${{ matrix.example.target || 'build' }} VCON_API_KEY=${{secrets.VCON_API_KEY}} run: make -C examples/${{ matrix.example.path }} ${{ matrix.example.target || 'build' }} VCON_API_KEY=${{secrets.VCON_API_KEY}}
zephyr_examples: zephyr_examples:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: make -C examples/zephyr init with: { fetch-depth: 2 }
- id: check
run: /bin/bash test/check.sh '^examples/zephyr|^src'
- if: steps.check.outputs.MATCH == 1
run: make -C examples/zephyr init
- name: minify manifest - name: minify manifest
if: steps.check.outputs.MATCH == 1
uses: mikefarah/yq@master uses: mikefarah/yq@master
with: with:
cmd: yq -i eval '(.manifest.defaults, .manifest.remotes, .manifest.projects[] | select(.name == "cmsis" or .name == "hal_stm32" or .name == "mbedtls" or .name == "mcuboot" or .name == "picolibc" | del(.null) ), .manifest.self) as $i ireduce({};setpath($i | path; $i)) | del(.manifest.projects.[].null) | del(..|select(length==0))' examples/zephyr/zephyrproject/zephyr/west.yml cmd: yq -i eval '(.manifest.defaults, .manifest.remotes, .manifest.projects[] | select(.name == "cmsis" or .name == "hal_stm32" or .name == "mbedtls" or .name == "mcuboot" or .name == "picolibc" | del(.null) ), .manifest.self) as $i ireduce({};setpath($i | path; $i)) | del(.manifest.projects.[].null) | del(..|select(length==0))' examples/zephyr/zephyrproject/zephyr/west.yml
- run: make -C examples/zephyr update - if: steps.check.outputs.MATCH == 1
- run: make -C examples/zephyr/device-dashboard build run: make -C examples/zephyr update
- run: make -C examples/zephyr/http-client build - if: steps.check.outputs.MATCH == 1
- run: make -C examples/zephyr/http-server build run: make -C examples/zephyr/device-dashboard build
- run: make -C examples/zephyr/mqtt-aws-client build - if: steps.check.outputs.MATCH == 1
- run: make -C examples/zephyr/websocket-server build run: make -C examples/zephyr/http-client build
- if: steps.check.outputs.MATCH == 1
run: make -C examples/zephyr/http-server build
- if: steps.check.outputs.MATCH == 1
run: make -C examples/zephyr/mqtt-aws-client build
- if: steps.check.outputs.MATCH == 1
run: make -C examples/zephyr/websocket-server build

30
test/check.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
#
# This script is used by the Github Actions
# o must be run with one parameter: a glob pattern
# o write "MATCH=1" (changed files match a pattern) or "MATCH=0" to $GITHUB_OUTPUT
#
# Usage in github actions:
# <job_name>:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with: { fetch-depth: 2 } # Important for git diff to work
# - id: check
# run: /bin/bash check.sh '.*'
# - if: steps.check.outputs.MATCH == 1
# run: .....
# List all files changed by the last commit, and compare with the passed
# pattern argument. If at least one file matches the pattern, write
# MATCH=1. If no files match, write MATCH=0.
for FILE in $(git --no-pager diff --name-only HEAD~1 HEAD) ; do
if [[ "$FILE" =~ $1 ]] ; then
echo FILE "$FILE" matches $1 # Log for debugging
echo MATCH=1 >> $GITHUB_OUTPUT
exit 0 # And exit early
else
echo FILE "$FILE" DOES NOT match $1 # Log for debugging
fi
done
echo MATCH=0 >> $GITHUB_OUTPUT

View File

@ -319,7 +319,9 @@ static void test_sntp_server(const char *url) {
ASSERT(c->is_udp == 1); ASSERT(c->is_udp == 1);
for (i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50); for (i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50);
MG_DEBUG(("server: %s, ms: %lld", url ? url : "(default)", ms)); MG_DEBUG(("server: %s, ms: %lld", url ? url : "(default)", ms));
#if !defined(NO_SNTP_CHECK)
ASSERT(ms > 0); ASSERT(ms > 0);
#endif
mg_mgr_free(&mgr); mg_mgr_free(&mgr);
} }