Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Add github action for crossdock tests (#297)
Browse files Browse the repository at this point in the history
* Add github action for crossdock

Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>

* Increase code coverage

Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
  • Loading branch information
Ashmita152 committed Dec 5, 2020
1 parent 923c455 commit 6bf76a1
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 16 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci-crossdock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CIT Crossdock

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
crossdock:
runs-on: ubuntu-latest
env:
TORNADO: ">=4,<5"
VIRTUAL_ENV: "github"
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/setup-python@v2
with:
python-version: 2.7

- 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 pycurl dependencies
run: sudo apt-get install libgnutls28-dev libcurl4-openssl-dev libssl-dev

- name: Install dependencies
run: make bootstrap

- name: Build crossdock
run: bash scripts/build-crossdock.sh

- name: Output crossdock logs
run: make crossdock-logs
if: ${{ failure() }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Tests
name: Unit Tests

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ master ]

jobs:
ci-tests:
unit-tests:
env:
VIRTUAL_ENV: github
runs-on: ubuntu-latest
Expand Down
29 changes: 15 additions & 14 deletions scripts/build-crossdock.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
#!/bin/bash

set -e
set -euxf -o pipefail

make crossdock

export REPO=jaegertracing/xdock-py
export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
export TAG=`if [ "$BRANCH" == "master" ]; then echo "latest"; else echo "${BRANCH///}"; fi`
export TORNADO=$TORNADO
echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, REPO=$REPO, PR=$PR, BRANCH=$BRANCH, TAG=$TAG, TORNADO=$TORNADO"
REPO=jaegertracing/xdock-py
BRANCH=${BRANCH:?'missing BRANCH env var'}
TORNADO=${TORNADO:?'missing TORNADO env var'}
TAG=$([ "$BRANCH" == "master" ] && echo "latest" || echo "$BRANCH")
COMMIT=${GITHUB_SHA::8}
DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false}

# Only push the docker container to Docker Hub for master branch
if [[ "$BRANCH" == "master" && "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then
echo "REPO=$REPO, BRANCH=$BRANCH, TAG=$TAG, TORNADO=$TORNADO, COMMIT=$COMMIT"

# Only push the docker container to dockerhub 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

docker login -u $DOCKER_USER -p $DOCKER_PASS

set -x

docker build --build-arg tornado=$TORNADO -f crossdock/Dockerfile -t $REPO:$COMMIT .
docker build -f crossdock/Dockerfile \
--build-arg tornado=$TORNADO \
--tag $REPO:$COMMIT .

docker tag $REPO:$COMMIT $REPO:$TAG
docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
docker tag $REPO:$COMMIT $REPO:gh-$GITHUB_RUN_NUMBER
docker push $REPO
8 changes: 8 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,17 @@ def test_initialize_tracer(self):

assert opentracing.global_tracer() == tracer

def test_initialize_tracer_twice(self):
c = Config({}, service_name='x')
tracer = c.initialize_tracer()
tracer = c.initialize_tracer()

assert tracer is None

def test_default_local_agent_reporting_port(self):
c = Config({}, service_name='x')
assert c.local_agent_reporting_port == 6831
assert c.local_agent_enabled is True

def test_generate_128bit_trace_id(self):
c = Config({}, service_name='x')
Expand Down

0 comments on commit 6bf76a1

Please sign in to comment.