Merge branch 'feature/353' into 'master'
Release Elixir and frontend assets as part of the release Closes #353 See merge request framasoft/mobilizon!774
This commit is contained in:
commit
fde367568d
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,6 +14,7 @@ erl_crash.dump
|
||||||
# secrets files as long as you replace their contents by environment
|
# secrets files as long as you replace their contents by environment
|
||||||
# variables.
|
# variables.
|
||||||
/config/*.secret.exs
|
/config/*.secret.exs
|
||||||
|
/config/releases.exs
|
||||||
|
|
||||||
/setup_db.psql
|
/setup_db.psql
|
||||||
|
|
||||||
|
|
173
.gitlab-ci.yml
173
.gitlab-ci.yml
|
@ -1,13 +1,17 @@
|
||||||
image: tcitworld/mobilizon-ci
|
image: tcitworld/mobilizon-ci
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- install
|
||||||
- check
|
- check
|
||||||
|
- build
|
||||||
- test
|
- test
|
||||||
|
- package
|
||||||
|
- upload
|
||||||
- deploy
|
- deploy
|
||||||
- docker
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
MIX_ENV: "test"
|
MIX_ENV: "test"
|
||||||
|
YARN_CACHE_FOLDER: "js/.yarn"
|
||||||
# DB Variables for Postgres / Postgis
|
# DB Variables for Postgres / Postgis
|
||||||
POSTGRES_DB: mobilizon_test
|
POSTGRES_DB: mobilizon_test
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
|
@ -20,102 +24,116 @@ variables:
|
||||||
MOBILIZON_DATABASE_HOST: $POSTGRES_HOST
|
MOBILIZON_DATABASE_HOST: $POSTGRES_HOST
|
||||||
GEOLITE_CITIES_PATH: "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
GEOLITE_CITIES_PATH: "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
||||||
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
|
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
|
||||||
|
# Release elements
|
||||||
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}"
|
||||||
|
ARCH: "amd64"
|
||||||
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
key: ${CI_COMMIT_REF_SLUG}
|
key: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
|
||||||
paths:
|
paths:
|
||||||
- ~/.cache/Cypress
|
- ~/.cache/Cypress
|
||||||
- _build/
|
|
||||||
- deps/
|
|
||||||
- js/node_modules
|
|
||||||
- cache/Cypress
|
- cache/Cypress
|
||||||
|
- deps/
|
||||||
|
- _build/
|
||||||
|
- js/node_modules
|
||||||
|
- 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:
|
||||||
|
- yarn --cwd "js" install --frozen-lockfile
|
||||||
|
- mix deps.get
|
||||||
|
- mix compile
|
||||||
|
|
||||||
lint-elixir:
|
lint-elixir:
|
||||||
stage: check
|
stage: check
|
||||||
script:
|
script:
|
||||||
- export EXITVALUE=0
|
- export EXITVALUE=0
|
||||||
- mix deps.get
|
|
||||||
- mix credo --strict -a || export EXITVALUE=1
|
- mix credo --strict -a || export EXITVALUE=1
|
||||||
- mix format --check-formatted --dry-run || export EXITVALUE=1
|
- mix format --check-formatted --dry-run || export EXITVALUE=1
|
||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
|
|
||||||
lint-front:
|
lint-front:
|
||||||
image: node:14
|
|
||||||
stage: check
|
stage: check
|
||||||
before_script:
|
before_script:
|
||||||
- export EXITVALUE=0
|
- export EXITVALUE=0
|
||||||
- cd js
|
- cd js
|
||||||
script:
|
script:
|
||||||
- yarn install
|
|
||||||
- yarn run lint || export EXITVALUE=1
|
- yarn run lint || export EXITVALUE=1
|
||||||
- yarn run prettier -c . || export EXITVALUE=1
|
- yarn run prettier -c . || export EXITVALUE=1
|
||||||
- yarn run build:assets || export EXITVALUE=1
|
|
||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
|
|
||||||
|
build-frontend:
|
||||||
|
stage: build
|
||||||
|
before_script:
|
||||||
|
- apt update
|
||||||
|
- apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant
|
||||||
|
script:
|
||||||
|
- yarn --cwd "js" run build
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 day
|
expire_in: 5 days
|
||||||
when: on_success
|
|
||||||
paths:
|
paths:
|
||||||
- priv/static
|
- priv/static
|
||||||
|
needs:
|
||||||
|
- lint-front
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
stage: check
|
stage: check
|
||||||
script:
|
script:
|
||||||
- export EXITVALUE=0
|
- export EXITVALUE=0
|
||||||
- mix deps.get
|
|
||||||
- mix hex.outdated || export EXITVALUE=1
|
- mix hex.outdated || export EXITVALUE=1
|
||||||
- cd js
|
- yarn --cwd "js" outdated || export EXITVALUE=1
|
||||||
- yarn outdated || export EXITVALUE=1
|
|
||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
needs:
|
||||||
|
- install
|
||||||
|
|
||||||
exunit:
|
exunit:
|
||||||
stage: test
|
stage: test
|
||||||
services:
|
services:
|
||||||
- name: mdillon/postgis:11
|
- name: mdillon/postgis:11
|
||||||
alias: postgres
|
alias: postgres
|
||||||
|
variables:
|
||||||
|
MIX_ENV: test
|
||||||
before_script:
|
before_script:
|
||||||
- cd js
|
- mix ecto.create
|
||||||
- yarn install
|
- mix ecto.migrate
|
||||||
- yarn run build:assets
|
|
||||||
- cd ../
|
|
||||||
- mix deps.get
|
|
||||||
- MIX_ENV=test mix ecto.create
|
|
||||||
- MIX_ENV=test mix ecto.migrate
|
|
||||||
dependencies:
|
|
||||||
- lint-elixir
|
|
||||||
script:
|
script:
|
||||||
- mix coveralls
|
- mix coveralls
|
||||||
|
|
||||||
jest:
|
jest:
|
||||||
stage: test
|
stage: test
|
||||||
before_script:
|
needs:
|
||||||
- cd js
|
|
||||||
- yarn install
|
|
||||||
dependencies:
|
|
||||||
- lint-front
|
- lint-front
|
||||||
|
before_script:
|
||||||
|
- yarn add --dev jest-junit
|
||||||
script:
|
script:
|
||||||
- yarn run test:unit --no-color
|
- yarn --cwd "js" run test:unit --no-color --ci --reporters=default --reporters=jest-junit
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
- js/coverage
|
- js/coverage
|
||||||
|
reports:
|
||||||
|
junit:
|
||||||
|
- js/junit.xml
|
||||||
expire_in: 30 days
|
expire_in: 30 days
|
||||||
|
|
||||||
# cypress:
|
# cypress:
|
||||||
# stage: test
|
# stage: test
|
||||||
# services:
|
# services:
|
||||||
# - name: mdillon/postgis:11
|
# - name: mdillon/postgis:11
|
||||||
# alias: postgres
|
# alias: postgres
|
||||||
|
# variables:
|
||||||
|
# MIX_ENV=e2e
|
||||||
# script:
|
# script:
|
||||||
# - mix deps.get
|
# - mix ecto.create
|
||||||
# - cd js
|
# - mix ecto.migrate
|
||||||
# - yarn install
|
# - mix run priv/repo/e2e.seed.exs
|
||||||
# - npx cypress install # just to be sure
|
# - mix phx.server &
|
||||||
# - 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
|
# - cd js
|
||||||
# - npx wait-on http://localhost:4000
|
# - npx wait-on http://localhost:4000
|
||||||
# - if [ -z "$CYPRESS_KEY" ]; then npx cypress run; else npx cypress run --record --parallel --key $CYPRESS_KEY; fi
|
# - if [ -z "$CYPRESS_KEY" ]; then npx cypress run; else npx cypress run --record --parallel --key $CYPRESS_KEY; fi
|
||||||
|
@ -131,22 +149,19 @@ jest:
|
||||||
# # - mkdir public
|
# # - mkdir public
|
||||||
# # Mobilizon documentation is now on https://framagit.org/framasoft/joinmobilizon/documentation
|
# # 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 docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172
|
||||||
# # - mix deps.get
|
|
||||||
# # - mix docs
|
# # - mix docs
|
||||||
# # - mv doc public/backend
|
# # - mv doc public/backend
|
||||||
# #- cd js
|
# #- yarn run --cwd "js" styleguide:build
|
||||||
# #- yarn install
|
# #- mv js/styleguide public/frontend
|
||||||
# #- yarn run styleguide:build
|
# rules:
|
||||||
# #- mv styleguide ../public/frontend
|
# - if: '$CI_COMMIT_BRANCH == "master"'
|
||||||
# only:
|
|
||||||
# - master
|
|
||||||
# artifacts:
|
# artifacts:
|
||||||
# expire_in: 1 hour
|
# expire_in: 1 hour
|
||||||
# paths:
|
# paths:
|
||||||
# - public
|
# - public
|
||||||
|
|
||||||
.docker: &docker
|
.docker: &docker
|
||||||
stage: docker
|
stage: build
|
||||||
cache: {}
|
cache: {}
|
||||||
image:
|
image:
|
||||||
name: gcr.io/kaniko-project/executor:debug
|
name: gcr.io/kaniko-project/executor:debug
|
||||||
|
@ -159,14 +174,72 @@ jest:
|
||||||
|
|
||||||
build-docker-master:
|
build-docker-master:
|
||||||
<<: *docker
|
<<: *docker
|
||||||
only:
|
rules:
|
||||||
- schedules
|
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
|
||||||
|
when: never
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
variables:
|
variables:
|
||||||
DOCKER_IMAGE_NAME: framasoft/mobilizon:master
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:master
|
||||||
|
|
||||||
build-docker-tag:
|
build-docker-tag:
|
||||||
<<: *docker
|
<<: *docker
|
||||||
only:
|
rules:
|
||||||
- tags
|
- if: '$CI_PROJECT_NAMESPACE != "framasoft"'
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
variables:
|
variables:
|
||||||
DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG
|
DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG
|
||||||
|
|
||||||
|
package-app:
|
||||||
|
stage: package
|
||||||
|
before_script:
|
||||||
|
- apt update
|
||||||
|
- apt install -y --no-install-recommends build-essential git cmake
|
||||||
|
variables:
|
||||||
|
MIX_ENV: "prod"
|
||||||
|
script:
|
||||||
|
- mix local.hex --force
|
||||||
|
- mix local.rebar --force
|
||||||
|
- cp docker/production/releases.exs ./config/
|
||||||
|
- mix phx.digest
|
||||||
|
- mix release
|
||||||
|
artifacts:
|
||||||
|
expire_in: 2 days
|
||||||
|
paths:
|
||||||
|
- _build/prod/rel
|
||||||
|
|
||||||
|
release-upload:
|
||||||
|
stage: upload
|
||||||
|
image: curlimages/curl:latest
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
|
script: |
|
||||||
|
APP_VERSION="${CI_COMMIT_TAG}"
|
||||||
|
APP_ASSET="${CI_PROJECT_NAME}_${APP_VERSION}_${ARCH}.tar.gz"
|
||||||
|
|
||||||
|
echo "Artifact: ${APP_ASSET}"
|
||||||
|
tar czf ${APP_ASSET} -C _build/prod/rel mobilizon
|
||||||
|
ls -al ${APP_ASSET}
|
||||||
|
|
||||||
|
curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${APP_ASSET}" ${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 day
|
||||||
|
when: on_success
|
||||||
|
paths:
|
||||||
|
- mobilizon_*.tar.gz
|
||||||
|
|
||||||
|
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}\"}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue