From f245824c318980da221cb8d0b70db6ce89de7f94 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 30 Aug 2024 20:44:55 -0300 Subject: [PATCH 1/5] Use requirements.txt in Dockerfile --- tools/docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index a46733a34..3262cbb2d 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -34,7 +34,6 @@ RUN : \ python3-setuptools \ python3-venv \ wget \ - && pip3 install --upgrade pip textual-dev \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && : @@ -70,7 +69,8 @@ RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANC fi && \ git checkout $LIBBUILDER_CHECKOUT_REF && \ git submodule update --init --recursive; \ - fi + fi && \ + pip3 install --upgrade -r $LIBBUILDER_PATH/tools/config_editor/requirements.txt COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh From 44160a81e57a2925efef0a39c26251043bbc659f Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 30 Aug 2024 20:45:15 -0300 Subject: [PATCH 2/5] Test docker build in PRs --- .github/workflows/docker.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8952015a2..2657c1dfb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,6 +7,12 @@ on: - 'release/*' tags: - 'v*.*' + pull_request: + paths: + - ".github/workflows/docker.yml" + - "tools/config_editor/**" + - "tools/docker/**" + - "!**.md" env: # Build the image for amd64 and arm64 @@ -16,7 +22,7 @@ env: jobs: docker: # Disable the job in forks - if: ${{ github.repository_owner == 'espressif' }} + if: ${{ github.event_name == 'pull_request' || github.repository_owner == 'espressif' }} runs-on: ubuntu-latest steps: @@ -29,16 +35,28 @@ jobs: run: | echo "CLONE_BRANCH_OR_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV echo "TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + - name: Set variables (release branches) if: ${{ github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} run: | echo "CLONE_BRANCH_OR_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV echo "TAG_NAME=release-${GITHUB_REF_NAME##release/}" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + - name: Set variables (main branch) if: ${{ github.ref_type == 'branch' && github.ref_name == 'master' }} run: | echo "CLONE_BRANCH_OR_TAG=master" >> $GITHUB_ENV echo "TAG_NAME=latest" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + + - name: Set variables (pull requests) + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "CLONE_BRANCH_OR_TAG=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + echo "TAG_NAME=PR_${{ github.event.number }}" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.event.pull_request.head.repo.full_name }}.git" >> $GITHUB_ENV # Display the variables set above, just in case. - name: Check variables @@ -46,33 +64,37 @@ jobs: echo "CLONE_BRANCH_OR_TAG: $CLONE_BRANCH_OR_TAG" echo "CHECKOUT_REF: $CHECKOUT_REF" echo "TAG_NAME: $TAG_NAME" + echo "URL: $URL" - # The following steps are the standard boilerplate from - # https://github.com/marketplace/actions/build-and-push-docker-images - name: Checkout uses: actions/checkout@v4 + - name: Login to Docker Hub + if: ${{ github.event_name == 'push' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up QEMU for multiarch builds uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push uses: docker/build-push-action@v5 with: context: tools/docker - push: true + push: ${{ github.event_name == 'push' }} tags: ${{ env.DOCKERHUB_REPO }}:${{ env.TAG_NAME }} platforms: ${{ env.BUILD_PLATFORMS }} build-args: | - LIBBUILDER_CLONE_URL=${{ github.server_url }}/${{ github.repository }}.git + LIBBUILDER_CLONE_URL=${{ env.URL }} LIBBUILDER_CLONE_BRANCH_OR_TAG=${{ env.CLONE_BRANCH_OR_TAG }} - name: Update Docker Hub repository description (master branch) - if: ${{ github.ref_type == 'branch' && github.ref_name == 'master' }} + if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master' }} uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From fe7799d232d8c3ab06dc5f589405e4b7aea450d9 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 30 Aug 2024 20:48:28 -0300 Subject: [PATCH 3/5] Optimize push workflow for PRs --- .github/workflows/push.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c3edd52d3..649c84c81 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,13 +5,21 @@ on: branches: - master pull_request: + paths: + - "**" + - "!**.md" + - "!.github/workflows/cron_build.yml" + - "!.github/workflows/cron.yml" + - "!.github/workflows/docker.yml" + - "!.github/workflows/repository_dispatch.yml" + - "!tools/config_editor/**" + - "!tools/docker/**" concurrency: group: esp-idf-libs-${{github.event.pull_request.number || github.ref}} cancel-in-progress: true jobs: - build-libs: name: Build Libs for ${{ matrix.target }} runs-on: ubuntu-latest @@ -21,16 +29,20 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 + - name: Install dependencies run: bash ./tools/prepare-ci.sh + - name: Build Libs for ${{ matrix.target }} run: bash ./build.sh -e -t ${{ matrix.target }} + - name: Upload build if: failure() uses: actions/upload-artifact@v4 with: name: build-${{ matrix.target }} path: build + - name: Upload archive uses: actions/upload-artifact@v4 with: @@ -48,17 +60,20 @@ jobs: path: dist pattern: artifacts-* merge-multiple: true + - shell: bash run: | mkdir -p out find dist -name 'arduino-esp32-libs-esp*.tar.gz' -exec tar zxvf {} -C out \; cd out/tools/esp32-arduino-libs && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../.. cp out/package_esp32_index.template.json dist/package_esp32_index.template.json + - name: Upload full esp32-arduino-libs archive uses: actions/upload-artifact@v4 with: name: esp32-arduino-libs path: dist/esp32-arduino-libs.tar.gz + - name: Upload package_esp32_index.template.json uses: actions/upload-artifact@v4 with: From d89b40cf7d7a6a199d8aaaacf08e552893f1de45 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 30 Aug 2024 21:04:49 -0300 Subject: [PATCH 4/5] Optimize docker workflow --- .github/workflows/docker.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2657c1dfb..a2ff13d10 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,9 +10,9 @@ on: pull_request: paths: - ".github/workflows/docker.yml" - - "tools/config_editor/**" - - "tools/docker/**" - - "!**.md" + - "tools/config_editor/requirements.txt" + - "tools/docker/Dockerfile" + - "tools/docker/entrypoint.sh" env: # Build the image for amd64 and arm64 @@ -23,7 +23,7 @@ jobs: docker: # Disable the job in forks if: ${{ github.event_name == 'pull_request' || github.repository_owner == 'espressif' }} - + name: Build and push if needed runs-on: ubuntu-latest steps: # Depending on the branch/tag, set CLONE_BRANCH_OR_TAG variable (used in the Dockerfile @@ -62,7 +62,6 @@ jobs: - name: Check variables run: | echo "CLONE_BRANCH_OR_TAG: $CLONE_BRANCH_OR_TAG" - echo "CHECKOUT_REF: $CHECKOUT_REF" echo "TAG_NAME: $TAG_NAME" echo "URL: $URL" From d5f674ead659a7280b6c33a4d9e69beac9ffd592 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 30 Aug 2024 21:12:08 -0300 Subject: [PATCH 5/5] Improve name --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a2ff13d10..d6166a365 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,7 +23,7 @@ jobs: docker: # Disable the job in forks if: ${{ github.event_name == 'pull_request' || github.repository_owner == 'espressif' }} - name: Build and push if needed + name: Build docker image and push if needed runs-on: ubuntu-latest steps: # Depending on the branch/tag, set CLONE_BRANCH_OR_TAG variable (used in the Dockerfile