chore: Streamline CI config
This commit is contained in:
parent
ab12492fc7
commit
d3fff943af
3 changed files with 2 additions and 87 deletions
|
@ -1,6 +1,4 @@
|
||||||
stages:
|
stages:
|
||||||
- prebuild
|
|
||||||
- asset_dependencies
|
|
||||||
- test
|
- test
|
||||||
- deploy_tags
|
- deploy_tags
|
||||||
- deploy
|
- deploy
|
||||||
|
@ -15,106 +13,31 @@ variables:
|
||||||
# fetch & clean the repo rather than completely cloning (faster)
|
# fetch & clean the repo rather than completely cloning (faster)
|
||||||
GIT_STRATEGY: fetch
|
GIT_STRATEGY: fetch
|
||||||
|
|
||||||
# Build the app once and cache it so that we can have fast compiles in test
|
|
||||||
# and Docker built steps
|
|
||||||
prebuild:
|
|
||||||
stage: prebuild
|
|
||||||
image: "elixir:1.10"
|
|
||||||
cache:
|
|
||||||
key:
|
|
||||||
files:
|
|
||||||
- mix.lock
|
|
||||||
paths:
|
|
||||||
- _build/
|
|
||||||
- deps/
|
|
||||||
script:
|
|
||||||
- script/ci-set-timestamps
|
|
||||||
- mix local.hex --force
|
|
||||||
- mix local.rebar --force
|
|
||||||
- mix deps.get
|
|
||||||
- mix deps.compile
|
|
||||||
- mix compile
|
|
||||||
# Make results available to other jobs
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- deps/phoenix
|
|
||||||
- deps/phoenix_html
|
|
||||||
exclude:
|
|
||||||
- deps/
|
|
||||||
|
|
||||||
fetch_asset_dependencies:
|
|
||||||
stage: asset_dependencies
|
|
||||||
image: "node:15.0"
|
|
||||||
needs:
|
|
||||||
- prebuild
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
cache:
|
|
||||||
key:
|
|
||||||
files:
|
|
||||||
- apps/app/assets/package-lock.json
|
|
||||||
paths:
|
|
||||||
- apps/app/assets/node_modules/
|
|
||||||
script:
|
|
||||||
- cd apps/app/assets/ && npm install
|
|
||||||
# Make results available to other jobs
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- apps/app/assets/node_modules
|
|
||||||
exclude:
|
|
||||||
- apps/app/assets/node_modules
|
|
||||||
|
|
||||||
# Test stage. Runs various tests and speculatively builds docker image in
|
# Test stage. Runs various tests and speculatively builds docker image in
|
||||||
# parallel, in case the build passes.
|
# parallel, in case the build passes.
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
needs:
|
|
||||||
- prebuild
|
|
||||||
image: "elixir:1.10"
|
image: "elixir:1.10"
|
||||||
services:
|
services:
|
||||||
- name: postgres:12
|
- name: postgres:12
|
||||||
cache:
|
script: script/cibuild
|
||||||
key:
|
|
||||||
files:
|
|
||||||
- mix.lock
|
|
||||||
paths:
|
|
||||||
- _build/
|
|
||||||
- deps/
|
|
||||||
script:
|
|
||||||
- script/ci-set-timestamps
|
|
||||||
- script/cibuild
|
|
||||||
|
|
||||||
build_image_for_commit:
|
build_image_for_commit:
|
||||||
stage: test
|
stage: test
|
||||||
needs:
|
|
||||||
- fetch_asset_dependencies
|
|
||||||
- prebuild
|
|
||||||
image: "docker:20.10"
|
image: "docker:20.10"
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
services:
|
services:
|
||||||
- name: docker:20.10-dind
|
- name: docker:20.10-dind
|
||||||
cache:
|
|
||||||
key:
|
|
||||||
files:
|
|
||||||
- mix.lock
|
|
||||||
paths:
|
|
||||||
- _build/
|
|
||||||
- deps/
|
|
||||||
script:
|
script:
|
||||||
- script/ci-set-timestamps
|
|
||||||
- ls -la _build
|
|
||||||
- docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
|
- docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
|
||||||
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
||||||
# This enables fast parallel builds
|
# This enables fast parallel builds
|
||||||
- export DOCKER_BUILDKIT=1
|
- export DOCKER_BUILDKIT=1
|
||||||
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --build-arg BUILDKIT_INLINE_CACHE=1 .
|
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
|
||||||
# Push the commit SHA tagged version to registry. We will later choose to tag that as stable
|
# Push the commit SHA tagged version to registry. We will later choose to tag that as stable
|
||||||
# if everything passes.
|
# if everything passes.
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||||
# This copies the elixir build artifacts for deps and app so that we can cache them
|
|
||||||
- docker cp `docker create $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA`:/root/app/_build/prod _build
|
|
||||||
- ls -la _build
|
|
||||||
|
|
||||||
# If tests pass, tag the commit and update package versions
|
# If tests pass, tag the commit and update package versions
|
||||||
deploy_to_tags:
|
deploy_to_tags:
|
||||||
|
|
|
@ -26,8 +26,6 @@ ADD ./apps/admin/mix.exs /root/app/apps/admin/
|
||||||
ADD ./apps/app/mix.exs /root/app/apps/app/
|
ADD ./apps/app/mix.exs /root/app/apps/app/
|
||||||
ADD ./apps/content/mix.exs /root/app/apps/content/
|
ADD ./apps/content/mix.exs /root/app/apps/content/
|
||||||
ADD ./apps/core/mix.exs /root/app/apps/core/
|
ADD ./apps/core/mix.exs /root/app/apps/core/
|
||||||
ADD ./deps /root/app/deps
|
|
||||||
ADD ./_build /root/app/_build
|
|
||||||
RUN mix deps.get
|
RUN mix deps.get
|
||||||
RUN mix deps.compile
|
RUN mix deps.compile
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
BUILD_TIMESTAMP=`date -d $CI_COMMIT_TIMESTAMP +%Y%m%d%H%M.%S`
|
|
||||||
|
|
||||||
echo $BUILD_TIMESTAMP
|
|
||||||
touch -t $BUILD_TIMESTAMP ../apps/**/*.ex ../apps/**/*.exs ../config/**/*.ex ../config/**/*.exs ../mix.exs
|
|
Loading…
Reference in a new issue