From 8ab651fb47e2bf97ec9946c48ccbe8252d24c1ef Mon Sep 17 00:00:00 2001 From: Ying WANG Date: Fri, 6 Oct 2023 12:40:47 +0200 Subject: [PATCH 1/5] fix the linter for renovate PR --- .github/workflows/lint-renovate-pr.yml | 70 ++++++++++++++++++++++++++ mimir-build-image/Dockerfile | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint-renovate-pr.yml diff --git a/.github/workflows/lint-renovate-pr.yml b/.github/workflows/lint-renovate-pr.yml new file mode 100644 index 00000000000..9a8fa161cb0 --- /dev/null +++ b/.github/workflows/lint-renovate-pr.yml @@ -0,0 +1,70 @@ +name: Lint and Update renovate PR + +# configure trigger by pull request +on: + pull_request: + types: [opened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + prepare: + if: github.event.pull_request.user.login == 'renovate[bot]' + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Get build image from Makefile + id: build_image_step + run: echo "build_image=$(make print-build-image)" >> "$GITHUB_OUTPUT" + outputs: + build_image: ${{ steps.build_image_step.outputs.build_image }} + + lint_and_update: + runs-on: ubuntu-latest + needs: + - prepare + container: + image: ${{ needs.prepare.outputs.build_image }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_BOT_ACCESS_TOKEN }} + + - name: Run Git Config + run: | + git config --global --add safe.directory '*' + git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com" + git config --global user.name "${{ github.event.pull_request.user.login }}" + + - name: Checkout Pull Request Branch + run: gh pr checkout ${{ github.event.pull_request.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_BOT_ACCESS_TOKEN }} + + - name: Run make targets + id: update + run: | + make BUILD_IN_CONTAINER=false doc + make BUILD_IN_CONTAINER=false build-helm-tests + + - name: Check Updates + id: check_updates + run: | + if ./tools/find-diff-or-untracked.sh operations/helm/; then + echo "diff=0" >> "$GITHUB_OUTPUT" # Script success, no change + else + echo "diff=1" >> "$GITHUB_OUTPUT" # Script failed, changes exist + fi + + - name: Update PR + id: update_pr + if: steps.check_updates.outputs.diff != '0' + run: | + echo "Add commit to fix linting errors" + git add operations/helm/ + git commit -m "Update build with linting fixes" + git push \ No newline at end of file diff --git a/mimir-build-image/Dockerfile b/mimir-build-image/Dockerfile index 7a225b44a1b..91bb487acb6 100644 --- a/mimir-build-image/Dockerfile +++ b/mimir-build-image/Dockerfile @@ -9,7 +9,7 @@ FROM golang:1.21.2-bullseye ARG goproxyValue ENV GOPROXY=${goproxyValue} ENV SKOPEO_DEPS="libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config" -RUN apt-get update && apt-get install -y curl python3-requests python3-yaml file jq zip unzip protobuf-compiler libprotobuf-dev shellcheck libpcap-dev $SKOPEO_DEPS && \ +RUN apt-get update && apt-get install -y curl python3-requests python3-yaml file jq zip unzip protobuf-compiler libprotobuf-dev shellcheck gh libpcap-dev $SKOPEO_DEPS && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN go install golang.org/x/tools/cmd/goimports@3fce476f0a782aeb5034d592c189e63be4ba6c9e RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - From 5f5cb96b968f29991b615195dc22fe23776fd4e8 Mon Sep 17 00:00:00 2001 From: Ying WANG Date: Fri, 6 Oct 2023 18:13:47 +0200 Subject: [PATCH 2/5] remove gh to another PR --- .github/workflows/lint-renovate-pr.yml | 3 +++ mimir-build-image/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-renovate-pr.yml b/.github/workflows/lint-renovate-pr.yml index 9a8fa161cb0..ff49d988412 100644 --- a/.github/workflows/lint-renovate-pr.yml +++ b/.github/workflows/lint-renovate-pr.yml @@ -39,6 +39,9 @@ jobs: git config --global --add safe.directory '*' git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com" git config --global user.name "${{ github.event.pull_request.user.login }}" + + - name: Install the gh cli + uses: ksivamuthu/actions-setup-gh-cli@v2 - name: Checkout Pull Request Branch run: gh pr checkout ${{ github.event.pull_request.number }} diff --git a/mimir-build-image/Dockerfile b/mimir-build-image/Dockerfile index 91bb487acb6..7a225b44a1b 100644 --- a/mimir-build-image/Dockerfile +++ b/mimir-build-image/Dockerfile @@ -9,7 +9,7 @@ FROM golang:1.21.2-bullseye ARG goproxyValue ENV GOPROXY=${goproxyValue} ENV SKOPEO_DEPS="libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config" -RUN apt-get update && apt-get install -y curl python3-requests python3-yaml file jq zip unzip protobuf-compiler libprotobuf-dev shellcheck gh libpcap-dev $SKOPEO_DEPS && \ +RUN apt-get update && apt-get install -y curl python3-requests python3-yaml file jq zip unzip protobuf-compiler libprotobuf-dev shellcheck libpcap-dev $SKOPEO_DEPS && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN go install golang.org/x/tools/cmd/goimports@3fce476f0a782aeb5034d592c189e63be4ba6c9e RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - From ef47623dac7dcf5041b600e1973576cb7d946774 Mon Sep 17 00:00:00 2001 From: Ying WANG Date: Fri, 6 Oct 2023 18:36:30 +0200 Subject: [PATCH 3/5] update with comments --- .github/workflows/lint-renovate-pr.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint-renovate-pr.yml b/.github/workflows/lint-renovate-pr.yml index ff49d988412..74ad0a3900e 100644 --- a/.github/workflows/lint-renovate-pr.yml +++ b/.github/workflows/lint-renovate-pr.yml @@ -1,9 +1,11 @@ -name: Lint and Update renovate PR +name: Regenerate docs and helm tests # configure trigger by pull request on: pull_request: types: [opened, synchronize] + paths: + - 'operations/helm/**' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} @@ -51,8 +53,7 @@ jobs: - name: Run make targets id: update run: | - make BUILD_IN_CONTAINER=false doc - make BUILD_IN_CONTAINER=false build-helm-tests + make BUILD_IN_CONTAINER=false doc build-helm-tests - name: Check Updates id: check_updates @@ -67,7 +68,7 @@ jobs: id: update_pr if: steps.check_updates.outputs.diff != '0' run: | - echo "Add commit to fix linting errors" + echo "Add commit for regenerating helm tests and docs" git add operations/helm/ git commit -m "Update build with linting fixes" - git push \ No newline at end of file + git push From 4b4d25c2e262d80f50d7cbbecde884532df86350 Mon Sep 17 00:00:00 2001 From: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:39:21 +0200 Subject: [PATCH 4/5] Update lint-renovate-pr.yml --- .github/workflows/lint-renovate-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-renovate-pr.yml b/.github/workflows/lint-renovate-pr.yml index 74ad0a3900e..a43b0a6ef14 100644 --- a/.github/workflows/lint-renovate-pr.yml +++ b/.github/workflows/lint-renovate-pr.yml @@ -70,5 +70,5 @@ jobs: run: | echo "Add commit for regenerating helm tests and docs" git add operations/helm/ - git commit -m "Update build with linting fixes" + git commit -m "Update build with regenerated helm tests and docs" git push From 051804b58d7eae0e516dc6b197eac9f27074952c Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Fri, 6 Oct 2023 19:06:11 +0200 Subject: [PATCH 5/5] Rename lint-renovate-pr.yml to generate-docs-helm-tests-renovate-pr.yml --- ...t-renovate-pr.yml => generate-docs-helm-tests-renovate-pr.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{lint-renovate-pr.yml => generate-docs-helm-tests-renovate-pr.yml} (100%) diff --git a/.github/workflows/lint-renovate-pr.yml b/.github/workflows/generate-docs-helm-tests-renovate-pr.yml similarity index 100% rename from .github/workflows/lint-renovate-pr.yml rename to .github/workflows/generate-docs-helm-tests-renovate-pr.yml