diff mbox series

gitlab-ci: allow specifying base and tip in build test

Message ID 20190416072139.490-1-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show
Series gitlab-ci: allow specifying base and tip in build test | expand

Commit Message

Wei Liu April 16, 2019, 7:21 a.m. UTC
We will soon provide this new capability to humans and automated
systems.

The default behaviour is retained: tip and base are passed by Gitlab
CI.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 automation/gitlab-ci/build-each-commit.sh | 10 +++++-----
 automation/gitlab-ci/test.yaml            |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Wei Liu May 13, 2019, 2:17 p.m. UTC | #1
Doug, ping?

On Tue, Apr 16, 2019 at 08:21:39AM +0100, Wei Liu wrote:
> We will soon provide this new capability to humans and automated
> systems.
> 
> The default behaviour is retained: tip and base are passed by Gitlab
> CI.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  automation/gitlab-ci/build-each-commit.sh | 10 +++++-----
>  automation/gitlab-ci/test.yaml            |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/automation/gitlab-ci/build-each-commit.sh b/automation/gitlab-ci/build-each-commit.sh
> index 879028b5a7..19e337b468 100755
> --- a/automation/gitlab-ci/build-each-commit.sh
> +++ b/automation/gitlab-ci/build-each-commit.sh
> @@ -1,18 +1,18 @@
>  #!/bin/bash
>  
>  # For a newly pushed branch the BEFORE_SHA will be all 0s
> -if [[ ${CI_COMMIT_BEFORE_SHA} == 0000000000000000000000000000000000000000 ]]; then
> +if [[ ${BASE} == 0000000000000000000000000000000000000000 ]]; then
>      echo "Newly pushed branch, skipped"
>      exit 0
>  fi
>  
> -git merge-base --is-ancestor ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA}
> +git merge-base --is-ancestor ${BASE} ${TIP}
>  if [[ $? -ne 0 ]]; then
> -    echo "${CI_COMMIT_SHA} is not a descendent of ${CI_COMMIT_BEFORE_SHA}, skipped"
> +    echo "${TIP} is not a descendent of ${BASE}, skipped"
>      exit 0
>  fi
>  
> -echo "Building ${CI_COMMIT_BEFORE_SHA}..${CI_COMMIT_SHA}"
> +echo "Building ${BASE}..${TIP}"
>  
> -NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA} \
> +NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${BASE} ${TIP} \
>      bash -c "git clean -ffdx && ./automation/scripts/build"
> diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
> index d4556afe11..a795866673 100644
> --- a/automation/gitlab-ci/test.yaml
> +++ b/automation/gitlab-ci/test.yaml
> @@ -7,7 +7,7 @@ build-each-commit-gcc:
>      XEN_TARGET_ARCH: x86_64
>      CC: gcc
>    script:
> -    - ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
> +    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
>    artifacts:
>      paths:
>        - '*.log'
> -- 
> 2.20.1
>
Douglas Goldstein May 14, 2019, 5:50 p.m. UTC | #2
On Tue, Apr 16, 2019 at 08:21:39AM +0100, Wei Liu wrote:
> We will soon provide this new capability to humans and automated
> systems.
> 
> The default behaviour is retained: tip and base are passed by Gitlab
> CI.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Swore I replied to this already. I apologize.

Acked-by: Doug Goldstein <cardoe@cardoe.com>
diff mbox series

Patch

diff --git a/automation/gitlab-ci/build-each-commit.sh b/automation/gitlab-ci/build-each-commit.sh
index 879028b5a7..19e337b468 100755
--- a/automation/gitlab-ci/build-each-commit.sh
+++ b/automation/gitlab-ci/build-each-commit.sh
@@ -1,18 +1,18 @@ 
 #!/bin/bash
 
 # For a newly pushed branch the BEFORE_SHA will be all 0s
-if [[ ${CI_COMMIT_BEFORE_SHA} == 0000000000000000000000000000000000000000 ]]; then
+if [[ ${BASE} == 0000000000000000000000000000000000000000 ]]; then
     echo "Newly pushed branch, skipped"
     exit 0
 fi
 
-git merge-base --is-ancestor ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA}
+git merge-base --is-ancestor ${BASE} ${TIP}
 if [[ $? -ne 0 ]]; then
-    echo "${CI_COMMIT_SHA} is not a descendent of ${CI_COMMIT_BEFORE_SHA}, skipped"
+    echo "${TIP} is not a descendent of ${BASE}, skipped"
     exit 0
 fi
 
-echo "Building ${CI_COMMIT_BEFORE_SHA}..${CI_COMMIT_SHA}"
+echo "Building ${BASE}..${TIP}"
 
-NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA} \
+NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${BASE} ${TIP} \
     bash -c "git clean -ffdx && ./automation/scripts/build"
diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
index d4556afe11..a795866673 100644
--- a/automation/gitlab-ci/test.yaml
+++ b/automation/gitlab-ci/test.yaml
@@ -7,7 +7,7 @@  build-each-commit-gcc:
     XEN_TARGET_ARCH: x86_64
     CC: gcc
   script:
-    - ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
+    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
   artifacts:
     paths:
       - '*.log'