From 5c630f21b79bb3db50def5442c211a65d59a7dd7 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Sat, 5 Dec 2020 22:38:16 +0800 Subject: [PATCH 1/5] Add gh action for crossdock and crossdock otel ci jobs Signed-off-by: Ashmita Bohara --- .github/workflows/ci-crossdock.yml | 67 ++++++++++++++++++++++++++++++ scripts/travis/build-crossdock.sh | 10 ++--- 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci-crossdock.yml diff --git a/.github/workflows/ci-crossdock.yml b/.github/workflows/ci-crossdock.yml new file mode 100644 index 00000000000..9fd497f325d --- /dev/null +++ b/.github/workflows/ci-crossdock.yml @@ -0,0 +1,67 @@ +name: CIT Crossdock + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + crossdock: + runs-on: ubuntu-latest + strategy: + matrix: + steps: + - name: crossdock + cmd: bash scripts/travis/build-crossdock.sh + - name: crossdock-otel + cmd: make build-crossdock crossdock-otel + name: ${{ matrix.steps.name }} + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Fetch git tags + run: | + git fetch --prune --unshallow --tags + + - uses: actions/setup-go@v2 + with: + go-version: ^1.15 + + - uses: docker/login-action@v1 + id: dockerhub-login + with: + username: jaegertracingbot + password: ${{ secrets.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + if: env.DOCKERHUB_TOKEN != null + + - name: Export DOCKERHUB_LOGIN variable + run: | + echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV + if: steps.dockerhub-login.outcome == 'success' + + - name: Export BRANCH variable for pull_request event + run: | + export BRANCH=${GITHUB_HEAD_REF} + echo "we are on branch=$BRANCH" + echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + if: github.event_name == 'pull_request' + + - name: Export BRANCH variable for push event + run: | + echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV + if: github.event_name == 'push' + + - name: Install tools + run: make install-ci + + - name: Build, test, and publish ${{ matrix.steps.name }} image + run: ${{ matrix.steps.cmd }} + + - name: Output crossdock logs + run: make crossdock-logs + if: ${{ failure() }} diff --git a/scripts/travis/build-crossdock.sh b/scripts/travis/build-crossdock.sh index a605dd4de54..6045a589c15 100755 --- a/scripts/travis/build-crossdock.sh +++ b/scripts/travis/build-crossdock.sh @@ -1,21 +1,21 @@ #!/bin/bash -set -e +set -euxf -o pipefail BRANCH=${BRANCH:?'missing BRANCH env var'} +DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false} +COMMIT=${GITHUB_SHA::8} make build-and-run-crossdock -# Only push the docker container to Docker Hub for master branch -if [[ "$BRANCH" == "master" && "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then +# Only push the docker container to Docker Hub for master branch and when dockerhub login is done +if [[ "$BRANCH" == "master" && "$DOCKERHUB_LOGIN" == "true" ]]; then echo 'upload to Docker Hub' else echo 'skip docker upload for PR' exit 0 fi -set -x - # docker image has been build when running the crossdock export REPO=jaegertracing/test-driver docker tag $REPO:latest $REPO:$COMMIT From 48ca7837eb48b5c3af9cdcc1f2e2d3b8fac6000a Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Mon, 7 Dec 2020 00:20:45 +0800 Subject: [PATCH 2/5] Separate out BRANCH logic to separate action Signed-off-by: Ashmita Bohara --- .github/actions/setup-branch/action.yml | 17 +++++++++++++++++ .github/workflows/ci-crossdock.yml | 13 ++----------- 2 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 .github/actions/setup-branch/action.yml diff --git a/.github/actions/setup-branch/action.yml b/.github/actions/setup-branch/action.yml new file mode 100644 index 00000000000..60777f915e4 --- /dev/null +++ b/.github/actions/setup-branch/action.yml @@ -0,0 +1,17 @@ +name: 'Setup BRANCH' +description: 'Make BRANCH var accessible to job' +runs: + using: "composite" + steps: + - name: Setup BRANCH + run: | + case ${GITHUB_EVENT_NAME} in + pull_request) + BRANCH=${GITHUB_HEAD_REF} + ;; + push) + BRANCH=${GITHUB_REF##*/} + ;; + esac + echo "we are on branch=${BRANCH}" + echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV} diff --git a/.github/workflows/ci-crossdock.yml b/.github/workflows/ci-crossdock.yml index 9fd497f325d..2f6e38c0a96 100644 --- a/.github/workflows/ci-crossdock.yml +++ b/.github/workflows/ci-crossdock.yml @@ -44,17 +44,8 @@ jobs: echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable for pull_request event - run: | - export BRANCH=${GITHUB_HEAD_REF} - echo "we are on branch=$BRANCH" - echo "BRANCH=${BRANCH}" >> $GITHUB_ENV - if: github.event_name == 'pull_request' - - - name: Export BRANCH variable for push event - run: | - echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - if: github.event_name == 'push' + - name: Export BRANCH variable + uses: .github/actions/setup-branch - name: Install tools run: make install-ci From e93c2a805a0d528a0824208eaa499317f79b88d2 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Mon, 7 Dec 2020 00:22:25 +0800 Subject: [PATCH 3/5] Separate out BRANCH logic to separate action Signed-off-by: Ashmita Bohara --- .github/workflows/ci-crossdock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-crossdock.yml b/.github/workflows/ci-crossdock.yml index 2f6e38c0a96..7399eb92425 100644 --- a/.github/workflows/ci-crossdock.yml +++ b/.github/workflows/ci-crossdock.yml @@ -45,7 +45,7 @@ jobs: if: steps.dockerhub-login.outcome == 'success' - name: Export BRANCH variable - uses: .github/actions/setup-branch + uses: ./.github/actions/setup-branch - name: Install tools run: make install-ci From 24257abb547d2dfa103bdb43680db6cf23d6011d Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Mon, 7 Dec 2020 00:24:30 +0800 Subject: [PATCH 4/5] Separate out BRANCH logic to separate action Signed-off-by: Ashmita Bohara --- .github/actions/setup-branch/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-branch/action.yml b/.github/actions/setup-branch/action.yml index 60777f915e4..7dae9376873 100644 --- a/.github/actions/setup-branch/action.yml +++ b/.github/actions/setup-branch/action.yml @@ -4,6 +4,7 @@ runs: using: "composite" steps: - name: Setup BRANCH + shell: bash run: | case ${GITHUB_EVENT_NAME} in pull_request) From afc7766e79fa306b134ba9e7482611a3d3f7b7ca Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Mon, 7 Dec 2020 00:27:19 +0800 Subject: [PATCH 5/5] Separate out BRANCH logic to separate action Signed-off-by: Ashmita Bohara --- .github/workflows/ci-all-in-one-build.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-all-in-one-build.yml b/.github/workflows/ci-all-in-one-build.yml index 85c6c4669f8..d332701ac30 100644 --- a/.github/workflows/ci-all-in-one-build.yml +++ b/.github/workflows/ci-all-in-one-build.yml @@ -40,17 +40,8 @@ jobs: echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable for pull_request event - run: | - export BRANCH=${GITHUB_HEAD_REF} - echo "we are on branch=$BRANCH" - echo "BRANCH=${BRANCH}" >> $GITHUB_ENV - if: github.event_name == 'pull_request' - - - name: Export BRANCH variable for push event - run: | - echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - if: github.event_name == 'push' + - name: Export BRANCH variable + uses: ./.github/actions/setup-branch - name: Install tools run: make install-ci