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

Commit

Permalink
Add unit tests and crossdock in github actions (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashmita152 authored Mar 21, 2021
1 parent 2be525b commit 6b314cd
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 29 deletions.
18 changes: 18 additions & 0 deletions .github/actions/setup-branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Setup BRANCH'
description: 'Make BRANCH var accessible to job'
runs:
using: "composite"
steps:
- name: Setup BRANCH
shell: bash
run: |
case ${GITHUB_EVENT_NAME} in
pull_request)
BRANCH=${GITHUB_HEAD_REF}
;;
push | release)
BRANCH=${GITHUB_REF##*/}
;;
esac
echo "we are on branch=${BRANCH}"
echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
48 changes: 48 additions & 0 deletions .github/workflows/ci-crossdock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Crossdock

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

jobs:
crossdock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/setup-java@v1
with:
java-version: 8

- 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
uses: ./.github/actions/setup-branch

- name: Run Crossdock
id: run-crossdock
run: make crossdock-fresh

- name: Output Crossdock Logs
run: make crossdock-logs
if: ${{ failure() }}

- name: Publish Crossdock Image
run: bash scripts/publish-crossdock.sh
if: steps.run-crossdock.outcome == 'success'
31 changes: 31 additions & 0 deletions .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unit Tests

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

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/setup-java@v1
with:
java-version: 8

- name: Run unit tests
run: make test-ci

- name: Generate codecov report
run: ./gradlew codeCoverageReport

- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
verbose: true
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ clean:
test:
$(GRADLE) check

.PHONY: test-travis
test-travis:
.PHONY: test-ci
test-ci:
$(GRADLE) -is check

.PHONY: release
Expand Down
2 changes: 1 addition & 1 deletion jaeger-crossdock/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8u121-jdk-alpine
FROM openjdk:8-jdk-alpine
EXPOSE 8080-8082

ADD build/libs/jaeger-crossdock.jar /
Expand Down
2 changes: 1 addition & 1 deletion jaeger-thrift/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
}

compileThrift {
thriftExecutable "${projectDir}/../travis/docker-thrift/thrift"
thriftExecutable "${projectDir}/../scripts/docker-thrift/thrift"
sourceDir "${projectDir}/../idl/thrift"
outputDir 'src/main/gen-java'
generator 'java', 'private-members'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions travis/prepare-signing.sh → scripts/prepare-signing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ if [ "x${ENCRYPTION_IV}" == "x" ]; then
fi

if [ "${TRAVIS_SECURE_ENV_VARS}" == true ]; then
openssl aes-256-cbc -K "${ENCRYPTION_KEY}" -iv "${ENCRYPTION_IV}" -in travis/signing-key.asc.enc -out travis/signing-key.asc -d
openssl aes-256-cbc -K "${ENCRYPTION_KEY}" -iv "${ENCRYPTION_IV}" -in scripts/signing-key.asc.enc -out scripts/signing-key.asc -d
if (( $? != 0 )); then
echo "Failed to decrypt the signing key. Skipping."
exit 1
fi

gpg --no-tty --batch --allow-secret-key-import --import travis/signing-key.asc
gpg --no-tty --batch --allow-secret-key-import --import scripts/signing-key.asc
rm -rf "$HOME/.gradle/gradle.properties"
echo signing.keyId="${SIGNING_KEY_ID}" > "$HOME/.gradle/gradle.properties"
echo signing.password="${SIGNING_KEY_PASSPHRASE}" >> "$HOME/.gradle/gradle.properties"
Expand Down
28 changes: 28 additions & 0 deletions scripts/publish-crossdock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -euxf -o pipefail

REPO=jaegertracing/xdock-java
BRANCH=${BRANCH:?'missing BRANCH env var'}
TAG=$([ "$BRANCH" == "master" ] && echo "latest" || echo "$BRANCH")
COMMIT=${GITHUB_SHA::8}
DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false}

echo "REPO=$REPO, BRANCH=$BRANCH, TAG=$TAG, 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

./gradlew shadowJar

pushd 'jaeger-crossdock'
docker build -f Dockerfile -t $REPO:$COMMIT .
popd

docker tag $REPO:$COMMIT $REPO:$TAG
docker push $REPO
File renamed without changes.
23 changes: 0 additions & 23 deletions travis/publish-crossdock.sh

This file was deleted.

0 comments on commit 6b314cd

Please sign in to comment.