2018-11-06 09:30:27 +00:00
|
|
|
image: tcitworld/mobilizon-ci
|
2018-01-13 22:35:11 +00:00
|
|
|
|
2018-12-18 11:26:10 +00:00
|
|
|
stages:
|
2020-12-22 23:01:25 +00:00
|
|
|
- install
|
2019-10-05 19:17:18 +00:00
|
|
|
- check
|
2021-01-14 14:47:35 +00:00
|
|
|
- build-js
|
2019-10-05 19:17:18 +00:00
|
|
|
- test
|
2021-01-14 14:47:35 +00:00
|
|
|
- docker
|
2020-12-22 23:01:25 +00:00
|
|
|
- package
|
|
|
|
- upload
|
2019-03-18 11:37:04 +00:00
|
|
|
- deploy
|
2018-01-13 22:35:11 +00:00
|
|
|
|
2018-01-13 22:40:06 +00:00
|
|
|
variables:
|
|
|
|
MIX_ENV: "test"
|
2020-12-22 23:01:25 +00:00
|
|
|
YARN_CACHE_FOLDER: "js/.yarn"
|
2019-01-03 10:33:52 +00:00
|
|
|
# DB Variables for Postgres / Postgis
|
2018-10-11 15:37:39 +00:00
|
|
|
POSTGRES_DB: mobilizon_test
|
2018-01-13 23:21:20 +00:00
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_PASSWORD: ""
|
2018-01-13 23:47:03 +00:00
|
|
|
POSTGRES_HOST: postgres
|
2019-01-03 10:33:52 +00: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 10:24:22 +00:00
|
|
|
GEOLITE_CITIES_PATH: "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
2019-10-05 17:07:50 +00:00
|
|
|
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
|
2020-12-21 15:56:38 +00:00
|
|
|
# Release elements
|
2020-12-22 23:01:25 +00:00
|
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}"
|
2021-01-13 08:05:39 +00:00
|
|
|
ARCH: "amd64"
|
2020-12-21 15:56:38 +00:00
|
|
|
|
2019-10-07 08:59:21 +00:00
|
|
|
cache:
|
2021-01-13 08:05:39 +00:00
|
|
|
key: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
|
2019-10-07 08:59:21 +00:00
|
|
|
paths:
|
2019-10-07 09:27:06 +00:00
|
|
|
- ~/.cache/Cypress
|
2020-12-22 23:01:25 +00:00
|
|
|
- cache/Cypress
|
2019-10-07 08:59:21 +00:00
|
|
|
- deps/
|
2020-12-22 23:01:25 +00:00
|
|
|
- _build/
|
2019-10-07 08:59:21 +00:00
|
|
|
- js/node_modules
|
2020-12-22 23:01:25 +00:00
|
|
|
- js/.yarn
|
|
|
|
|
|
|
|
# Installed dependencies are cached across the pipeline
|
|
|
|
# So there is no need to reinstall them all the time
|
|
|
|
# It saves minutes during a pipeline build time
|
|
|
|
install:
|
|
|
|
stage: install
|
|
|
|
script:
|
2021-01-12 18:47:10 +00:00
|
|
|
- yarn --cwd "js" install --frozen-lockfile
|
|
|
|
- mix deps.get
|
|
|
|
- mix compile
|
2019-10-07 08:59:21 +00:00
|
|
|
|
2021-01-11 12:58:40 +00:00
|
|
|
lint-elixir:
|
2019-10-05 19:17:18 +00:00
|
|
|
stage: check
|
2021-01-14 14:07:59 +00:00
|
|
|
before_script:
|
|
|
|
- mix deps.get
|
2019-03-22 10:37:58 +00:00
|
|
|
script:
|
2019-10-07 08:59:21 +00:00
|
|
|
- export EXITVALUE=0
|
|
|
|
- mix format --check-formatted --dry-run || export EXITVALUE=1
|
2021-01-22 18:31:27 +00:00
|
|
|
- mix credo --strict -a || export EXITVALUE=1
|
2021-01-25 15:31:57 +00:00
|
|
|
- mix sobelow --config || export EXITVALUE=1
|
2021-01-11 12:58:40 +00:00
|
|
|
- exit $EXITVALUE
|
|
|
|
|
|
|
|
lint-front:
|
2021-01-14 14:07:59 +00:00
|
|
|
image: node:14
|
2021-01-11 12:58:40 +00:00
|
|
|
stage: check
|
|
|
|
before_script:
|
|
|
|
- export EXITVALUE=0
|
2021-01-14 14:07:59 +00:00
|
|
|
- yarn --cwd "js" install --frozen-lockfile
|
2021-01-11 12:58:40 +00:00
|
|
|
script:
|
2021-01-14 14:45:10 +00:00
|
|
|
- yarn --cwd "js" run lint || export EXITVALUE=1
|
|
|
|
- yarn --cwd "js" run prettier -c . || export EXITVALUE=1
|
2019-10-07 08:59:21 +00:00
|
|
|
- exit $EXITVALUE
|
2020-12-22 23:01:25 +00:00
|
|
|
|
|
|
|
build-frontend:
|
2021-01-14 14:47:35 +00:00
|
|
|
stage: build-js
|
2021-01-14 14:07:59 +00:00
|
|
|
image: node:14
|
2020-12-22 23:01:25 +00:00
|
|
|
before_script:
|
2021-01-12 18:47:10 +00:00
|
|
|
- apt update
|
|
|
|
- apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant
|
2020-12-22 23:01:25 +00:00
|
|
|
script:
|
2021-01-14 14:07:59 +00:00
|
|
|
- yarn --cwd "js" install --frozen-lockfile
|
2021-01-12 18:47:10 +00:00
|
|
|
- yarn --cwd "js" run build
|
2019-10-07 08:59:21 +00:00
|
|
|
artifacts:
|
2020-12-22 23:01:25 +00:00
|
|
|
expire_in: 5 days
|
2019-03-22 10:04:57 +00:00
|
|
|
paths:
|
2021-01-12 18:47:10 +00:00
|
|
|
- priv/static
|
2020-12-22 23:01:25 +00:00
|
|
|
needs:
|
2021-01-12 18:47:10 +00:00
|
|
|
- lint-front
|
2019-03-22 10:04:57 +00:00
|
|
|
|
2019-10-05 19:17:18 +00:00
|
|
|
deps:
|
|
|
|
stage: check
|
2021-01-14 14:07:59 +00:00
|
|
|
before_script:
|
|
|
|
- mix deps.get
|
2018-12-18 11:26:10 +00:00
|
|
|
script:
|
2019-10-07 08:59:21 +00:00
|
|
|
- export EXITVALUE=0
|
|
|
|
- mix hex.outdated || export EXITVALUE=1
|
2020-12-22 23:01:25 +00:00
|
|
|
- yarn --cwd "js" outdated || export EXITVALUE=1
|
2019-10-07 08:59:21 +00:00
|
|
|
- exit $EXITVALUE
|
2019-03-08 12:42:34 +00:00
|
|
|
allow_failure: true
|
2020-12-22 23:01:25 +00:00
|
|
|
needs:
|
|
|
|
- install
|
2018-01-13 22:35:11 +00:00
|
|
|
|
2019-10-05 19:17:18 +00:00
|
|
|
exunit:
|
|
|
|
stage: test
|
2018-12-18 11:26:10 +00:00
|
|
|
services:
|
2020-02-18 07:57:00 +00:00
|
|
|
- name: mdillon/postgis:11
|
|
|
|
alias: postgres
|
2020-12-22 23:01:25 +00:00
|
|
|
variables:
|
|
|
|
MIX_ENV: test
|
2018-12-18 11:26:10 +00:00
|
|
|
before_script:
|
2021-01-14 14:07:59 +00:00
|
|
|
- mix deps.get
|
2020-12-22 23:01:25 +00:00
|
|
|
- mix ecto.create
|
|
|
|
- mix ecto.migrate
|
2018-01-13 22:35:11 +00:00
|
|
|
script:
|
2018-12-18 11:26:10 +00:00
|
|
|
- mix coveralls
|
2021-01-12 19:09:44 +00:00
|
|
|
artifacts:
|
|
|
|
when: always
|
|
|
|
reports:
|
|
|
|
junit:
|
|
|
|
- test-junit-report.xml
|
|
|
|
expire_in: 30 days
|
2020-12-02 10:19:39 +00:00
|
|
|
|
|
|
|
jest:
|
|
|
|
stage: test
|
2020-12-22 23:01:25 +00:00
|
|
|
needs:
|
2021-01-11 12:58:40 +00:00
|
|
|
- lint-front
|
2021-01-14 14:07:59 +00:00
|
|
|
before_script:
|
|
|
|
- yarn --cwd "js" install --frozen-lockfile
|
2020-12-02 10:19:39 +00:00
|
|
|
script:
|
2020-12-22 23:01:25 +00:00
|
|
|
- yarn --cwd "js" run test:unit --no-color --ci --reporters=default --reporters=jest-junit
|
2020-12-02 10:19:39 +00:00
|
|
|
artifacts:
|
|
|
|
when: always
|
|
|
|
paths:
|
|
|
|
- js/coverage
|
2020-12-22 23:01:25 +00:00
|
|
|
reports:
|
|
|
|
junit:
|
2021-01-12 18:47:10 +00:00
|
|
|
- js/junit.xml
|
2020-12-02 10:19:39 +00:00
|
|
|
expire_in: 30 days
|
2020-12-22 23:01:25 +00:00
|
|
|
|
2020-06-03 17:04:22 +00:00
|
|
|
# cypress:
|
|
|
|
# stage: test
|
|
|
|
# services:
|
|
|
|
# - name: mdillon/postgis:11
|
|
|
|
# alias: postgres
|
2020-12-22 23:01:25 +00:00
|
|
|
# variables:
|
|
|
|
# MIX_ENV=e2e
|
2020-06-03 17:04:22 +00:00
|
|
|
# script:
|
2020-12-22 23:01:25 +00:00
|
|
|
# - mix ecto.create
|
|
|
|
# - mix ecto.migrate
|
|
|
|
# - mix run priv/repo/e2e.seed.exs
|
|
|
|
# - mix phx.server &
|
2020-06-03 17:04:22 +00:00
|
|
|
# - 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 19:17:18 +00:00
|
|
|
|
2021-01-14 14:47:12 +00:00
|
|
|
pages:
|
|
|
|
stage: deploy
|
|
|
|
script:
|
|
|
|
- mkdir public
|
2021-03-09 09:06:54 +00:00
|
|
|
- mix deps.get
|
2021-01-14 14:47:12 +00:00
|
|
|
- mix docs
|
|
|
|
- mv doc public/backend
|
2021-01-14 16:01:44 +00:00
|
|
|
# #- yarn run --cwd "js" styleguide:build
|
|
|
|
# #- mv js/styleguide public/frontend
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_BRANCH == "master"'
|
|
|
|
artifacts:
|
|
|
|
expire_in: 1 hour
|
|
|
|
paths:
|
|
|
|
- public
|
2020-11-09 09:04:55 +00:00
|
|
|
|
|
|
|
.docker: &docker
|
2021-01-14 14:47:35 +00:00
|
|
|
stage: docker
|
2020-11-09 09:04:55 +00:00
|
|
|
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:
|
2021-04-23 17:12:52 +00:00
|
|
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/docker/production/Dockerfile --destination $DOCKER_IMAGE_NAME --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP
|
2020-11-09 09:04:55 +00:00
|
|
|
|
|
|
|
build-docker-master:
|
|
|
|
<<: *docker
|
2021-01-13 08:05:39 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
|
|
|
|
when: never
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
2020-11-09 09:04:55 +00:00
|
|
|
variables:
|
|
|
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:master
|
|
|
|
|
|
|
|
build-docker-tag:
|
|
|
|
<<: *docker
|
2021-01-13 08:05:39 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_TAG
|
2020-11-09 09:04:55 +00:00
|
|
|
variables:
|
|
|
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG
|
2020-12-21 15:56:38 +00:00
|
|
|
|
2020-12-22 23:01:25 +00:00
|
|
|
package-app:
|
|
|
|
stage: package
|
2021-02-10 13:11:20 +00:00
|
|
|
variables: &release-variables
|
2020-12-21 15:56:38 +00:00
|
|
|
MIX_ENV: "prod"
|
2021-02-10 13:11:20 +00:00
|
|
|
script: &release-script
|
2021-01-12 18:47:10 +00:00
|
|
|
- mix local.hex --force
|
|
|
|
- mix local.rebar --force
|
2021-01-27 10:42:46 +00:00
|
|
|
- mix deps.get
|
2021-01-12 18:47:10 +00:00
|
|
|
- mix phx.digest
|
2021-03-16 10:07:44 +00:00
|
|
|
- mix release --path release/mobilizon
|
|
|
|
- cd release/mobilizon && ln -s lib/mobilizon-*/priv priv
|
2021-02-10 13:11:20 +00:00
|
|
|
only:
|
|
|
|
- tags@framasoft/mobilizon
|
|
|
|
artifacts:
|
|
|
|
expire_in: never
|
|
|
|
paths:
|
|
|
|
- release
|
|
|
|
|
|
|
|
package-app-dev:
|
|
|
|
stage: package
|
|
|
|
variables: *release-variables
|
|
|
|
script: *release-script
|
|
|
|
except:
|
|
|
|
- tags@framasoft/mobilizon
|
2020-12-21 15:56:38 +00:00
|
|
|
artifacts:
|
2020-12-22 23:01:25 +00:00
|
|
|
expire_in: 2 days
|
2020-12-21 15:56:38 +00:00
|
|
|
paths:
|
2021-02-10 13:11:20 +00:00
|
|
|
- release
|
2020-12-21 15:56:38 +00:00
|
|
|
|
2020-12-22 23:01:25 +00:00
|
|
|
release-upload:
|
|
|
|
stage: upload
|
2020-12-21 15:56:38 +00:00
|
|
|
image: curlimages/curl:latest
|
2021-01-13 08:05:39 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
2020-12-21 15:56:38 +00:00
|
|
|
script: |
|
2021-01-13 08:05:39 +00:00
|
|
|
APP_VERSION="${CI_COMMIT_TAG}"
|
|
|
|
APP_ASSET="${CI_PROJECT_NAME}_${APP_VERSION}_${ARCH}.tar.gz"
|
2020-12-22 23:01:25 +00:00
|
|
|
|
|
|
|
echo "Artifact: ${APP_ASSET}"
|
2021-03-16 10:07:44 +00:00
|
|
|
tar czf ${APP_ASSET} -C release mobilizon
|
2020-12-22 23:01:25 +00:00
|
|
|
ls -al ${APP_ASSET}
|
2020-12-21 15:56:38 +00:00
|
|
|
|
2020-12-22 23:01:25 +00:00
|
|
|
curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${APP_ASSET}" ${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}
|
2020-12-21 15:56:38 +00:00
|
|
|
artifacts:
|
|
|
|
expire_in: 1 day
|
|
|
|
when: on_success
|
|
|
|
paths:
|
2021-01-13 08:05:39 +00:00
|
|
|
- mobilizon_*.tar.gz
|
2021-01-27 10:43:12 +00:00
|
|
|
# release-create:
|
|
|
|
# stage: deploy
|
|
|
|
# image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
|
|
# rules:
|
|
|
|
# - if: $CI_COMMIT_TAG
|
|
|
|
# dependencies: []
|
|
|
|
# cache: {}
|
|
|
|
# script: |
|
|
|
|
# APP_VERSION="${CI_COMMIT_TAG}"
|
|
|
|
# APP_ASSET="${CI_PROJECT_NAME}_${APP_VERSION}_${ARCH}.tar.gz"
|
|
|
|
|
|
|
|
# release-cli create --name "$CI_PROJECT_TITLE v$CI_COMMIT_TAG" \
|
|
|
|
# --tag-name "$CI_COMMIT_TAG" \
|
|
|
|
# --assets-link "{\"name\":\"${APP_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}\"}"
|