Skip to content

Commit 9221c83

Browse files
GITHUB_USERNAMEGITHUB_USERNAME
authored andcommitted
Update pipelines to use assemblyline-service-pipeline-generator
1 parent 56b976a commit 9221c83

4 files changed

Lines changed: 64 additions & 127 deletions

File tree

pipelines/.cruft.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"template": "git@github.com:CybercentreCanada/assemblyline-service-pipeline-generator.git",
3+
"commit": "eb41868283c10b1a31746ebfd29b2c0e32c26025",
4+
"checkout": null,
5+
"context": {
6+
"cookiecutter": {
7+
"__directory_name": "pipelines",
8+
"classification": "UNCLASSIFIED",
9+
"is_public": true,
10+
"test_in_container": true,
11+
"test_versions": "default",
12+
"timeout": "default",
13+
"__setupscript": "setup.bash",
14+
"_extensions": [
15+
"local_extensions.extract_versions"
16+
],
17+
"_template": "git@github.com:CybercentreCanada/assemblyline-service-pipeline-generator.git"
18+
}
19+
},
20+
"directory": null
21+
}

pipelines/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setup.bash

pipelines/azure-build.yaml

Lines changed: 22 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@ name: build
22

33
variables:
44
- group: unittest-samples
5-
- name: self_location
6-
value: "self_location"
7-
- name: full_self_location
8-
value: "$(Agent.BuildDirectory)/$(self_location)"
9-
- name: samples_location
10-
value: "samples_location"
11-
- name: full_samples_location
12-
value: "$(Agent.BuildDirectory)/$(samples_location)"
13-
14-
resources:
15-
repositories:
16-
- repository: unittest-samples
17-
type: github
18-
name: $(unittest_samples_repository)
19-
ref: main
20-
endpoint: github-repo-sa
21-
trigger: none
225

236
trigger:
247
tags:
@@ -28,54 +11,26 @@ pr: none
2811
pool:
2912
vmImage: "ubuntu-20.04"
3013

31-
stages:
32-
- stage: deploy
33-
jobs:
34-
- job: deploy
35-
displayName: Deploy containers to dockerhub
36-
variables:
37-
- group: deployment-information
38-
steps:
39-
- task: Docker@2
40-
displayName: Login to docker hub
41-
inputs:
42-
command: login
43-
containerRegistry: dockerhub
44-
- task: Docker@2
45-
displayName: Login to chimera
46-
inputs:
47-
command: login
48-
containerRegistry: CHIMERA-U-ACR
49-
- checkout: self
50-
fetchDepth: 1
51-
path: $(self_location)
52-
- checkout: unittest-samples
53-
fetchDepth: 1
54-
path: $(samples_location)
55-
- script: |
56-
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
57-
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
58-
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 .
59-
workingDirectory: $(full_self_location)
60-
displayName: Build containers
61-
- script: |
62-
[ ! -d "$(pwd)/tests" ] && echo "No tests found" && exit
63-
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
64-
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
65-
[ -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
66-
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'
67-
workingDirectory: $(full_self_location)
68-
displayName: Test containers
69-
- script: |
70-
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
71-
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
72-
export SERIES="`expr $TAG : '\([0-9]\+\.[0-9]\+\.\)'`${BUILD_TYPE}"
14+
resources:
15+
repositories:
16+
- repository: PipelineTemplates
17+
type: github
18+
name: CybercentreCanada/assemblyline-pipeline-templates
19+
ref: refs/heads/main
20+
endpoint: github-repo-sa
21+
trigger: none
22+
- repository: unittest-samples
23+
type: github
24+
name: $(unittest_samples_repository)
25+
ref: main
26+
endpoint: github-repo-sa
27+
trigger: none
7328

74-
for IMAGE in "cccs/" "uchimera.azurecr.io/cccs/"
75-
do
76-
docker tag cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE ${IMAGE}${BUILD_REPOSITORY_NAME##*/}:$TAG
77-
docker tag cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE ${IMAGE}${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE
78-
docker tag cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE ${IMAGE}${BUILD_REPOSITORY_NAME##*/}:$SERIES
79-
docker push ${IMAGE}${BUILD_REPOSITORY_NAME##*/} --all-tags
80-
done
81-
displayName: Deploy to container repositories
29+
extends:
30+
template: stages/deploy-service.yaml@PipelineTemplates
31+
parameters:
32+
is_public: "true"
33+
samples_repo: unittest-samples
34+
labels:
35+
classification: "UNCLASSIFIED"
36+

pipelines/azure-tests.yaml

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,31 @@ name: tests
22

33
variables:
44
- group: unittest-samples
5-
- name: self_location
6-
value: "self_location"
7-
- name: full_self_location
8-
value: "$(Agent.BuildDirectory)/$(self_location)"
9-
- name: samples_location
10-
value: "samples_location"
11-
- name: full_samples_location
12-
value: "$(Agent.BuildDirectory)/$(samples_location)"
13-
14-
resources:
15-
repositories:
16-
- repository: unittest-samples
17-
type: github
18-
name: $(unittest_samples_repository)
19-
ref: main
20-
endpoint: github-repo-sa
21-
trigger: none
225

236
trigger: ["*"]
247
pr: ["*"]
258

269
pool:
2710
vmImage: "ubuntu-20.04"
2811

29-
jobs:
30-
- job: run_test
31-
strategy:
32-
matrix:
33-
Python3_9:
34-
python.version: "3.9"
35-
Python3_11:
36-
python.version: "3.11"
37-
Python3_12:
38-
python.version: "3.12"
39-
40-
timeoutInMinutes: 10
12+
resources:
13+
repositories:
14+
- repository: PipelineTemplates
15+
type: github
16+
name: CybercentreCanada/assemblyline-pipeline-templates
17+
ref: refs/heads/main
18+
endpoint: github-repo-sa
19+
trigger: none
20+
- repository: unittest-samples
21+
type: github
22+
name: $(unittest_samples_repository)
23+
ref: main
24+
endpoint: github-repo-sa
25+
trigger: none
4126

42-
steps:
43-
- task: UsePythonVersion@0
44-
displayName: Set python version
45-
inputs:
46-
versionSpec: "$(python.version)"
47-
- checkout: self
48-
fetchDepth: 1
49-
path: $(self_location)
50-
- checkout: unittest-samples
51-
fetchDepth: 1
52-
path: $(samples_location)
53-
- script: |
54-
[ ! -d "$(pwd)/tests" ] && echo "No tests found" && exit
55-
sudo apt-get update
56-
sudo apt-get install -y libfuzzy-dev libfuzzy2
57-
if [[ -f "$(pwd)/pkglist.txt" ]]; then
58-
grep -vE '^#' "$(pwd)/pkglist.txt" | xargs sudo apt install -y
59-
fi
60-
sudo rm -rf /var/lib/apt/lists/*
61-
sudo env "PATH=$PATH" python -m pip install -U --no-cache-dir assemblyline assemblyline_v4_service
62-
[ -f $(pwd)/requirements.txt ] && sudo env "PATH=$PATH" python -m pip install -U --no-cache-dir -r $(pwd)/requirements.txt
63-
[ -f $(pwd)/tests/requirements.txt ] && sudo env "PATH=$PATH" python -m pip install -U --no-cache-dir -r $(pwd)/tests/requirements.txt
64-
sudo rm -rf /tmp/* /var/lib/apt/lists/* ~/.cache/pip
65-
workingDirectory: $(full_self_location)
66-
displayName: Setup environment
67-
- script: |
68-
[ ! -d "$(pwd)/tests" ] && echo "No tests found" && exit
69-
export REPO_NAME=${BUILD_REPOSITORY_NAME##*/}
70-
python -m pytest -p no:cacheprovider --durations=10 -rsx -vv
71-
workingDirectory: $(full_self_location)
72-
displayName: Test
27+
extends:
28+
template: stages/test-service.yaml@PipelineTemplates
29+
parameters:
30+
samples_repo: unittest-samples
31+
test_container: "true"
32+

0 commit comments

Comments
 (0)