diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..c745df0b03 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: Continuous Integration (CI) + +on: + push: + + pull_request: + branches: [ develop ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + arch: [Esp8266, Host, Esp32, Rp2040] + variant: [""] + os: [ubuntu-latest, windows-latest] + include: + - arch: Esp32 + variant: esp32s2 + os: ubuntu-latest + - arch: Esp32 + variant: esp32s2 + os: windows-latest + - arch: Esp32 + variant: esp32c3 + os: ubuntu-latest + - arch: Esp32 + variant: esp32c3 + os: windows-latest + exclude: + - os: windows-latest + arch: Host + + continue-on-error: ${{ matrix.arch == 'Host' && matrix.os == 'windows-latest' }} + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ toJson(matrix) }} + cancel-in-progress: true + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup SMING_HOME for Ubuntu + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + echo "CI_BUILD_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "SMING_HOME=$GITHUB_WORKSPACE/Sming" >> $GITHUB_ENV + - name: Setup SMING_HOME for Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + echo ("CI_BUILD_DIR=" + $env:GITHUB_WORKSPACE) >> $env:GITHUB_ENV + $env:SMING_HOME = Join-Path $env:GITHUB_WORKSPACE "Sming" + echo ("SMING_HOME=" + $env:SMING_HOME) >> $env:GITHUB_ENV + - name: Install Sming Framework on Ubuntu + if: ${{ matrix.os == 'ubuntu-latest' }} + env: + SMING_ARCH: ${{matrix.arch}} + SMING_SOC: ${{matrix.variant}} + run: | + ./Tools/install.sh $(echo "$SMING_ARCH" | tr '[:upper:]' '[:lower:]') + - name: Install Sming Framework on Windows + if: ${{ matrix.os == 'windows-latest' }} + env: + SMING_ARCH: ${{matrix.arch}} + SMING_SOC: ${{matrix.variant}} + run: | + Tools/ci/setenv.ps1 + Tools/install.cmd "$env:SMING_ARCH".ToLower() + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + - name: Build and Test for ${{matrix.arch}} on Ubuntu + env: + SMING_ARCH: ${{matrix.arch}} + SMING_SOC: ${{matrix.variant}} + CLANG_FORMAT: clang-format-8 + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + source $SMING_HOME/../Tools/export.sh + $CLANG_FORMAT --version + ./Tools/ci/build.sh + - name: Build and Test for ${{matrix.arch}} on Windows + env: + SMING_ARCH: ${{matrix.arch}} + SMING_SOC: ${{matrix.variant}} + PYTHON_PATH: C:\hostedtoolcache\windows\Python\3.9.12\x64\ + if: ${{ matrix.os == 'windows-latest' }} + run: | + Tools/ci/setenv.ps1 + Tools/ci/build.cmd + diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml new file mode 100644 index 0000000000..1d65dd2aaf --- /dev/null +++ b/.github/workflows/coverity-scan.yml @@ -0,0 +1,73 @@ +name: Coverity Scan + +on: + # Push to master MUST be evaluated + # Pushing to develop only on condition + push: + branches: [ master, develop ] + # Pull requests to master MUST be evaluated + pull_request: + branches: [ master ] + # Run the workflow once a month + schedule: + - cron: '30 1 1 * *' + +jobs: + scan: +# concurrency: +# group: ${{ github.head_ref || github.run_id }} +# cancel-in-progress: true + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Check if we are allowed to scan + env: + BRANCH: ${{github.ref_name}} + run: | + CHECK_SCA=0 + if [[ "$BRANCH" == "master" ]]; then + CHECK_SCA=1; + elif [[ $BRANCH == "develop" ]]; then + if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then + CHECK_SCA=1; + elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then + COMMIT_MSG=$(git log --format=%B -n 1) + if [[ "$COMMIT_MSG" == *"[scan:coverity]"* ]]; then + CHECK_SCA=1; + fi + fi + fi + + echo "CHECK_SCA=$CHECK_SCA" >> $GITHUB_ENV + - name: Setup SMING_HOME for Ubuntu + if: ${{ env.CHECK_SCA == 1 }} + run: | + echo "CI_BUILD_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "SMING_HOME=$GITHUB_WORKSPACE/Sming" >> $GITHUB_ENV + echo "SMING_ARCH=Host" >> $GITHUB_ENV + - name: Install Sming Framework on Ubuntu + if: ${{ env.CHECK_SCA == 1 }} + run: | + ./Tools/install.sh $(echo "$SMING_ARCH" | tr '[:upper:]' '[:lower:]') + - name: Install Ninja + if: ${{ env.CHECK_SCA == 1 }} + uses: seanmiddleditch/gha-setup-ninja@master + - name: Run Coverity Scan + if: ${{ env.CHECK_SCA == 1 }} + env: + COVERITY_SCAN_TOKEN: ${{secrets.COVERITY_SCAN_TOKEN}} + run: | + source $SMING_HOME/../Tools/export.sh + export MAKE_PARALLEL="make -j$(nproc)" + export COVERITY_SCAN_BUILD_COMMAND_PREPEND="cd $SMING_HOME" + cat > /tmp/secrets.sh + $SMING_HOME/Arch/Host/Tools/ci/coverity-scan.sh + - name: Archive scan log + if: ${{ env.CHECK_SCA == 1 }} + uses: actions/upload-artifact@v3 + with: + name: coverity-scan-report + path: Sming/cov-int/scm_log.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..0d4abe542a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + workflow_dispatch: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +# TODO: check if the tag is pointing to the tip of the master branch + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: trstringer/manual-approval@v1 + if: ${{ github.ref_type == 'tag' }} + with: + secret: ${{ github.TOKEN }} + approvers: slaff + - name: Install xmlstarlet + if: ${{ github.ref_type == 'tag' }} + run: sudo apt-get install -y xmlstarlet + - name: Build docs + if: ${{ github.ref_type == 'tag' }} + run: | + Tools/install.sh doc + make -C docs html + zip -r sming-docs.zip docs/build/html + - name: Release New Version + if: ${{ github.ref_type == 'tag' }} + env: + SMING_ARCH: Host + RELEASE_TOKEN: ${{secrets.RELEASE_TOKEN}} + CI_REPO_NAME: ${{github.repository}} + CHOCO_TOKEN: ${{secrets.CHOKO_TOKEN}} + run: | + export CI_BUILD_DIR="$GITHUB_WORKSPACE" + export SMING_HOME="$GITHUB_WORKSPACE/Sming" + make -C $SMING_HOME submodules + cat > /tmp/secrets.sh + Tools/ci/deploy.sh ${{github.ref_name}} \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/spelling-check.yml similarity index 89% rename from .github/workflows/pull-request.yml rename to .github/workflows/spelling-check.yml index 2ab7d91ddf..0edeb0080e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/spelling-check.yml @@ -1,10 +1,9 @@ -# Run whenever a PR is generated or updated. - -name: Pull Request Checks +name: Spelling Check on: pull_request: - + branches: [ develop ] + jobs: code-spell: diff --git a/README.md b/README.md index 83ab9aee4e..5cb54bc23b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Sming is [open source](LICENSE), modular and supports [multiple architectures](h [![Backers](https://opencollective.com/Sming/backers/badge.svg)](#financial-contributions) [![Sponsors](https://opencollective.com/Sming/sponsors/badge.svg)](#financial-contributions) [![Download](https://img.shields.io/badge/download-~1.7M-orange.svg)](https://github.com/SmingHub/Sming/releases/latest) -[![Build](https://travis-ci.org/SmingHub/Sming.svg?branch=develop)](https://travis-ci.org/SmingHub/Sming) +[![Build](https://github.com/SmingHub/Sming/actions/workflows/ci.yml/badge.svg)](https://github.com/SmingHub/Sming/actions/workflows/ci.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/23ff16f8d550440787125b0d25ba7ada)](https://www.codacy.com/gh/SmingHub/Sming/dashboard?utm_source=github.com&utm_medium=referral&utm_content=SmingHub/Sming&utm_campaign=Badge_Grade) [![Coverity Badge](https://img.shields.io/coverity/scan/12007.svg)](https://scan.coverity.com/projects/sminghub-sming) diff --git a/Sming/Components/crypto/include/Crypto/HashContext.h b/Sming/Components/crypto/include/Crypto/HashContext.h index 6192c7b59c..512d6cf477 100644 --- a/Sming/Components/crypto/include/Crypto/HashContext.h +++ b/Sming/Components/crypto/include/Crypto/HashContext.h @@ -103,7 +103,7 @@ template class HashContext */ Hash getHash() { - Hash hash; + Hash hash{}; engine.final(hash.data()); return hash; } diff --git a/Tools/ci/build.cmd b/Tools/ci/build.cmd index 098a127291..4efca9ff24 100644 --- a/Tools/ci/build.cmd +++ b/Tools/ci/build.cmd @@ -9,9 +9,6 @@ if "%BUILD_DOCS%"=="true" ( goto :EOF ) -subst z: %CI_BUILD_DIR% -set SMING_HOME=z:\Sming - cd /d %SMING_HOME% call Arch\%SMING_ARCH%\Tools\ci\build.setup.cmd || goto :error diff --git a/Tools/ci/setenv.ps1 b/Tools/ci/setenv.ps1 index 5e50e39b86..a2c69a3925 100644 --- a/Tools/ci/setenv.ps1 +++ b/Tools/ci/setenv.ps1 @@ -26,9 +26,11 @@ if (Test-Path "$env:PICO_TOOLCHAIN_PATH" ) { if ($IsWindows) { $env:PATH = "C:\MinGW\msys\1.0\bin;C:\MinGW\bin;$env:PATH" - $env:PYTHON_PATH = "C:\Python39-x64" - if ( -not (Test-Path "$env:PYTHON_PATH") ) { - $env:PYTHON_PATH = "C:\Python39" + if ($null -eq $env:PYTHON_PATH) { + $env:PYTHON_PATH = "C:\Python39-x64" + if ( -not (Test-Path "$env:PYTHON_PATH") ) { + $env:PYTHON_PATH = "C:\Python39" + } } $env:PATH = "$env:PYTHON_PATH;$env:PYTHON_PATH\Scripts;$env:PATH" diff --git a/appveyor.yml b/appveyor.yml index 972d188321..fb4c571ef5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,4 @@ image: -- Ubuntu2004 - Visual Studio 2019 environment: @@ -9,21 +8,6 @@ environment: matrix: - SMING_ARCH: Host - - SMING_ARCH: Esp8266 - - - SMING_ARCH: Esp32 - SMING_SOC: esp32 - - - SMING_ARCH: Esp32 - SMING_SOC: esp32s2 - - - SMING_ARCH: Esp32 - SMING_SOC: esp32c3 - - - SMING_ARCH: Rp2040 - - - BUILD_DOCS: true - install: - ps: | # Set up environment variables for all environments and build types