-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Github workflows to run unit tests (#1)
There is a unit test workflow for gating pull requests. Then there is also a workflow that runs tests then builds/pushes to docker if the tests pass.
- Loading branch information
Showing
5 changed files
with
49 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,44 @@ | ||
name: Build and Push | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ main ] | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters