From b2e55c063a34cf794b0b450b4d892ab2deccbce7 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Fri, 28 Apr 2023 11:31:45 +0200 Subject: [PATCH 1/3] .github: skip touching open PRs when the remote branch exists To avoid noise of touching existing PRs, check first if the remote branch already exists. If that exists, skip creating or updating the PR. --- .github/workflows/cacerts-apply-patch.sh | 9 +++++++-- .github/workflows/cacerts-release.yaml | 1 + .github/workflows/common.sh | 9 +++++++++ .github/workflows/containerd-apply-patch.sh | 9 +++++++-- .github/workflows/containerd-release-main.yaml | 1 + .github/workflows/docker-apply-patch.sh | 9 +++++++-- .github/workflows/docker-release-main.yaml | 1 + .github/workflows/firmware-apply-patch.sh | 9 +++++++-- .github/workflows/firmware-release-main.yaml | 1 + .github/workflows/go-apply-patch.sh | 9 +++++++-- .github/workflows/go-release-main.yaml | 1 + .github/workflows/kernel-apply-patch.sh | 5 +++++ .github/workflows/kernel-release.yaml | 1 + .github/workflows/runc-apply-patch.sh | 9 +++++++-- .github/workflows/runc-release-main.yaml | 1 + .github/workflows/rust-apply-patch.sh | 9 +++++++-- .github/workflows/rust-release-main.yaml | 1 + .github/workflows/vmware-apply-patch.sh | 9 +++++++-- .github/workflows/vmware-release-main.yaml | 1 + 19 files changed, 79 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cacerts-apply-patch.sh b/.github/workflows/cacerts-apply-patch.sh index 032e92af1d..d9b1bc74a3 100755 --- a/.github/workflows/cacerts-apply-patch.sh +++ b/.github/workflows/cacerts-apply-patch.sh @@ -6,13 +6,18 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "cacerts-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" # Parse the Manifest file for already present source files and keep the latest version in the current series VERSION_OLD=$(sed -n "s/^DIST nss-\([0-9]*\.[0-9]*\).*$/\1/p" app-misc/ca-certificates/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest ca-certificates, nothing to do" - exit 0 + echo "already the latest ca-certificates, nothing to do" + exit 0 fi EBUILD_FILENAME=$(get_ebuild_filename app-misc/ca-certificates "${VERSION_OLD}") diff --git a/.github/workflows/cacerts-release.yaml b/.github/workflows/cacerts-release.yaml index 9433fb0e8f..261aa04ac9 100644 --- a/.github/workflows/cacerts-release.yaml +++ b/.github/workflows/cacerts-release.yaml @@ -53,6 +53,7 @@ jobs: VERSION_NEW: ${{ steps.nss-latest-release.outputs.NSS_VERSION }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: ${{ steps.figure-out-branch.outputs.BRANCH }} run: gha/.github/workflows/cacerts-apply-patch.sh - name: Create pull request if: (steps.figure-out-branch.outputs.SKIP == 0) && (steps.apply-patch.outputs.UPDATE_NEEDED == 1) diff --git a/.github/workflows/common.sh b/.github/workflows/common.sh index d82f0d2016..87488103a6 100644 --- a/.github/workflows/common.sh +++ b/.github/workflows/common.sh @@ -64,6 +64,15 @@ function prepare_git_repo() { git -C "${SDK_OUTER_TOPDIR}" config user.email "${BUILDBOT_USEREMAIL}" } +function check_remote_branch() { + local target_branch="${1}" + + if git -C "${SDK_OUTER_TOPDIR}" show-ref "remotes/origin/${target_branch}"; then + return 1 + fi + return 0 +} + # Regenerates a manifest file using an ebuild of a given package with # a given version. # diff --git a/.github/workflows/containerd-apply-patch.sh b/.github/workflows/containerd-apply-patch.sh index f7e8f07f52..a3d152314e 100755 --- a/.github/workflows/containerd-apply-patch.sh +++ b/.github/workflows/containerd-apply-patch.sh @@ -6,12 +6,17 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "containerd-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" VERSION_OLD=$(sed -n "s/^DIST containerd-\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p" app-emulation/containerd/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Containerd, nothing to do" - exit 0 + echo "already the latest Containerd, nothing to do" + exit 0 fi # we need to update not only the main ebuild file, but also its CONTAINERD_COMMIT, diff --git a/.github/workflows/containerd-release-main.yaml b/.github/workflows/containerd-release-main.yaml index 394c7728aa..c4c790129d 100644 --- a/.github/workflows/containerd-release-main.yaml +++ b/.github/workflows/containerd-release-main.yaml @@ -35,6 +35,7 @@ jobs: COMMIT_HASH: ${{ steps.containerd-latest-release.outputs.COMMIT_HASH }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/containerd-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 diff --git a/.github/workflows/docker-apply-patch.sh b/.github/workflows/docker-apply-patch.sh index e5f38d5e09..a224099d48 100755 --- a/.github/workflows/docker-apply-patch.sh +++ b/.github/workflows/docker-apply-patch.sh @@ -6,12 +6,17 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "docker-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" VERSION_OLD=$(sed -n "s/^DIST docker-\([0-9]*.[0-9]*.[0-9]*\).*/\1/p" app-emulation/docker/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Docker, nothing to do" - exit 0 + echo "already the latest Docker, nothing to do" + exit 0 fi # we need to update not only the main ebuild file, but also its DOCKER_GITCOMMIT, diff --git a/.github/workflows/docker-release-main.yaml b/.github/workflows/docker-release-main.yaml index 9475ed6e08..84c0ef4fca 100644 --- a/.github/workflows/docker-release-main.yaml +++ b/.github/workflows/docker-release-main.yaml @@ -38,6 +38,7 @@ jobs: COMMIT_HASH_CLI: ${{ steps.docker-latest-release.outputs.COMMIT_HASH_CLI }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/docker-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 diff --git a/.github/workflows/firmware-apply-patch.sh b/.github/workflows/firmware-apply-patch.sh index 424d85a941..a448e79525 100755 --- a/.github/workflows/firmware-apply-patch.sh +++ b/.github/workflows/firmware-apply-patch.sh @@ -6,13 +6,18 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "firmware-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" # Parse the Manifest file for already present source files and keep the latest version in the current series VERSION_OLD=$(sed -n "s/^DIST linux-firmware-\([0-9]*\).*$/\1/p" sys-kernel/coreos-firmware/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Linux Firmware, nothing to do" - exit 0 + echo "already the latest Linux Firmware, nothing to do" + exit 0 fi EBUILD_FILENAME=$(get_ebuild_filename sys-kernel/coreos-firmware "${VERSION_OLD}") diff --git a/.github/workflows/firmware-release-main.yaml b/.github/workflows/firmware-release-main.yaml index 85932752f2..cb95e7b6a8 100644 --- a/.github/workflows/firmware-release-main.yaml +++ b/.github/workflows/firmware-release-main.yaml @@ -32,6 +32,7 @@ jobs: VERSION_NEW: ${{ steps.firmware-latest-release.outputs.VERSION_NEW }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/firmware-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 diff --git a/.github/workflows/go-apply-patch.sh b/.github/workflows/go-apply-patch.sh index f22dfd1b1f..affdb3e3bd 100755 --- a/.github/workflows/go-apply-patch.sh +++ b/.github/workflows/go-apply-patch.sh @@ -18,6 +18,11 @@ done branch_name="go-$(join_by '-and-' ${VERSIONS_NEW})-main" +if ! check_remote_branch "${branch_name}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + # Parse the Manifest file for already present source files and keep the latest version in the current series # DIST go1.17.src.tar.gz ... => 1.17 # DIST go1.17.1.src.tar.gz ... => 1.17.1 @@ -56,8 +61,8 @@ done cleanup_repo if [[ $any_different -eq 0 ]]; then - echo "go packages were already at the latest versions, nothing to do" - exit 0 + echo "go packages were already at the latest versions, nothing to do" + exit 0 fi vo_gh="$(join_by ' and ' "${UPDATED_VERSIONS_OLD[@]}")" diff --git a/.github/workflows/go-release-main.yaml b/.github/workflows/go-release-main.yaml index 53e99fda43..3ac78e88b6 100644 --- a/.github/workflows/go-release-main.yaml +++ b/.github/workflows/go-release-main.yaml @@ -33,6 +33,7 @@ jobs: VERSIONS_NEW: ${{ steps.go-latest-release.outputs.VERSIONS_NEW }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/go-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 diff --git a/.github/workflows/kernel-apply-patch.sh b/.github/workflows/kernel-apply-patch.sh index 282f0fffdc..560e8e7e98 100755 --- a/.github/workflows/kernel-apply-patch.sh +++ b/.github/workflows/kernel-apply-patch.sh @@ -6,6 +6,11 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "linux-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" # trim the 3rd part in the input semver, e.g. from 5.4.1 to 5.4 diff --git a/.github/workflows/kernel-release.yaml b/.github/workflows/kernel-release.yaml index 0b9f8d45e4..8029e4b500 100644 --- a/.github/workflows/kernel-release.yaml +++ b/.github/workflows/kernel-release.yaml @@ -54,6 +54,7 @@ jobs: VERSION_NEW: ${{ steps.kernel-latest-release.outputs.KERNEL_VERSION }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: ${{ steps.figure-out-branch.outputs.BRANCH }} run: gha/.github/workflows/kernel-apply-patch.sh - name: Create pull request if: (steps.figure-out-branch.outputs.SKIP == 0) && (steps.apply-patch.outputs.UPDATE_NEEDED == 1) diff --git a/.github/workflows/runc-apply-patch.sh b/.github/workflows/runc-apply-patch.sh index f89ef5cf57..40c1196281 100755 --- a/.github/workflows/runc-apply-patch.sh +++ b/.github/workflows/runc-apply-patch.sh @@ -6,6 +6,11 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "runc-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" # Get the newest runc version, including official releases and rc @@ -16,8 +21,8 @@ pushd "${SDK_OUTER_OVERLAY}" # "0.0.2.1" as newer than "0.0.2". VERSION_OLD=$(sed -n "s/^DIST docker-runc-\([0-9]*\.[0-9]*.*\)\.tar.*/\1_/p" app-emulation/docker-runc/Manifest | tr '.' '_' | sort -ruV | sed -e 's/_$//' | tr '_' '.' | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Runc, nothing to do" - exit 0 + echo "already the latest Runc, nothing to do" + exit 0 fi runcEbuildOld=$(get_ebuild_filename app-emulation/docker-runc "${VERSION_OLD}") diff --git a/.github/workflows/runc-release-main.yaml b/.github/workflows/runc-release-main.yaml index 16c37d9d5a..f674810b38 100644 --- a/.github/workflows/runc-release-main.yaml +++ b/.github/workflows/runc-release-main.yaml @@ -50,6 +50,7 @@ jobs: COMMIT_HASH: ${{ steps.runc-latest-release.outputs.COMMIT_HASH }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/runc-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 diff --git a/.github/workflows/rust-apply-patch.sh b/.github/workflows/rust-apply-patch.sh index 1b51ce6335..025e24bd96 100755 --- a/.github/workflows/rust-apply-patch.sh +++ b/.github/workflows/rust-apply-patch.sh @@ -6,12 +6,17 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "rust-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + pushd "${SDK_OUTER_OVERLAY}" VERSION_OLD=$(sed -n "s/^DIST rustc-\(1\.[0-9]*\.[0-9]*\).*/\1/p" dev-lang/rust/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest Rust, nothing to do" - exit 0 + echo "already the latest Rust, nothing to do" + exit 0 fi # Replace (dev-lang/virtual)/rust versions in profiles/, e.g. package.accept_keywords. diff --git a/.github/workflows/rust-release-main.yaml b/.github/workflows/rust-release-main.yaml index 892400525e..ecbf850392 100644 --- a/.github/workflows/rust-release-main.yaml +++ b/.github/workflows/rust-release-main.yaml @@ -32,6 +32,7 @@ jobs: VERSION_NEW: ${{ steps.rust-latest-release.outputs.VERSION_NEW }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/rust-apply-patch.sh - name: Create pull request for main id: create-pull-request diff --git a/.github/workflows/vmware-apply-patch.sh b/.github/workflows/vmware-apply-patch.sh index b9b1585552..2dcdf9e5bb 100755 --- a/.github/workflows/vmware-apply-patch.sh +++ b/.github/workflows/vmware-apply-patch.sh @@ -6,6 +6,11 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" prepare_git_repo +if ! check_remote_branch "open-vm-tools-${VERSION_NEW}-${TARGET_BRANCH}"; then + echo "remote branch already exists, nothing to do" + exit 0 +fi + # Update app-emulation/open-vm-tools pushd "${SDK_OUTER_OVERLAY}" @@ -13,8 +18,8 @@ pushd "${SDK_OUTER_OVERLAY}" # Parse the Manifest file for already present source files and keep the latest version in the current series VERSION_OLD=$(sed -n "s/^DIST open-vm-tools-\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p" app-emulation/open-vm-tools/Manifest | sort -ruV | head -n1) if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then - echo "already the latest open-vm-tools, nothing to do" - exit 0 + echo "already the latest open-vm-tools, nothing to do" + exit 0 fi EBUILD_FILENAME_OVT=$(get_ebuild_filename app-emulation/open-vm-tools "${VERSION_OLD}") diff --git a/.github/workflows/vmware-release-main.yaml b/.github/workflows/vmware-release-main.yaml index 1c3156b3b2..98e5edd2f7 100644 --- a/.github/workflows/vmware-release-main.yaml +++ b/.github/workflows/vmware-release-main.yaml @@ -35,6 +35,7 @@ jobs: VERSION_NEW: ${{ steps.openvmtools-latest-release.outputs.VERSION_NEW }} PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + TARGET_BRANCH: main run: scripts/.github/workflows/vmware-apply-patch.sh - name: Create pull request for main uses: peter-evans/create-pull-request@v5 From 425473f11d9c38d339176bbc724c0781a77efa70 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Tue, 2 May 2023 17:37:53 +0200 Subject: [PATCH 2/3] .github: add back ready_for_review In case of a draft PR created first, no CI gets triggered at the time. So we should trigger CI afterwards when it is being set to a ready_for_review state. --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e1e2efbed..a0c9f5f07f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,7 +2,7 @@ name: "Run build" on: pull_request: # Run when the PR is opened, reopened, or updated (synchronize) - types: [opened, reopened, synchronize] + types: [opened, ready_for_review, reopened, synchronize] workflow_dispatch: inputs: image_formats: From 0902d3cd642e0786a369c3b507a806d0dd3d1c81 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Wed, 3 May 2023 12:51:51 +0200 Subject: [PATCH 3/3] .github: add correct changelog Changelog directory is now located under flatcar scripts, not under coreos overlay. Fix the location to add correct changelog to the git commit. Also use a correct path SDK_OUTER_TOPDIR in cleanup_repo. --- .github/workflows/common.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/common.sh b/.github/workflows/common.sh index 87488103a6..56251400b3 100644 --- a/.github/workflows/common.sh +++ b/.github/workflows/common.sh @@ -173,12 +173,17 @@ function commit_changes() { regenerate_manifest "${pkg}" "${new_version}" - pushd "${SDK_OUTER_OVERLAY}" + pushd "${SDK_OUTER_TOPDIR}" - git add "${pkg}" if [[ -d changelog ]]; then git add changelog fi + + popd + + pushd "${SDK_OUTER_OVERLAY}" + + git add "${pkg}" for dir; do git add "${dir}" done @@ -193,7 +198,7 @@ function commit_changes() { # avoid unwanted changes to be a part of a PR created by the # peter-evans/create-pull-request action that follows up. function cleanup_repo() { - git -C "${SDK_OUTER_OVERLAY}" status - git -C "${SDK_OUTER_OVERLAY}" reset --hard HEAD - git -C "${SDK_OUTER_OVERLAY}" clean -ffdx + git -C "${SDK_OUTER_TOPDIR}" status + git -C "${SDK_OUTER_TOPDIR}" reset --hard HEAD + git -C "${SDK_OUTER_TOPDIR}" clean -ffdx }