242 lines
7.2 KiB
YAML
242 lines
7.2 KiB
YAML
stages:
|
|
- build
|
|
- test
|
|
- deploy
|
|
|
|
variables:
|
|
# Disable the shared image build jobs from turniere-infra; this repo owns buildx builds below.
|
|
DOCKER_IMAGE_ENVS: ""
|
|
DOCKER_BUILDKIT: "1"
|
|
BUILDX_PLATFORMS: "linux/amd64,linux/arm64"
|
|
|
|
include:
|
|
- project: 'turniere/turniere-infra'
|
|
file: '/ci/pipeline.yaml'
|
|
|
|
.buildx-image:
|
|
stage: build
|
|
tags:
|
|
- shell
|
|
before_script:
|
|
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
|
|
- export BUILDX_BUILDER_NAME="turniere-buildx-$CI_PIPELINE_ID-$CI_JOB_ID"
|
|
- docker buildx create --name "$BUILDX_BUILDER_NAME" --driver docker-container --use
|
|
- docker buildx inspect --builder "$BUILDX_BUILDER_NAME" --bootstrap
|
|
after_script:
|
|
- export BUILDX_BUILDER_NAME="turniere-buildx-$CI_PIPELINE_ID-$CI_JOB_ID"
|
|
- docker buildx rm "$BUILDX_BUILDER_NAME" || true
|
|
- docker logout "$CI_REGISTRY" || true
|
|
|
|
build production image:
|
|
extends: .buildx-image
|
|
script:
|
|
- >-
|
|
docker buildx build
|
|
--builder "$BUILDX_BUILDER_NAME"
|
|
--file Dockerfile
|
|
--target production
|
|
--platform "$BUILDX_PLATFORMS"
|
|
--cache-from "type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:production"
|
|
--cache-to "type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:production,mode=max"
|
|
--tag "$CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA"
|
|
--push
|
|
.
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE != "push"
|
|
when: never
|
|
- when: always
|
|
|
|
build test image:
|
|
extends: .buildx-image
|
|
script:
|
|
- >-
|
|
docker buildx build
|
|
--builder "$BUILDX_BUILDER_NAME"
|
|
--file Dockerfile
|
|
--target test
|
|
--platform "$BUILDX_PLATFORMS"
|
|
--cache-from "type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:production"
|
|
--cache-from "type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:test"
|
|
--cache-to "type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:test,mode=max"
|
|
--tag "$CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA"
|
|
--push
|
|
.
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE != "push"
|
|
when: never
|
|
- when: always
|
|
|
|
rails spec:
|
|
stage: test
|
|
tags:
|
|
- docker
|
|
needs:
|
|
- build test image
|
|
image: $CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA
|
|
parallel:
|
|
matrix:
|
|
- RSPEC_NODE_INDEX: ["1", "2", "3", "4", "5", "6", "7", "8"]
|
|
RSPEC_NODE_TOTAL: "8"
|
|
rules:
|
|
- if: $SKIP_TEST
|
|
when: never
|
|
- if: $SKIP_ALL_SPECS
|
|
when: never
|
|
- if: $SKIP_RAILS_SPEC
|
|
when: never
|
|
- if: $CI_PIPELINE_SOURCE != "push"
|
|
when: never
|
|
- when: always
|
|
script:
|
|
- cd /app
|
|
- inv db-migrate
|
|
- inv test-shard --node-index=$RSPEC_NODE_INDEX --node-total=$RSPEC_NODE_TOTAL
|
|
artifacts:
|
|
paths:
|
|
- specs_with_runtime.txt
|
|
expire_in: 30 days
|
|
|
|
rails e2e spec:
|
|
stage: test
|
|
tags:
|
|
- docker
|
|
needs:
|
|
- build production image
|
|
- build test image
|
|
image: $CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA
|
|
services:
|
|
- name: postgres:16
|
|
alias: postgres
|
|
- name: $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA
|
|
alias: app
|
|
command:
|
|
- bundle
|
|
- exec
|
|
- rails
|
|
- s
|
|
- -p
|
|
- "3000"
|
|
- -b
|
|
- 0.0.0.0
|
|
variables:
|
|
FF_NETWORK_PER_BUILD: "true"
|
|
POSTGRES_DB: turniere_blackbox
|
|
POSTGRES_USER: turniere
|
|
POSTGRES_PASSWORD: turniere
|
|
POSTGRES_URL: postgres://turniere:turniere@postgres:5432/turniere_blackbox
|
|
POSTGRES_USERNAME: turniere
|
|
SECRET_KEY_BASE: turniere-blackbox-secret-key-base-please-change-in-real-prod
|
|
MAILGUN_API_KEY: blackbox-test-api-key
|
|
MAILGUN_DOMAIN: blackbox.example.com
|
|
RAILS_LOG_TO_STDOUT: "1"
|
|
RAILS_SERVE_STATIC_FILES: "1"
|
|
NO_PROXY: app,postgres,localhost,127.0.0.1
|
|
no_proxy: app,postgres,localhost,127.0.0.1
|
|
TURNIERE_E2E_BASE_URL: http://app:3000
|
|
TURNIERE_E2E_EMAIL: e2e@example.com
|
|
TURNIERE_E2E_PASSWORD: password123
|
|
TURNIERE_E2E_USERNAME: e2e-user
|
|
rules:
|
|
- if: $SKIP_TEST
|
|
when: never
|
|
- if: $SKIP_ALL_SPECS
|
|
when: never
|
|
- if: $SKIP_E2E_SPEC
|
|
when: never
|
|
- if: $CI_PIPELINE_SOURCE != "push"
|
|
when: never
|
|
- when: always
|
|
script:
|
|
- cd /app
|
|
- inv blackbox-service
|
|
|
|
rails follow sync e2e spec:
|
|
stage: test
|
|
tags:
|
|
- docker
|
|
needs:
|
|
- build production image
|
|
- build test image
|
|
image: $CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA
|
|
services:
|
|
- name: postgres:16
|
|
alias: source-postgres
|
|
variables:
|
|
POSTGRES_DB: turniere_source_blackbox
|
|
POSTGRES_USER: turniere
|
|
POSTGRES_PASSWORD: turniere
|
|
- name: postgres:16
|
|
alias: follower-postgres
|
|
variables:
|
|
POSTGRES_DB: turniere_follower_blackbox
|
|
POSTGRES_USER: turniere
|
|
POSTGRES_PASSWORD: turniere
|
|
- name: $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA
|
|
alias: source-app
|
|
variables:
|
|
POSTGRES_URL: postgres://turniere:turniere@source-postgres:5432/turniere_source_blackbox
|
|
POSTGRES_USERNAME: turniere
|
|
POSTGRES_PASSWORD: turniere
|
|
SECRET_KEY_BASE: turniere-blackbox-secret-key-base-please-change-in-real-prod
|
|
MAILGUN_API_KEY: blackbox-test-api-key
|
|
MAILGUN_DOMAIN: blackbox.example.com
|
|
TOURNAMENT_SYNC_HTTP_TIMEOUT_SECONDS: "3"
|
|
NO_PROXY: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
no_proxy: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
RAILS_LOG_TO_STDOUT: "1"
|
|
RAILS_SERVE_STATIC_FILES: "1"
|
|
command:
|
|
- bundle
|
|
- exec
|
|
- rails
|
|
- s
|
|
- -p
|
|
- "3000"
|
|
- -b
|
|
- 0.0.0.0
|
|
- name: $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA
|
|
alias: follower-app
|
|
variables:
|
|
POSTGRES_URL: postgres://turniere:turniere@follower-postgres:5432/turniere_follower_blackbox
|
|
POSTGRES_USERNAME: turniere
|
|
POSTGRES_PASSWORD: turniere
|
|
SECRET_KEY_BASE: turniere-blackbox-secret-key-base-please-change-in-real-prod
|
|
MAILGUN_API_KEY: blackbox-test-api-key
|
|
MAILGUN_DOMAIN: blackbox.example.com
|
|
TOURNAMENT_SYNC_HTTP_TIMEOUT_SECONDS: "3"
|
|
NO_PROXY: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
no_proxy: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
RAILS_LOG_TO_STDOUT: "1"
|
|
RAILS_SERVE_STATIC_FILES: "1"
|
|
command:
|
|
- bundle
|
|
- exec
|
|
- rails
|
|
- s
|
|
- -p
|
|
- "3000"
|
|
- -b
|
|
- 0.0.0.0
|
|
variables:
|
|
FF_NETWORK_PER_BUILD: "true"
|
|
NO_PROXY: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
no_proxy: source-app,follower-app,source-postgres,follower-postgres,localhost,127.0.0.1
|
|
TURNIERE_SOURCE_E2E_BASE_URL: http://source-app:3000
|
|
TURNIERE_FOLLOWER_E2E_BASE_URL: http://follower-app:3000
|
|
TURNIERE_E2E_EMAIL: e2e@example.com
|
|
TURNIERE_E2E_PASSWORD: password123
|
|
TURNIERE_E2E_USERNAME: e2e-user
|
|
rules:
|
|
- if: $SKIP_TEST
|
|
when: never
|
|
- if: $SKIP_ALL_SPECS
|
|
when: never
|
|
- if: $SKIP_FOLLOW_E2E_SPEC
|
|
when: never
|
|
- if: $CI_PIPELINE_SOURCE != "push"
|
|
when: never
|
|
- when: always
|
|
script:
|
|
- cd /app
|
|
- inv blackbox-follow-service
|