2020-12-19 22:45:02 +00:00
|
|
|
stages:
|
|
|
|
- test
|
2021-01-13 21:47:21 +00:00
|
|
|
- deploy_tags
|
2020-12-19 22:45:02 +00:00
|
|
|
- deploy
|
|
|
|
|
2020-07-03 15:34:19 +00:00
|
|
|
variables:
|
2020-07-03 15:39:15 +00:00
|
|
|
POSTGRES_PASSWORD: "postgres"
|
|
|
|
POSTGRES_USER: "postgres"
|
2020-07-03 15:34:19 +00:00
|
|
|
DATABASE_URL: "postgres"
|
2020-07-22 19:22:44 +00:00
|
|
|
MIX_ENV: "test"
|
2020-12-19 17:43:27 +00:00
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
2020-12-19 18:51:02 +00:00
|
|
|
DOCKER_HOST: tcp://docker:2376
|
2021-03-26 22:31:54 +00:00
|
|
|
# fetch & clean the repo rather than completely cloning (faster)
|
|
|
|
GIT_STRATEGY: fetch
|
|
|
|
|
2021-08-12 19:07:19 +00:00
|
|
|
include:
|
|
|
|
- .gitlab/ci/.cypress.yml
|
|
|
|
|
2021-03-26 22:31:54 +00:00
|
|
|
# Test stage. Runs various tests and speculatively builds docker image in
|
|
|
|
# parallel, in case the build passes.
|
2021-06-10 21:06:38 +00:00
|
|
|
.test_template: &test_template
|
2020-12-19 22:45:02 +00:00
|
|
|
stage: test
|
2021-04-24 16:20:17 +00:00
|
|
|
cache:
|
2021-06-18 22:08:54 +00:00
|
|
|
key: $CI_JOB_NAME
|
2021-04-24 16:20:17 +00:00
|
|
|
paths:
|
|
|
|
- _build/
|
|
|
|
- deps/
|
2020-12-19 22:28:35 +00:00
|
|
|
services:
|
|
|
|
- name: postgres:12
|
2021-08-05 03:10:32 +00:00
|
|
|
script:
|
|
|
|
- apk add git
|
|
|
|
- script/cibuild
|
2020-12-18 20:10:25 +00:00
|
|
|
|
2021-07-22 20:39:17 +00:00
|
|
|
test_1.10.4:
|
2021-06-10 21:06:38 +00:00
|
|
|
<<: *test_template
|
|
|
|
image: "elixir:1.10.4-alpine"
|
|
|
|
|
|
|
|
test_1.11.4:
|
|
|
|
<<: *test_template
|
|
|
|
image: "elixir:1.11.4-alpine"
|
|
|
|
|
2021-07-22 20:39:17 +00:00
|
|
|
test:
|
2021-06-10 21:06:38 +00:00
|
|
|
<<: *test_template
|
|
|
|
image: "elixir:1.12.1-alpine"
|
2021-07-22 20:39:17 +00:00
|
|
|
script:
|
2021-08-05 03:10:32 +00:00
|
|
|
- apk add git
|
2021-07-23 16:08:31 +00:00
|
|
|
- script/cibuild covered
|
2021-07-22 20:39:17 +00:00
|
|
|
artifacts:
|
2021-07-23 16:10:53 +00:00
|
|
|
paths:
|
|
|
|
- cover/excoveralls.json
|
2021-06-10 21:06:38 +00:00
|
|
|
|
2021-07-20 21:09:22 +00:00
|
|
|
credo:
|
|
|
|
stage: test
|
|
|
|
image: "elixir:1.12.1-alpine"
|
2021-07-20 21:15:04 +00:00
|
|
|
cache:
|
|
|
|
key: "test_1.12.1"
|
|
|
|
paths:
|
|
|
|
- _build/
|
|
|
|
- deps/
|
|
|
|
script:
|
2021-08-05 03:10:32 +00:00
|
|
|
- apk add git
|
2021-07-20 21:15:04 +00:00
|
|
|
- mix local.hex --force
|
|
|
|
- mix local.rebar --force
|
|
|
|
- mix deps.get
|
2021-08-05 03:05:13 +00:00
|
|
|
- mix deps.compile
|
2021-07-20 21:34:29 +00:00
|
|
|
- mix credo --all
|
2021-07-20 21:09:22 +00:00
|
|
|
|
2021-07-20 22:42:40 +00:00
|
|
|
stylelint:
|
|
|
|
stage: test
|
|
|
|
image: "node:16"
|
|
|
|
script:
|
|
|
|
- cd apps/app/assets/
|
2021-07-20 22:44:42 +00:00
|
|
|
- npm install
|
2021-07-20 22:42:40 +00:00
|
|
|
- npx stylelint **/*.css
|
|
|
|
|
|
|
|
prettier:
|
|
|
|
stage: test
|
|
|
|
image: "node:16"
|
|
|
|
script:
|
|
|
|
- cd apps/app/assets/
|
2021-07-20 22:44:42 +00:00
|
|
|
- npm install
|
2021-07-20 22:42:40 +00:00
|
|
|
- npx prettier --check **/*.js
|
|
|
|
|
2020-12-22 17:47:16 +00:00
|
|
|
build_image_for_commit:
|
|
|
|
stage: test
|
2021-03-26 22:31:54 +00:00
|
|
|
image: "docker:20.10"
|
2021-07-19 17:44:35 +00:00
|
|
|
rules:
|
2021-07-19 17:54:28 +00:00
|
|
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
|
|
when: on_success
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
|
|
changes:
|
2021-07-19 17:44:35 +00:00
|
|
|
- Dockerfile
|
2021-07-19 17:54:28 +00:00
|
|
|
when: on_success
|
2020-12-19 22:28:35 +00:00
|
|
|
services:
|
2021-03-26 22:31:54 +00:00
|
|
|
- name: docker:20.10-dind
|
2021-06-10 21:06:38 +00:00
|
|
|
before_script:
|
|
|
|
- apk add git
|
|
|
|
- script/ci-docker-prebuild
|
2020-12-19 22:28:35 +00:00
|
|
|
script:
|
2021-06-10 21:06:38 +00:00
|
|
|
- script/ci-docker-build
|
2020-12-22 17:47:16 +00:00
|
|
|
|
2021-07-23 16:08:31 +00:00
|
|
|
report_coverage:
|
|
|
|
stage: deploy_tags
|
|
|
|
needs: ['test']
|
|
|
|
image: "elixir:1.12.1-alpine"
|
|
|
|
script:
|
2021-07-23 16:17:14 +00:00
|
|
|
- mix local.hex --force
|
2021-07-23 16:08:31 +00:00
|
|
|
- script/coverage-json-to-metrics
|
|
|
|
- script/coverage-json-to-cobertura
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
metrics: metrics.txt
|
|
|
|
cobertura: cover/cobertura.xml
|
|
|
|
|
2021-03-26 22:31:54 +00:00
|
|
|
# If tests pass, tag the commit and update package versions
|
2021-01-13 21:43:04 +00:00
|
|
|
deploy_to_tags:
|
2021-01-13 21:47:21 +00:00
|
|
|
stage: deploy_tags
|
2021-08-12 19:16:03 +00:00
|
|
|
needs:
|
|
|
|
- test
|
|
|
|
- test_1.10.4
|
|
|
|
- test_1.11.4
|
|
|
|
- build_image_for_commit
|
|
|
|
- cypress
|
|
|
|
- credo
|
|
|
|
- prettier
|
|
|
|
- stylelint
|
2021-06-19 03:56:19 +00:00
|
|
|
image: "node:16"
|
2021-01-13 21:43:04 +00:00
|
|
|
only:
|
|
|
|
- master
|
2021-03-26 22:31:54 +00:00
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- package-lock.json
|
2021-06-18 22:59:30 +00:00
|
|
|
- package.json
|
2021-03-26 22:31:54 +00:00
|
|
|
paths:
|
|
|
|
- node_modules/
|
2021-01-13 21:43:04 +00:00
|
|
|
script:
|
2021-05-28 17:38:37 +00:00
|
|
|
- export GIT_AUTHOR_NAME=$GITLAB_USER_NAME
|
|
|
|
- export GIT_AUTHOR_EMAIL=$GITLAB_USER_EMAIL
|
|
|
|
- export GIT_COMMITTER_NAME=$GITLAB_USER_NAME
|
|
|
|
- export GIT_COMMITTER_EMAIL=$GITLAB_USER_EMAIL
|
2021-06-19 00:08:35 +00:00
|
|
|
- export GIT_BRANCH=$CI_COMMIT_REF_NAME
|
2021-06-18 23:35:06 +00:00
|
|
|
- git config user.email $GITLAB_USER_EMAIL
|
|
|
|
- git config user.name $GITLAB_USER_NAME
|
2021-06-18 23:22:12 +00:00
|
|
|
- npm install --no-save
|
2021-06-19 02:36:35 +00:00
|
|
|
- npx semantic-release --repository-url=$CI_REPOSITORY_URL
|
2021-01-13 21:43:04 +00:00
|
|
|
- script/generate-build-version
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
dotenv: build.env
|
|
|
|
|
2021-03-26 22:31:54 +00:00
|
|
|
# If the tests passed, we take the image for this SHA and tag it with the version
|
|
|
|
# and latest, so we can signal that it is ready for prod
|
2020-12-22 17:47:16 +00:00
|
|
|
deploy_commit_image_to_tag:
|
|
|
|
stage: deploy
|
2021-01-13 21:43:04 +00:00
|
|
|
needs:
|
|
|
|
- build_image_for_commit
|
|
|
|
- job: deploy_to_tags
|
|
|
|
artifacts: true
|
|
|
|
only:
|
|
|
|
- master
|
2020-12-22 17:47:16 +00:00
|
|
|
image: "docker:19.03.12"
|
|
|
|
services:
|
|
|
|
- name: docker:19.03.12-dind
|
2021-03-26 22:31:54 +00:00
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none # this job does not need the project files, only docker
|
2021-06-10 21:06:38 +00:00
|
|
|
parallel:
|
|
|
|
matrix:
|
|
|
|
- IMAGE_TYPE: ["", "-elixir-builder", "-asset-builder"]
|
2020-12-22 17:47:16 +00:00
|
|
|
script:
|
2021-01-13 21:43:04 +00:00
|
|
|
- echo "BUILD_VERSION is ${BUILD_VERSION}"
|
2020-12-22 17:47:16 +00:00
|
|
|
- docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
|
2020-12-22 20:36:13 +00:00
|
|
|
# Run the docker pull, but retry if it doesn't work at first because layers may be
|
|
|
|
# still be loading to storage
|
2021-06-10 21:06:38 +00:00
|
|
|
- for i in 1 2 3 4 5; do docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA$IMAGE_TYPE && break || sleep 15; done
|
|
|
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA$IMAGE_TYPE $CI_REGISTRY_IMAGE:$BUILD_VERSION$IMAGE_TYPE
|
|
|
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA$IMAGE_TYPE $CI_REGISTRY_IMAGE:latest$IMAGE_TYPE
|
|
|
|
- docker push $CI_REGISTRY_IMAGE:$BUILD_VERSION$IMAGE_TYPE
|
|
|
|
- docker push $CI_REGISTRY_IMAGE:latest$IMAGE_TYPE
|
2021-06-23 14:52:43 +00:00
|
|
|
|
2021-06-23 14:59:19 +00:00
|
|
|
.dependabot_gitlab: &dependabot_gitlab
|
2021-06-23 14:52:43 +00:00
|
|
|
image:
|
2021-09-15 22:23:53 +00:00
|
|
|
name: docker.io/andrcuns/dependabot-gitlab:0.9.7
|
2021-06-23 14:52:43 +00:00
|
|
|
entrypoint: [""]
|
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none
|
|
|
|
RAILS_ENV: production
|
|
|
|
SETTINGS__STANDALONE: "true"
|
|
|
|
SETTINGS__GITLAB_URL: $CI_SERVER_URL
|
|
|
|
SETTINGS__GITLAB_ACCESS_TOKEN: $GITLAB_TOKEN
|
|
|
|
before_script:
|
|
|
|
- cd /home/dependabot/app
|
|
|
|
script:
|
2021-06-23 21:21:10 +00:00
|
|
|
- bundle exec rake "dependabot:update[$CI_PROJECT_PATH,$PACKAGE_MANAGER,$DIRECTORY]"
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
- schedules
|
2021-06-23 14:52:43 +00:00
|
|
|
|
2021-06-23 21:21:10 +00:00
|
|
|
npm-release-tools:
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: npm
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /(\bnpm|yarn\b)/
|
2021-06-23 21:21:10 +00:00
|
|
|
|
|
|
|
npm-assets:
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/apps/app/assets"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: npm
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /(\bnpm|yarn\b)/
|
2021-06-23 14:52:43 +00:00
|
|
|
|
2021-06-23 21:21:10 +00:00
|
|
|
mix-admin:
|
2021-09-15 22:09:02 +00:00
|
|
|
timeout: 3 hours 30 minutes # hopefully temporary hack because hex runs slowly in docker right now
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/apps/admin"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: mix
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /\bmix\b/
|
2021-06-23 21:21:10 +00:00
|
|
|
|
|
|
|
mix-app:
|
2021-09-15 22:09:02 +00:00
|
|
|
timeout: 3 hours 30 minutes # hopefully temporary hack because hex runs slowly in docker right now
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/apps/app"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: mix
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /\bmix\b/
|
2021-06-23 21:21:10 +00:00
|
|
|
|
|
|
|
mix-core:
|
2021-09-15 22:09:02 +00:00
|
|
|
timeout: 3 hours 30 minutes # hopefully temporary hack because hex runs slowly in docker right now
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/apps/core"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: mix
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /\bmix\b/
|
2021-06-23 21:21:10 +00:00
|
|
|
|
|
|
|
mix-content:
|
2021-09-15 22:09:02 +00:00
|
|
|
timeout: 3 hours 30 minutes # hopefully temporary hack because hex runs slowly in docker right now
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/apps/content"
|
2021-06-24 15:43:19 +00:00
|
|
|
PACKAGE_MANAGER: mix
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /\bmix\b/
|
2021-06-23 14:52:43 +00:00
|
|
|
|
|
|
|
docker:
|
2021-06-23 21:48:50 +00:00
|
|
|
extends: .dependabot_gitlab
|
2021-06-23 21:21:10 +00:00
|
|
|
variables:
|
|
|
|
DIRECTORY: "/"
|
2021-06-23 21:26:41 +00:00
|
|
|
PACKAGE_MANAGER: docker
|
2021-06-23 21:59:34 +00:00
|
|
|
only:
|
|
|
|
variables:
|
|
|
|
- $PACKAGE_MANAGER_SET =~ /\bdocker\b/
|