Skip to content

Commit

Permalink
Adding generic build pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-kevin committed Mar 29, 2022
1 parent 1ce452d commit e7c361b
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions pipelines/azure-build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
name: build

variables:
- group: unittest-samples
- name: self_location
value: "self_location"
- name: full_self_location
value: "$(Agent.BuildDirectory)/$(self_location)"
- name: samples_location
value: "samples_location"
- name: full_samples_location
value: "$(Agent.BuildDirectory)/$(samples_location)"

resources:
repositories:
- repository: unittest-samples
type: github
name: $(unittest_samples_repository)
ref: main
endpoint: github-repo-sa
trigger: none

trigger:
tags:
include: ["v*"]
Expand All @@ -21,10 +41,25 @@ stages:
inputs:
command: login
containerRegistry: dockerhub
- checkout: self
fetchDepth: 1
path: $(self_location)
- checkout: unittest-samples
fetchDepth: 1
path: $(samples_location)
- script: |
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
docker build --build-arg version=$TAG --build-arg branch=$BUILD_TYPE -t cccs/${BUILD_REPOSITORY_NAME##*/}:$TAG -t cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE -f ./Dockerfile .
workingDirectory: $(full_self_location)
displayName: Build containers
- script: |
set -xv # Echo commands before they are run
[ ! -d "$(pwd)/tests" ] && echo "No tests found" && exit
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
docker build --build-arg version=$TAG --build-arg branch=$BUILD_TYPE -t cccs/assemblyline-service-jsjaws:$TAG -t cccs/assemblyline-service-jsjaws:$BUILD_TYPE .
docker push cccs/assemblyline-service-jsjaws --all-tags
[ -f "$(pwd)/tests/requirements.txt" ] && docker run -e FULL_SELF_LOCATION=/opt/al_service -e FULL_SAMPLES_LOCATION=/opt/samples -v /usr/share/ca-certificates/mozilla:/usr/share/ca-certificates/mozilla -v $(pwd)/tests/:/opt/al_service/tests/ -v ${FULL_SAMPLES_LOCATION}:/opt/samples cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE bash -c 'pip install -U -r tests/requirements.txt; pytest -p no:cacheprovider -vv' && exit
docker run -e FULL_SELF_LOCATION=/opt/al_service -e FULL_SAMPLES_LOCATION=/opt/samples -v /usr/share/ca-certificates/mozilla:/usr/share/ca-certificates/mozilla -v $(pwd)/tests/:/opt/al_service/tests/ -v ${FULL_SAMPLES_LOCATION}:/opt/samples cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE bash -c 'pytest -p no:cacheprovider -vv'
workingDirectory: $(full_self_location)
displayName: Test containers
- script: docker push cccs/${BUILD_REPOSITORY_NAME##*/} --all-tags
displayName: Deploy to Docker Hub

0 comments on commit e7c361b

Please sign in to comment.