From 2c4f1b494202c61e22a703593f6fb68cda57acf0 Mon Sep 17 00:00:00 2001 From: gfurtadoalmeida <27151609+gfurtadoalmeida@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:41:30 -0300 Subject: [PATCH] Update pipeline to use custom docker image --- .github/scripts/build-with-sonar.sh | 49 ----------------------------- .github/workflows/build.yml | 16 +++------- 2 files changed, 4 insertions(+), 61 deletions(-) delete mode 100644 .github/scripts/build-with-sonar.sh diff --git a/.github/scripts/build-with-sonar.sh b/.github/scripts/build-with-sonar.sh deleted file mode 100644 index 5761f15..0000000 --- a/.github/scripts/build-with-sonar.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -TZ=America/Sao_Paulo -ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -apt update -apt-get install openjdk-17-jre -y - -source /opt/esp/idf/export.sh - -SONAR_SERVER_URL="https://sonarcloud.io" -SONAR_SCANNER_VERSION="5.0.1.3006" -SONAR_SCANNER_DOWNLOAD_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip" -SONAR_WRAPPER_DOWNLOAD_URL="$SONAR_SERVER_URL/static/cpp/build-wrapper-linux-x86.zip" -SONAR_WRAPPER_OUTPUT_DIR="build_wrapper_output" - -mkdir -p $HOME/.sonar - -curl -sSLo $HOME/.sonar/sonar-scanner.zip $SONAR_SCANNER_DOWNLOAD_URL -unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ -echo "$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux/bin" -export PATH="$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux/bin":$PATH - -curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip $SONAR_WRAPPER_DOWNLOAD_URL -unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ -echo "$HOME/.sonar/build-wrapper-linux-x86" -export PATH="$HOME/.sonar/build-wrapper-linux-x86":$PATH - -java --version - -build-wrapper-linux-x86-64 --out-dir $SONAR_WRAPPER_OUTPUT_DIR idf.py build - -if [ $? -eq 0 ] -then - sonar-scanner --define sonar.host.url="$SONAR_SERVER_URL" \ - --define sonar.organization=$SONAR_ORGANIZATION_NAME \ - --define sonar.token=$SONAR_ORGANIZATION_TOKEN - - if [ $? -eq 0 ] - then - exit 0 - else - echo "Failure scanning source code" - exit 1 - fi -else - echo "Failure building on Docker" - exit 1 -fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0814c51..6c04a53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ on: workflow_dispatch: env: - esp_docker_tag: v5.1 + esp_docker_image: gfurtadoalmeida/esp32-docker-sonar:v5.1 jobs: build: @@ -31,20 +31,12 @@ jobs: - name: Pull ESP-IDF Image shell: pwsh - run: docker pull espressif/idf:${{env.esp_docker_tag}} + run: docker pull ${{env.esp_docker_image}} - name: Build with Sonar shell: pwsh - run: docker run --rm -e LC_ALL='C.UTF-8' --env SONAR_ORGANIZATION_NAME=${{secrets.SONARCLOUD_ORGANIZATION}} --env SONAR_ORGANIZATION_TOKEN=${{secrets.SONARCLOUD_TOKEN}} -v ${{github.workspace}}:/project -w /project espressif/idf:${{env.esp_docker_tag}} bash .github/scripts/build-with-sonar.sh - - - name: Publish Binaries - uses: actions/upload-artifact@v3.1.2 - with: - name: binary - path: ${{github.workspace}}/build/*.bin - if-no-files-found: error - retention-days: 1 + run: docker run --rm --env SONARCLOUD_ORGANIZATION=${{secrets.SONARCLOUD_ORGANIZATION}} --env SONARCLOUD_TOKEN=${{secrets.SONARCLOUD_TOKEN}} --env LC_ALL='C.UTF-8' -v ${{github.workspace}}:/project -w /project ${{env.esp_docker_image}} idf.py build - name: Build Test shell: pwsh - run: docker run --rm -e LC_ALL='C.UTF-8' -v ${{github.workspace}}:/project -w /project espressif/idf:${{env.esp_docker_tag}} idf.py -C ./test build + run: docker run --rm --env LC_ALL='C.UTF-8' -v ${{github.workspace}}:/project -w /project ${{env.esp_docker_image}} idf.py -C ./test build