Newer
Older

Andrew Kapuscinski
committed
- build
- unit-test

Andrew Kapuscinski
committed
- push

Andrew Kapuscinski
committed
- deploy

Andrew Kapuscinski
committed
# Gitlab optimization https://docs.gitlab.com/ee/ci/large_repositories/
GIT_DEPTH: 10
# Workspaces default variables

Andrew Kapuscinski
committed
DEPLOY_ENV: "dev"

Andrew Kapuscinski
committed
DL_HOST: https://dl-nrao.aoc.nrao.edu
# Postgres Service Variables
POSTGRES_DB: archive
POSTGRES_USER: "archive"
POSTGRES_PASSWORD: "docker"
BASE_REGISTRY_URL: "brooks.aoc.nrao.edu:5000/ssa-docker/workspaces"
image: docker:19.03.12

Andrew Kapuscinski
committed
workflow:
rules:
- if: $CI_MERGE_REQUEST_TITLE =~ /^WIP:|^Draft:/
when: never

Andrew Kapuscinski
committed
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'

Andrew Kapuscinski
committed
# Import Templates
include:
- '/ci/build.template.yml'
- '/ci/push.template.yml'
- '/ci/cleanup.template.yml'
- '/ci/unit-test.template.yml'
# Unit testing steps require a specific database image to be available; this step downloads it

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
script:
- echo "$REGISTRY_URL_PASS" | docker login --username "$REGISTRY_URL_USER" --password-stdin $BASE_REGISTRY_URL
- docker pull ${BASE_REGISTRY_URL}/db:workspaces

Andrew Kapuscinski
committed
###############################################
# Build Pexes
###############################################

Brittany Faciane
committed
build pex carta envoy:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/carta_envoy"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/carta_envoy/**/*"
build pex casa envoy:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/casa_envoy"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/casa_envoy/**/*"
build pex conveyor:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/conveyor"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/conveyor/**/*"
build pex deliver:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/deliver"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/deliver/**/*"

Brittany Faciane
committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
build pex ingest:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/ingest"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/ingest/**/*"
build pex ingest envoy:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/ingest_envoy"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/ingest_envoy/**/*"
build pex mediator:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/mediator"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/mediator/**/*"
build pex null:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/null"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/null/**/*"
build pex productfetcher:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/productfetcher"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/productfetcher/**/*"
build pex update stage:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/update_stage"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/update_stage/**/*"
build pex vela:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/vela"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/vela/**/*"
build pex wf inspector:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/wf_inspector"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/wf_inspector/**/*"
build pex ws annihilator:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/ws_annihilator"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/ws_annihilator/**/*"
build pex ws metrics:
interruptible: true
stage: build-pexes
variables:
PEX_PATH: "apps/cli/executables/pexable/ws_metrics"
extends: .build-pexes
only:
changes:
- "apps/cli/executables/pexable/ws_metrics/**/*"
###############################################
# Build Service and Web Images
###############################################

Andrew Kapuscinski
committed
build workflow:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: build
variables:
SERVICE_NAME: "workflow"
PATH_PREFIX: "services/"

Andrew Kapuscinski
committed
build capability:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: build
variables:
SERVICE_NAME: "capability"
PATH_PREFIX: "services/"

Andrew Kapuscinski
committed
build notification:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: build
variables:
SERVICE_NAME: "notification"
PATH_PREFIX: "services/"

Andrew Kapuscinski
committed
build web:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: build
variables:
SERVICE_NAME: "web"
PATH_PREFIX: "apps/"
extends: .build
###############################################
# Test Stages for Services
###############################################

Andrew Kapuscinski
committed
unit test workflow:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: unit-test
variables:
SERVICE_NAME: "workflow"
extends: .unit-test

Andrew Kapuscinski
committed
unit test capability:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: unit-test
variables:
SERVICE_NAME: "capability"
extends: .unit-test

Andrew Kapuscinski
committed

Andrew Kapuscinski
committed
unit test notification:

Andrew Kapuscinski
committed
interruptible: true

Andrew Kapuscinski
committed
stage: unit-test
variables:
SERVICE_NAME: "notification"
###############################################
# Create Coverage Report
###############################################

Andrew Kapuscinski
committed
interruptible: true
- pip install pytest pytest-cov

Andrew Kapuscinski
committed
- coverage combine --append
- coverage report -i --omit="**/test_*.py,**/_version.py,**/conftest.py,**/*interfaces.py" --skip-empty
- coverage xml -i --omit="**/test_*.py,**/_version.py,**/conftest.py,**/*interfaces.py" --skip-empty
- coverage html -i --omit="**/test_*.py,**/_version.py,**/conftest.py,**/*interfaces.py" --skip-empty
coverage_report:
coverage_format: cobertura
path: coverage.xml

Charlotte Hausman
committed
paths:
- htmlcov/

Andrew Kapuscinski
committed
- unit test workflow
- unit test capability
- unit test notification
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
###############################################
# Push Service and Web Images to Registry
###############################################

Andrew Kapuscinski
committed
push workflow:
stage: push

Andrew Kapuscinski
committed
variables:
SERVICE_NAME: "workflow"

Andrew Kapuscinski
committed
extends: .push

Andrew Kapuscinski
committed
push capability:
stage: push

Andrew Kapuscinski
committed
variables:
SERVICE_NAME: "capability"

Andrew Kapuscinski
committed
extends: .push

Andrew Kapuscinski
committed
push notification:
stage: push
variables:
SERVICE_NAME: "notification"

Andrew Kapuscinski
committed
push web:
stage: push
variables:
SERVICE_NAME: "web"
extends: .push
# UI tests coming soon!
# needs:
# - unit test dev ui
###############################################
# Clean Pipeline of Service and Web Images
###############################################
stage: .post
variables:
SERVICE_NAME: "workflow"

Andrew Kapuscinski
committed
allow_failure: true
stage: .post
variables:
SERVICE_NAME: "capability"

Andrew Kapuscinski
committed
allow_failure: true
clean build notification:
stage: .post
variables:
SERVICE_NAME: "notification"

Andrew Kapuscinski
committed
allow_failure: true
clean build web:
stage: .post
variables:
SERVICE_NAME: "web"
extends: .cleanup
allow_failure: true
###############################################
# Deployment Stages
###############################################

Andrew Kapuscinski
committed
interruptible: true
dependencies:
- unit test coverage
before_script:
- pip install -r docs/requirements.txt
- apt update
- apt install make
- mv htmlcov public/htmlcov
- cd docs && make html && mv _build/html/* ../public/
artifacts:
paths:
- public
expire_in: 2 weeks
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'
before_script:
- apt update && apt install -y git
- pip install pyyaml
script:
- DEPLOY_ENV=${DEPLOY_ENV} ./ci/bin/generate-go-yaml.py
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'
changes:
- apps/cli/executables/go/**/*
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
variables:
# override DEPLOY_ENV
DEPLOY_ENV: "test"
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
DEPLOY_ENV: "prod"
artifacts:
paths:
- generated-go-build-pipeline.yml
# Trigger child pipeline based on generated go builder yaml
stage: go-trigger
trigger:
include:
- artifact: generated-go-build-pipeline.yml
job: go generate yaml
strategy: depend
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'
changes:
- apps/cli/executables/go/**/*
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
variables:
# override DEPLOY_ENV
DEPLOY_ENV: "test"
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
DEPLOY_ENV: "prod"

Andrew Kapuscinski
committed
stage: deploy
# Docker doesn't allow variable interpolation when declaring Docker Secret names
# This sed command finds and replaces "dsoc_ENV_secrets:" with "dsoc_${DEPLOY_ENV}_secrets:"
- sed -i "s/dsoc_ENV_secrets:/dsoc_${DEPLOY_ENV}_secrets:/g" docker-compose.yml
- sed -i "s/naasc_ENV_secrets:/naasc_${DEPLOY_ENV}_secrets:/g" docker-compose.yml
- ENV=$DEPLOY_ENV TAG=$IMAGE_TAG DL_HOST=$DL_HOST ENV_HOST=$ENV_HOST BASE_REGISTRY_URL=$BASE_REGISTRY_URL docker stack deploy --compose-file docker-compose.yml workspaces-${DEPLOY_ENV} -e TAG=${IMAGE_TAG}
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'

Andrew Kapuscinski
committed
variables:

Andrew Kapuscinski
committed
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'

Andrew Kapuscinski
committed
variables:
IMAGE_TAG: $CI_COMMIT_TAG
# override DEPLOY_ENV
DEPLOY_ENV: "test"
# override DL_HOST
DL_HOST: https://dl-dsoc-test.nrao.edu

Andrew Kapuscinski
committed
# override ENV_HOST

Andrew Kapuscinski
committed
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
# override DEPLOY_ENV
DEPLOY_ENV: "prod"
# override DL_HOST
DL_HOST: https://dl-dsoc.nrao.edu
# override ENV_HOST
ENV_HOST: ws.nrao.edu