Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Github workflows to run unit tests #1

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/install-etcd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Fail on any error
set -e

ETCD_VERSION=v3.5.0
INSTALL_DIR="/usr/local/bin"

wget -q https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz
mkdir -p ${INSTALL_DIR}
tar xzf etcd-*-linux-amd64.tar.gz -C ${INSTALL_DIR} --strip-components=1
rm -rf etcd*.gz
41 changes: 24 additions & 17 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
name: Build and Push

on:
pull_request:
push:
branches: [ main ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include pull request merge to trigger this workflow? Not sure it is covered by push.

types: [closed]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Install etcd
run: sudo ./.github/install-etcd.sh
- name: Build with Maven
run: mvn -B package --file pom.xml
build:
if: github.event.pull_request.merged == true
needs: test
runs-on: ubuntu-latest

env:
IMAGE_NAME: kserve/modelmesh
IMAGE_TAG: latest
steps:
- uses: actions/checkout@v2
- name: Build runtime image
- name: Build runtime image
run: |
GIT_COMMIT=$(git rev-parse HEAD)
BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)
IMAGE_TAG=main_${BUILD_ID}
BASE_IMAGE_TAG=$(cat BASE_IMAGE_TAG | awk -F= '{print $2}')

docker build -t modelmesh:${IMAGE_TAG} \
docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
--build-arg imageVersion=${IMAGE_TAG} \
--build-arg buildId=${BUILD_ID} \
--build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} \
--build-arg commitSha=${GIT_COMMIT} .

- name: Log in to docker hub
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Push to docker hub
- name: Push to Docker Hub
run: |
IMAGE_NAME=modelmesh
IMAGE_ID=kserve/$IMAGE_NAME
IMAGE_VERSION=latest

docker push $IMAGE_ID:$IMAGE_VERSION
docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
29 changes: 11 additions & 18 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
name: Unit Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main ]

jobs:
build:

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build and test
run: |
GIT_COMMIT=$(git rev-parse HEAD)
BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)
IMAGE_TAG=main_${BUILD_ID}
BASE_IMAGE_TAG=$(cat BASE_IMAGE_TAG | awk -F= '{print $2}')

docker build -t modelmesh:${IMAGE_TAG} \
--build-arg imageVersion=${IMAGE_TAG} \
--build-arg buildId=${BUILD_ID} \
--build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} \
--build-arg commitSha=${GIT_COMMIT} .
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Install etcd
run: sudo ./.github/install-etcd.sh
- name: Build with Maven
run: mvn -B package --file pom.xml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ LABEL image="build"

COPY / /build

RUN mvn -Dmaven.repo.local=repo -DskipTests=true -B clean install
RUN mvn -B package -DskipTests=true --file pom.xml

###############################################################################
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,6 @@ public static int getPID(Process process) throws Exception {

public static int killProcess(Process process) throws Exception {
int pid = getPID(process);
return Runtime.getRuntime().exec("command kill -9 " + pid).waitFor();
return Runtime.getRuntime().exec("kill -9 " + pid).waitFor();
}
}