2018-11-06 10:30:27 +01:00
|
|
|
image: tcitworld/mobilizon-ci
|
2018-01-13 23:35:11 +01:00
|
|
|
|
2018-12-18 12:26:10 +01:00
|
|
|
stages:
|
2019-10-05 21:17:18 +02:00
|
|
|
- check
|
|
|
|
- test
|
2019-03-18 12:37:04 +01:00
|
|
|
- deploy
|
2020-11-09 10:04:55 +01:00
|
|
|
- docker
|
2020-12-21 16:56:38 +01:00
|
|
|
- release
|
2018-01-13 23:35:11 +01:00
|
|
|
|
2018-01-13 23:40:06 +01:00
|
|
|
variables:
|
|
|
|
MIX_ENV: "test"
|
2019-01-03 11:33:52 +01:00
|
|
|
# DB Variables for Postgres / Postgis
|
2018-10-11 17:37:39 +02:00
|
|
|
POSTGRES_DB: mobilizon_test
|
2018-01-14 00:21:20 +01:00
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_PASSWORD: ""
|
2018-01-14 00:47:03 +01:00
|
|
|
POSTGRES_HOST: postgres
|
2019-01-03 11:33:52 +01:00
|
|
|
# DB Variables for Mobilizon
|
|
|
|
MOBILIZON_DATABASE_USERNAME: $POSTGRES_USER
|
|
|
|
MOBILIZON_DATABASE_PASSWORD: $POSTGRES_PASSWORD
|
|
|
|
MOBILIZON_DATABASE_DBNAME: $POSTGRES_DB
|
|
|
|
MOBILIZON_DATABASE_HOST: $POSTGRES_HOST
|
2018-12-18 11:24:22 +01:00
|
|
|
GEOLITE_CITIES_PATH: "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
2019-10-05 19:07:50 +02:00
|
|
|
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
|
2020-12-21 16:56:38 +01:00
|
|
|
# Release elements
|
|
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
|
|
|
|
ELIXIR_ASSET: "${CI_PROJECT_NAME}-standalone-${CI_COMMIT_TAG}.tar.gz"
|
|
|
|
FRONTEND_ASSET: "${CI_PROJECT_NAME}-frontend-${CI_COMMIT_TAG}.tar.gz"
|
|
|
|
|
2018-01-13 23:40:06 +01:00
|
|
|
|
2019-10-07 10:59:21 +02:00
|
|
|
cache:
|
|
|
|
key: ${CI_COMMIT_REF_SLUG}
|
|
|
|
paths:
|
2019-10-07 11:27:06 +02:00
|
|
|
- ~/.cache/Cypress
|
2020-01-30 20:27:25 +01:00
|
|
|
- _build/
|
2019-10-07 10:59:21 +02:00
|
|
|
- deps/
|
|
|
|
- js/node_modules
|
2019-10-07 11:15:19 +02:00
|
|
|
- cache/Cypress
|
2019-10-07 10:59:21 +02:00
|
|
|
|
2021-01-11 13:58:40 +01:00
|
|
|
lint-elixir:
|
2019-10-05 21:17:18 +02:00
|
|
|
stage: check
|
2019-03-22 11:37:58 +01:00
|
|
|
script:
|
2019-10-07 10:59:21 +02:00
|
|
|
- export EXITVALUE=0
|
2019-03-22 11:37:58 +01:00
|
|
|
- mix deps.get
|
2020-01-30 20:27:25 +01:00
|
|
|
- mix credo --strict -a || export EXITVALUE=1
|
2019-10-07 10:59:21 +02:00
|
|
|
- mix format --check-formatted --dry-run || export EXITVALUE=1
|
2021-01-11 13:58:40 +01:00
|
|
|
- exit $EXITVALUE
|
|
|
|
|
|
|
|
lint-front:
|
|
|
|
image: node:14
|
|
|
|
stage: check
|
|
|
|
before_script:
|
|
|
|
- export EXITVALUE=0
|
2019-03-22 11:04:57 +01:00
|
|
|
- cd js
|
2021-01-11 13:58:40 +01:00
|
|
|
script:
|
2019-04-10 17:30:18 +02:00
|
|
|
- yarn install
|
2020-12-14 10:21:33 +01:00
|
|
|
- yarn run lint || export EXITVALUE=1
|
2020-12-02 11:19:39 +01:00
|
|
|
- yarn run prettier -c . || export EXITVALUE=1
|
2021-01-11 13:58:40 +01:00
|
|
|
- yarn run build:assets || export EXITVALUE=1
|
2019-10-07 10:59:21 +02:00
|
|
|
- exit $EXITVALUE
|
|
|
|
artifacts:
|
|
|
|
expire_in: 1 day
|
|
|
|
when: on_success
|
2019-03-22 11:04:57 +01:00
|
|
|
paths:
|
2019-10-07 10:59:21 +02:00
|
|
|
- priv/static
|
2019-03-22 11:04:57 +01:00
|
|
|
|
2019-10-05 21:17:18 +02:00
|
|
|
deps:
|
|
|
|
stage: check
|
2018-12-18 12:26:10 +01:00
|
|
|
script:
|
2019-10-07 10:59:21 +02:00
|
|
|
- export EXITVALUE=0
|
2019-03-08 13:42:34 +01:00
|
|
|
- mix deps.get
|
2019-10-07 10:59:21 +02:00
|
|
|
- mix hex.outdated || export EXITVALUE=1
|
2019-10-05 21:17:18 +02:00
|
|
|
- cd js
|
2019-10-07 10:59:21 +02:00
|
|
|
- yarn outdated || export EXITVALUE=1
|
|
|
|
- exit $EXITVALUE
|
2019-03-08 13:42:34 +01:00
|
|
|
allow_failure: true
|
2018-01-13 23:35:11 +01:00
|
|
|
|
2019-10-05 21:17:18 +02:00
|
|
|
exunit:
|
|
|
|
stage: test
|
2018-12-18 12:26:10 +01:00
|
|
|
services:
|
2020-02-18 08:57:00 +01:00
|
|
|
- name: mdillon/postgis:11
|
|
|
|
alias: postgres
|
2018-12-18 12:26:10 +01:00
|
|
|
before_script:
|
2019-10-07 10:59:21 +02:00
|
|
|
- cd js
|
|
|
|
- yarn install
|
2020-12-11 15:44:48 +01:00
|
|
|
- yarn run build:assets
|
2019-10-07 10:59:21 +02:00
|
|
|
- cd ../
|
2018-12-18 12:26:10 +01:00
|
|
|
- mix deps.get
|
|
|
|
- MIX_ENV=test mix ecto.create
|
|
|
|
- MIX_ENV=test mix ecto.migrate
|
2020-12-21 16:56:38 +01:00
|
|
|
needs:
|
|
|
|
- deps
|
2021-01-11 13:58:40 +01:00
|
|
|
- lint-elixir
|
2018-01-13 23:35:11 +01:00
|
|
|
script:
|
2018-12-18 12:26:10 +01:00
|
|
|
- mix coveralls
|
2020-12-02 11:19:39 +01:00
|
|
|
|
|
|
|
jest:
|
|
|
|
stage: test
|
|
|
|
before_script:
|
|
|
|
- cd js
|
|
|
|
- yarn install
|
|
|
|
dependencies:
|
2021-01-11 13:58:40 +01:00
|
|
|
- lint-front
|
2020-12-02 11:19:39 +01:00
|
|
|
script:
|
|
|
|
- yarn run test:unit --no-color
|
|
|
|
artifacts:
|
|
|
|
when: always
|
|
|
|
paths:
|
|
|
|
- js/coverage
|
|
|
|
expire_in: 30 days
|
2020-06-03 19:04:22 +02:00
|
|
|
# cypress:
|
|
|
|
# stage: test
|
|
|
|
# services:
|
|
|
|
# - name: mdillon/postgis:11
|
|
|
|
# alias: postgres
|
|
|
|
# script:
|
|
|
|
# - mix deps.get
|
|
|
|
# - cd js
|
|
|
|
# - yarn install
|
|
|
|
# - npx cypress install # just to be sure
|
|
|
|
# - yarn run build
|
|
|
|
# - cd ../
|
|
|
|
# - MIX_ENV=e2e mix ecto.create
|
|
|
|
# - MIX_ENV=e2e mix ecto.migrate
|
|
|
|
# - MIX_ENV=e2e mix run priv/repo/e2e.seed.exs
|
|
|
|
# - MIX_ENV=e2e mix phx.server &
|
|
|
|
# - cd js
|
|
|
|
# - npx wait-on http://localhost:4000
|
|
|
|
# - if [ -z "$CYPRESS_KEY" ]; then npx cypress run; else npx cypress run --record --parallel --key $CYPRESS_KEY; fi
|
|
|
|
# artifacts:
|
|
|
|
# expire_in: 2 day
|
|
|
|
# paths:
|
|
|
|
# - js/tests/e2e/screenshots/**/*.png
|
|
|
|
# - js/tests/e2e/videos/**/*.mp4
|
2019-10-05 21:17:18 +02:00
|
|
|
|
2020-10-22 12:11:38 +02:00
|
|
|
# pages:
|
|
|
|
# stage: deploy
|
|
|
|
# script:
|
|
|
|
# # - mkdir public
|
|
|
|
# # Mobilizon documentation is now on https://framagit.org/framasoft/joinmobilizon/documentation
|
|
|
|
# # Mix docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172
|
|
|
|
# # - mix deps.get
|
|
|
|
# # - mix docs
|
|
|
|
# # - mv doc public/backend
|
|
|
|
# #- cd js
|
|
|
|
# #- yarn install
|
|
|
|
# #- yarn run styleguide:build
|
|
|
|
# #- mv styleguide ../public/frontend
|
|
|
|
# only:
|
|
|
|
# - master
|
|
|
|
# artifacts:
|
|
|
|
# expire_in: 1 hour
|
|
|
|
# paths:
|
|
|
|
# - public
|
2020-11-09 10:04:55 +01:00
|
|
|
|
|
|
|
.docker: &docker
|
|
|
|
stage: docker
|
|
|
|
cache: {}
|
|
|
|
image:
|
|
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
|
|
entrypoint: [""]
|
|
|
|
before_script:
|
|
|
|
- mkdir -p /kaniko/.docker
|
|
|
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json
|
|
|
|
script:
|
|
|
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/docker/production/Dockerfile --destination $DOCKER_IMAGE_NAME
|
|
|
|
|
|
|
|
build-docker-master:
|
|
|
|
<<: *docker
|
|
|
|
only:
|
|
|
|
- schedules
|
|
|
|
variables:
|
|
|
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:master
|
|
|
|
|
|
|
|
build-docker-tag:
|
|
|
|
<<: *docker
|
|
|
|
only:
|
|
|
|
- tags
|
|
|
|
variables:
|
|
|
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG
|
2020-12-21 16:56:38 +01:00
|
|
|
|
|
|
|
build-release-frontend:
|
|
|
|
stage: release
|
|
|
|
image: node:14-alpine
|
|
|
|
before_script:
|
|
|
|
- apk add --no-cache python build-base libwebp-tools bash imagemagick ncurses
|
|
|
|
script:
|
|
|
|
- yarn --cwd "js" install
|
|
|
|
- yarn --cwd "js" run build
|
|
|
|
artifacts:
|
|
|
|
expire_in: 1 day
|
|
|
|
paths:
|
|
|
|
- priv/static
|
|
|
|
|
|
|
|
|
|
|
|
build-release-elixir:
|
|
|
|
stage: release
|
|
|
|
image: elixir:alpine
|
|
|
|
before_script:
|
|
|
|
- apk add --no-cache build-base git cmake
|
|
|
|
variables:
|
|
|
|
MIX_ENV: "prod"
|
|
|
|
script:
|
|
|
|
- mix local.hex --force
|
|
|
|
- mix local.rebar --force
|
|
|
|
- mix deps.get
|
|
|
|
- cp docker/production/releases.exs ./config/
|
|
|
|
- mix phx.digest
|
|
|
|
- mix release
|
|
|
|
needs:
|
|
|
|
- build-release-frontend
|
|
|
|
artifacts:
|
|
|
|
expire_in: 1 day
|
|
|
|
paths:
|
|
|
|
- _build/prod/rel
|
|
|
|
|
|
|
|
build-release-upload:
|
|
|
|
stage: release
|
|
|
|
image: curlimages/curl:latest
|
|
|
|
# rules:
|
|
|
|
# - if: $CI_COMMIT_TAG
|
|
|
|
script: |
|
|
|
|
ls -R _build
|
|
|
|
tar czf /tmp/${ELIXIR_ASSET} -C _build/prod/rel mobilizon
|
|
|
|
tar czf /tmp/${FRONTEND_ASSET} -C priv/static .
|
|
|
|
ls -al /tmp/*.tar.gz
|
|
|
|
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "_build/${ELIXIR_ASSET}" ${PACKAGE_REGISTRY_URL}/${ELIXIR_ASSET}
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "_build/${FRONTEND_ASSET}" ${PACKAGE_REGISTRY_URL}/${FRONTEND_ASSET}
|
|
|
|
artifacts:
|
|
|
|
expire_in: 1 day
|
|
|
|
when: on_success
|
|
|
|
paths:
|
|
|
|
- _build/${ELIXIR_ASSET}
|
|
|
|
- _build/${FRONTEND_ASSET}
|
|
|
|
needs:
|
|
|
|
- build-release-elixir
|
|
|
|
|
|
|
|
build-release-create:
|
|
|
|
stage: release
|
|
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
script: |
|
|
|
|
release-cli create --name "Release $CI_COMMIT_SHA" \
|
|
|
|
--tag-name "$CI_COMMIT_TAG" \
|
|
|
|
--assets-link "{\"name\":\"${ELIXIR_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${ELIXIR_ASSET}\"}" \
|
|
|
|
--assets-link "{\"name\":\"${FRONTEND_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${FRONTEND_ASSET}\"}"
|
|
|
|
needs:
|
|
|
|
- build-release-upload
|
|
|
|
|