From 7ead24b609a52e083bf7731dc21388093adc062a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 18 Mar 2021 21:14:29 +0000 Subject: [PATCH 1/3] Update .mergify.yml --- .mergify.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.mergify.yml b/.mergify.yml index 99076ea62..5d4dbaf2c 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,4 +1,18 @@ pull_request_rules: + - name: ask to resolve conflict + conditions: + - conflict + actions: + comment: + message: | + This pull request is now in conflicts. Could you fix it @{{author}}? 🙏 + To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/ + ``` + git fetch upstream + git checkout -b {{head}} upstream/{{head}} + git merge upstream/{{base}} + git push upstream {{head}} + ``` - name: Automatic squash and merge on approval with success checks and ready-to-merge label conditions: - "#approved-reviews-by>=2" From d440fcc1d89e2b2c682d33c30d8982313922e58c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 6 Apr 2021 12:12:03 +0100 Subject: [PATCH 2/3] Disable unique ephemeral worker by default --- src/test/groovy/WithNodeStepTests.groovy | 29 +++++++++++++++++++++++- vars/README.md | 10 ++++---- vars/withNode.groovy | 8 +++++-- vars/withNode.txt | 5 ++-- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/test/groovy/WithNodeStepTests.groovy b/src/test/groovy/WithNodeStepTests.groovy index bf7c02f2a..b53a3a11b 100644 --- a/src/test/groovy/WithNodeStepTests.groovy +++ b/src/test/groovy/WithNodeStepTests.groovy @@ -47,7 +47,7 @@ class WithNodeStepTests extends ApmBasePipelineTest { } printCallStack() assertTrue(isOK) - assertTrue(assertMethodCallContainsPattern('node', 'foo && extra/')) + assertFalse(assertMethodCallContainsPattern('node', 'foo && extra/')) assertTrue(assertMethodCallOccurrences('ws', 0)) assertJobStatusSuccess() } @@ -67,6 +67,33 @@ class WithNodeStepTests extends ApmBasePipelineTest { assertJobStatusSuccess() } + @Test + void test_with_forced_worker() throws Exception { + helper.registerAllowedMethod('isStaticWorker', [Map.class], { return false }) + def isOK = false + script.call(labels: 'foo', forceWorker: true) { + isOK = true + } + printCallStack() + assertTrue(isOK) + assertTrue(assertMethodCallContainsPattern('node', 'foo && extra/')) + assertJobStatusSuccess() + } + + @Test + void test_with_forced_static_worker() throws Exception { + helper.registerAllowedMethod('isStaticWorker', [Map.class], { return true }) + def isOK = false + script.call(labels: 'arm', forceWorker: true) { + isOK = true + } + printCallStack() + assertTrue(isOK) + assertTrue(assertMethodCallContainsPattern('node', 'arm')) + assertFalse(assertMethodCallContainsPattern('node', 'extra/')) + assertJobStatusSuccess() + } + @Test void test_with_forced_workspace() throws Exception { helper.registerAllowedMethod('isStaticWorker', [ Map.class ], { return false }) diff --git a/vars/README.md b/vars/README.md index 559909b3a..6a6e6483e 100644 --- a/vars/README.md +++ b/vars/README.md @@ -1315,8 +1315,8 @@ Wrapper to interact with the gsutil command line. It returns the stdout output. Check if the author of a GitHub comment has admin or write permissions in the repository. ``` -if(!hasCommentAuthorWritePermissions(repoName: "elastic/beats", commentId: env.GT_COMMENT_ID)){ - error("Only Elasticians can do this action.") +if(!hasCommentAuthorWritePermissions(repoName: "elastic/kibana", commentId: env.GT_COMMENT_ID)){ + error("Only Elasticians can deploy Docker images") } ``` @@ -2917,7 +2917,7 @@ Wrap the node call for three reasons: } // Use ephemeral worker with a sleep of up to 100 seconds and with a specific workspace. - withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true){ + withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true, forceWorker: true){ // block } ``` @@ -2925,7 +2925,8 @@ Wrap the node call for three reasons: * labels: what's the labels to be used. Mandatory * sleepMin: whether to sleep and for how long at least. Optional. * sleepMax: whether to sleep and for how long maximum. Optional. -* forceWorkspace: whether to allocate a new unique workspace. Optional. +* forceWorker: whether to allocate a new unique ephemeral worker. Optional. Default false +* forceWorkspace: whether to allocate a new unique workspace. Optional. Default false ## withNpmrc Wrap the npmrc token @@ -3015,3 +3016,4 @@ writeVaultSecret(secret: 'secret/apm-team/ci/temp/github-comment', data: ['secre * secret: Name of the secret on the the vault root path. Mandatory * data: What's the data to be written. Mandatory + diff --git a/vars/withNode.groovy b/vars/withNode.groovy index e5c5a2ebb..43319568b 100644 --- a/vars/withNode.groovy +++ b/vars/withNode.groovy @@ -27,7 +27,7 @@ Wrap the node call for three reasons: } // Use ephemeral worker with a sleep of up to 100 seconds and with a specific workspace. - withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true){ + withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true, forceWorker: true){ ... } */ @@ -36,13 +36,17 @@ def call(Map args = [:], Closure body) { def sleepMax = args.get('sleepMax', 0) def labels = args.containsKey('labels') ? args.labels : error('withNode: labels parameter is required.') def forceWorkspace = args.get('forceWorkspace', false) + def forceWorker = args.get('forceWorker', false) def uuid = UUID.randomUUID().toString() // Sleep to smooth the ram up with the provisioner sleep(randomNumber(min: sleepMin, max: sleepMax)) // In case of ephemeral workers then use the uuid - def newLabels = isStaticWorker(labels: labels) ? labels : (labels?.trim() ? "${labels} && extra/${uuid}" : "extra/${uuid}") + def newLabels = labels + if (forceWorker) { + newLabels = isStaticWorker(labels: labels) ? labels : (labels?.trim() ? "${labels} && extra/${uuid}" : "extra/${uuid}") + } log(level: 'INFO', text: "Allocating a worker with the labels '${newLabels}'.") node("${newLabels}") { diff --git a/vars/withNode.txt b/vars/withNode.txt index b88e7962c..4e6e6c7ef 100644 --- a/vars/withNode.txt +++ b/vars/withNode.txt @@ -11,7 +11,7 @@ Wrap the node call for three reasons: } // Use ephemeral worker with a sleep of up to 100 seconds and with a specific workspace. - withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true){ + withNode(labels: 'immutable && ubuntu-18', sleepMax: 100, forceWorspace: true, forceWorker: true){ // block } ``` @@ -19,4 +19,5 @@ Wrap the node call for three reasons: * labels: what's the labels to be used. Mandatory * sleepMin: whether to sleep and for how long at least. Optional. * sleepMax: whether to sleep and for how long maximum. Optional. -* forceWorkspace: whether to allocate a new unique workspace. Optional. +* forceWorker: whether to allocate a new unique ephemeral worker. Optional. Default false +* forceWorkspace: whether to allocate a new unique workspace. Optional. Default false From 543a43db1cbb66c6102a8907d23fa46af15e19c7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 6 Apr 2021 12:14:02 +0100 Subject: [PATCH 3/3] Revert "Update .mergify.yml" This reverts commit 7ead24b609a52e083bf7731dc21388093adc062a. --- .mergify.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 984017466..d02925c87 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,18 +1,4 @@ pull_request_rules: - - name: ask to resolve conflict - conditions: - - conflict - actions: - comment: - message: | - This pull request is now in conflicts. Could you fix it @{{author}}? 🙏 - To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/ - ``` - git fetch upstream - git checkout -b {{head}} upstream/{{head}} - git merge upstream/{{base}} - git push upstream {{head}} - ``` - name: Automatic squash and merge on approval with success checks and ready-to-merge label conditions: - "#approved-reviews-by>=2"