From 18606d296bec5822c2cb1b81b96870a8259a986a Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Wed, 8 Nov 2023 08:03:14 +0100 Subject: [PATCH 1/5] .murdock: adapt bors to merge queue (cherry picked from commit 1e7f488448d7a0a214e17b6202b472563787e7cd) --- .murdock | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.murdock b/.murdock index 321c1d150fba..d1147e33a900 100755 --- a/.murdock +++ b/.murdock @@ -178,19 +178,27 @@ check_label() { return $? } -# this function returns 0 when this is build is building one of the two bors -# branches ("staging" or "trying", 1 otherwise. -is_bors_build() { - test "${CI_BUILD_BRANCH}" = "staging" || test "${CI_BUILD_BRANCH}" = "trying" +# true if "$2" starts with "$1", false otherwise +startswith() { + case "${2}" in + ${1}*) true ;; + *) false ;; + esac +} + +# this function returns 0 when this is build is building one of the two merge +# queue branches ("staging" or "trying", 1 otherwise. +is_merge_queue_build() { + startswith "gh-readonly-queue/" "${CI_BUILD_BRANCH}" } -# Set CI_BASE_COMMIT in case of a bors build. -# This assumes that bors always adds a single merge commit (possibly itself +# Set CI_BASE_COMMIT in case of a merge queue build. +# This assumes that merge queue always adds a single merge commit (possibly itself # including multiple merges for PRs) on the base branch. # That git command outputs the hash of the second merge commit (the one before # the topmost merge), which should be the base branch HEAD. # (CI_BASE_COMMIT is used by `can_fast_ci_run.py` to only build changes.) -if test -z "${CI_BASE_COMMIT}" && is_bors_build ; then +if test -z "${CI_BASE_COMMIT}" && is_merge_queue_build; then previous_merge="$(git log --merges --max-count 1 --skip 1 --pretty=format:%H)" export CI_BASE_COMMIT="${previous_merge}" fi @@ -216,8 +224,8 @@ fi # configurations. if [ -z "${QUICK_BUILD}" ]; then export QUICK_BUILD=0 - if is_bors_build ; then - # always do full build for bors' branches + if is_merge_queue_build; then + # always do full build for merge queue' branches true elif [ ${FULL_BUILD} -eq 1 ]; then # full build if building nightly or full build requested by label @@ -323,14 +331,6 @@ error() { exit 1 } -# true if "$2" starts with "$1", false otherwise -startswith() { - case "${2}" in - ${1}*) true ;; - *) false ;; - esac -} - # if MURDOCK_HOOK is set, this function will execute it and pass on all it's # parameters. should the hook script exit with negative exit code, hook() makes # this script exit with error, too. From ef40feec9e9e66ac8a2b03a89997c5b9d97562fd Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Wed, 8 Nov 2023 11:31:07 +0100 Subject: [PATCH 2/5] .github/workflows/*: Allow merge_groups and prs to be required (cherry picked from commit d41e368bf7895785ce748c4e940103fd7922f4c5) --- .github/workflows/check-commits.yml | 9 +++++++++ .github/workflows/check-labels.yml | 3 +++ .github/workflows/labeler.yml | 2 ++ .github/workflows/static-test.yml | 1 + .github/workflows/tools-buildtest.yml | 1 + .github/workflows/tools-test.yml | 2 ++ 6 files changed, 18 insertions(+) diff --git a/.github/workflows/check-commits.yml b/.github/workflows/check-commits.yml index d294f3783648..c4d15bacf70a 100644 --- a/.github/workflows/check-commits.yml +++ b/.github/workflows/check-commits.yml @@ -2,6 +2,8 @@ name: check-commits on: pull_request: types: [opened, reopened, synchronize] + merge_group: + jobs: check-commits: runs-on: ubuntu-latest @@ -24,3 +26,10 @@ jobs: - name: Run checks run: | ./dist/tools/${{ matrix.check }}/check.sh "${{ github.base_ref }}" + check-commits-success: + needs: check-commits + if: github.event_name != 'merge_group' + runs-on: ubuntu-latest + steps: + - name: check-commits succeeded + run: exit 0 diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index 0639b4c97c5f..167ab44c583e 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -4,8 +4,11 @@ on: types: [opened, reopened, labeled, unlabeled, synchronize] pull_request_review: types: [submitted, dismissed] + merge_group: + jobs: check-labels: + if: github.event_name != 'merge_group' runs-on: ubuntu-latest steps: - uses: RIOT-OS/check-labels-action@v1.1.1 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 052328779520..7b4efd24fd03 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -3,10 +3,12 @@ name: pr-labeler on: pull_request_target: types: [opened, synchronize, reopened] + merge_group: jobs: triage: runs-on: ubuntu-latest + if: github.event_name != 'merge_group' steps: - uses: actions/labeler@main with: diff --git a/.github/workflows/static-test.yml b/.github/workflows/static-test.yml index 81b2a517860e..c9f10c6fa89d 100644 --- a/.github/workflows/static-test.yml +++ b/.github/workflows/static-test.yml @@ -13,6 +13,7 @@ on: pull_request: branches: - '*' + merge_group: jobs: static-tests: diff --git a/.github/workflows/tools-buildtest.yml b/.github/workflows/tools-buildtest.yml index 35bc9e8dded2..d16a3481a2d8 100644 --- a/.github/workflows/tools-buildtest.yml +++ b/.github/workflows/tools-buildtest.yml @@ -11,6 +11,7 @@ on: pull_request: branches: - '*' + merge_group: jobs: tools-build: diff --git a/.github/workflows/tools-test.yml b/.github/workflows/tools-test.yml index 8f6226de8136..5d5f4fe82c37 100644 --- a/.github/workflows/tools-test.yml +++ b/.github/workflows/tools-test.yml @@ -9,9 +9,11 @@ on: pull_request: branches: - '*' + merge_group: jobs: python-tests: + if: github.event_name != 'merge_group' runs-on: ubuntu-latest steps: - uses: actions/checkout@main From bb6601cf96290d05c02ea7cb6a51d76ef90ed19d Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 8 Nov 2023 13:23:51 +0100 Subject: [PATCH 3/5] ci: workflows: static-test: fix CI_BASE_BRANCH for merge_groups (cherry picked from commit f849816686192e9d42d749e726b938a2b6fd08fb) --- .github/workflows/static-test.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/static-test.yml b/.github/workflows/static-test.yml index c9f10c6fa89d..65b4030df053 100644 --- a/.github/workflows/static-test.yml +++ b/.github/workflows/static-test.yml @@ -22,11 +22,18 @@ jobs: - uses: actions/checkout@main with: fetch-depth: 0 + - name: set CI_BASE_BRANCH + run: | + if [ -n "${{ github.base_ref }}" ]; then + echo "CI_BASE_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV + elif [ -n "${{ github.event.merge_group.base_ref }}" ]; then + echo "CI_BASE_BRANCH=${{ github.event.merge_group.base_ref }}" | sed s.=refs/heads/.=. >> $GITHUB_ENV + fi - name: Setup git run: | - # Note: ${{ github.base_ref }} is empty when not in a PR - if [ -n "${{ github.base_ref }}" ]; then - git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} --no-tags + # Note: CI_BASE_BRANCH is empty when not in a PR + if [ -n "${CI_BASE_BRANCH}" ]; then + git fetch origin ${CI_BASE_BRANCH}:${CI_BASE_BRANCH} --no-tags else git config diff.renameLimit 16384 fi @@ -35,9 +42,9 @@ jobs: run: docker pull riot/static-test-tools:latest - name: Run static-tests run: | - # Note: ${{ github.base_ref }} is empty when not in a PR + # Note: ${CI_BASE_BRANCH} is empty when not in a PR docker run --rm \ - -e CI_BASE_BRANCH=${{ github.base_ref }} \ + -e CI_BASE_BRANCH \ -e GITHUB_RUN_ID=${GITHUB_RUN_ID} \ -v $(pwd):/data/riotbuild \ riot/static-test-tools:latest \ From db28eca302886ca125c7579cfa37ccfe63ee898e Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 9 Nov 2023 09:28:15 +0100 Subject: [PATCH 4/5] .murdock: drop bors CI_BASE_BRANCH logic (cherry picked from commit a6c2bb8ecf90cb4fc9dac6ba192682782233bf99) --- .murdock | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.murdock b/.murdock index d1147e33a900..3484193e32ae 100755 --- a/.murdock +++ b/.murdock @@ -192,17 +192,6 @@ is_merge_queue_build() { startswith "gh-readonly-queue/" "${CI_BUILD_BRANCH}" } -# Set CI_BASE_COMMIT in case of a merge queue build. -# This assumes that merge queue always adds a single merge commit (possibly itself -# including multiple merges for PRs) on the base branch. -# That git command outputs the hash of the second merge commit (the one before -# the topmost merge), which should be the base branch HEAD. -# (CI_BASE_COMMIT is used by `can_fast_ci_run.py` to only build changes.) -if test -z "${CI_BASE_COMMIT}" && is_merge_queue_build; then - previous_merge="$(git log --merges --max-count 1 --skip 1 --pretty=format:%H)" - export CI_BASE_COMMIT="${previous_merge}" -fi - # fullbuild logic # non-full-builds are those where can_fast_ci_run might reduce the build # automatically From 5bde3d28e0d741c45025d4329ab6bde30662da1a Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 9 Nov 2023 13:29:52 +0100 Subject: [PATCH 5/5] .murdock: clarify `is_merge_queue_build()` help text (cherry picked from commit 282c77c84c05b31413c7d61f599a5218e7633401) --- .murdock | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.murdock b/.murdock index 3484193e32ae..b625b96ddc8c 100755 --- a/.murdock +++ b/.murdock @@ -186,8 +186,7 @@ startswith() { esac } -# this function returns 0 when this is build is building one of the two merge -# queue branches ("staging" or "trying", 1 otherwise. +# this function returns 0 when this build is building a merge queue branch. is_merge_queue_build() { startswith "gh-readonly-queue/" "${CI_BUILD_BRANCH}" }