From ec02ab60d63d88777200ddc984e9d45de808d64b Mon Sep 17 00:00:00 2001 From: Andrew Kapuscinski <akapusci@nrao.edu> Date: Fri, 20 Aug 2021 12:37:35 -0400 Subject: [PATCH] Minor CI pipeline gripe fixes --- .gitignore | 1 + .gitlab-ci.yml | 25 +++++-------------------- ci/cleanup.template.yml | 3 +-- ci/unit-test.template.yml | 4 ++++ schema/bin/run-migrations.sh | 4 +++- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 68a4e9ad8..d314422a0 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,7 @@ services/**/**/testing tmp delivery_root lustre/ +pgdata/ # ignore local NGAS local_ngas_root/cache/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 50618075b..1a47bc45b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ stages: - build-base - push-base - - run-schema - cache-build - build - unit-test @@ -11,7 +10,6 @@ stages: - deploy - e2e-test - .post - # - deploy-test variables: # Gitlab optimization https://docs.gitlab.com/ee/ci/large_repositories/ @@ -26,11 +24,6 @@ variables: POSTGRES_USER: "archive" POSTGRES_PASSWORD: "docker" -# CI Postgres Service -services: - - name: ssa-containers.aoc.nrao.edu/ops/ci/db:workspaces - alias: db - image: docker:19.03.12 workflow: @@ -72,19 +65,6 @@ push base image: - Dockerfile.base - docker.properties -# Run Schema -run schema: - stage: run-schema - image: ${REGISTRY_URL}/ops/base:${PROJECT_NAME} - script: - - export PGPASSWORD=$POSTGRES_PASSWORD - - cd schema && ./bin/run-migrations.sh "docker" - rules: - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - when: always - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: always - # Cache build cache: stage: cache-build @@ -177,6 +157,10 @@ unit test coverage: e2e: stage: e2e-test image: docker/compose:1.27.4 + # CI Postgres Service + services: + - name: ssa-containers.aoc.nrao.edu/ops/ci/db:workspaces + alias: db variables: ENV_HOST: workflow before_script: @@ -197,6 +181,7 @@ e2e: - docker logs workspaces_capability_1 - docker logs workspaces_workflow_1 - docker logs workspaces_web_1 + - docker network prune -f - docker-compose -f docker-compose.ci.yml down - docker image rm -f base-build:ci - docker image rm -f e2e:${CI_COMMIT_SHORT_SHA} diff --git a/ci/cleanup.template.yml b/ci/cleanup.template.yml index a36d24d93..6492c8b9a 100644 --- a/ci/cleanup.template.yml +++ b/ci/cleanup.template.yml @@ -4,9 +4,8 @@ - NAME="${REGISTRY_URL}/${PROJECT_NAME}/${SERVICE_NAME}" - | printf "%s\n" "- Removing Images -" \ - "${NAME}:${TAG}" \ "${NAME}:${CI_COMMIT_SHORT_SHA}" - - docker image rm --force "${NAME}:${TAG}" "${NAME}:${CI_COMMIT_SHORT_SHA}" "cache:${CI_COMMIT_SHORT_SHA}" + - docker image rm --force "${NAME}:${CI_COMMIT_SHORT_SHA}" "cache:${CI_COMMIT_SHORT_SHA}" rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_COMMIT_MESSAGE =~ /\A(?i)-debug/' when: never diff --git a/ci/unit-test.template.yml b/ci/unit-test.template.yml index 220b6fb25..c2e9e6da1 100644 --- a/ci/unit-test.template.yml +++ b/ci/unit-test.template.yml @@ -1,4 +1,8 @@ .unit-test: + # Postgres DB service + services: + - name: ssa-containers.aoc.nrao.edu/ops/ci/db:workspaces + alias: db image: ${REGISTRY_URL}/${PROJECT_NAME}/${SERVICE_NAME}:${CI_COMMIT_SHORT_SHA} script: - | diff --git a/schema/bin/run-migrations.sh b/schema/bin/run-migrations.sh index ee68be168..787d7d36f 100755 --- a/schema/bin/run-migrations.sh +++ b/schema/bin/run-migrations.sh @@ -6,6 +6,8 @@ set -e set -o pipefail +ARG="${$1:-docker}" + if [[ $# -eq 0 ]] ; then echo 'ERROR: run-migrations requires an argument for CAPO_PROFILE' exit 0 @@ -14,4 +16,4 @@ fi # Python library installation pip install -r requirements.txt -env CAPO_PROFILE=$1 alembic upgrade head +env CAPO_PROFILE=$ARG alembic upgrade head -- GitLab