Skip to content

Commit

Permalink
[PRIMA-8897]: Repo Hex + pipeline ex_fuzzywuzzy (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugenioLaghi authored Mar 31, 2021
1 parent dd09d2c commit 7903a13
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 2 deletions.
285 changes: 285 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
---
kind: pipeline
name: default

platform:
os: linux
arch: amd64

clone:
disable: true

steps:
- name: git-clone
image: public.ecr.aws/prima/drone-git:1.3-3
environment:
PLUGIN_DEPTH: 5

- name: cache-restore
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- . /etc/profile.d/ecs-credentials-endpoint
- cache-restore
environment:
BUCKET_NAME: prima-ci-cache
volumes:
- name: ecs
path: /etc/profile.d/ecs-credentials-endpoint
- name: docker
path: /var/run/docker.sock
- name: docker-conf
path: /root/.docker
depends_on:
- git-clone

- name: check-secrets
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- . /etc/profile.d/ecs-credentials-endpoint
- check-secrets-grants
volumes:
- name: ecs
path: /etc/profile.d/ecs-credentials-endpoint
depends_on:
- git-clone

- name: check-public-docker-images
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- check-public-docker-images
depends_on:
- git-clone

- name: build-image
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- sed -i 's/USER app/USER root/g' ./Dockerfile
- docker build -t prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT} ./
volumes:
- name: docker
path: /var/run/docker.sock
- name: docker-conf
path: /root/.docker
depends_on:
- cache-restore

- name: elixir-dependencies
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix deps.get
depends_on:
- build-image

- name: elixir-compile
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix compile --all-warnings --warnings-as-errors --ignore-module-conflict --debug-info
environment:
MIX_ENV: test
depends_on:
- elixir-dependencies

- name: elixir-dep-check
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix deps.unlock --check-unused
environment:
MIX_ENV: test
depends_on:
- elixir-compile

- name: elixir-format
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix format --check-formatted
environment:
MIX_ENV: test
depends_on:
- elixir-compile

- name: elixir-test
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix test
environment:
MIX_ENV: test
depends_on:
- elixir-compile

- name: elixir-credo
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix credo -a --strict
environment:
MIX_ENV: test
depends_on:
- elixir-compile

- name: elixir-dialyzer
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- mix dialyzer
environment:
MIX_ENV: test
depends_on:
- elixir-compile

- name: cache-save
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- . /etc/profile.d/ecs-credentials-endpoint
- cache-save _build deps
environment:
BUCKET_NAME: prima-ci-cache
volumes:
- name: ecs
path: /etc/profile.d/ecs-credentials-endpoint
- name: docker
path: /var/run/docker.sock
- name: docker-conf
path: /root/.docker
when:
branch:
- master
depends_on:
- elixir-compile
- elixir-format
- elixir-test
- elixir-credo
- elixir-dialyzer
- elixir-dep-check

volumes:
- name: docker
host:
path: /var/run/docker.sock
- name: ecs
host:
path: /etc/profile.d/ecs-credentials-endpoint
- name: docker-conf
host:
path: /home/ec2-user/.docker

trigger:
event:
- push

---
kind: pipeline
name: build-production

platform:
os: linux
arch: amd64

clone:
disable: true

steps:
- name: git-clone
image: public.ecr.aws/prima/drone-git:1.3-3
environment:
PLUGIN_DEPTH: 5

- name: cache-restore
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- . /etc/profile.d/ecs-credentials-endpoint
- cache-restore
environment:
BUCKET_NAME: prima-ci-cache
volumes:
- name: ecs
path: /etc/profile.d/ecs-credentials-endpoint
- name: docker
path: /var/run/docker.sock
- name: docker-conf
path: /root/.docker
depends_on:
- git-clone

- name: build-image
image: public.ecr.aws/prima/drone-tools:1.20.1
commands:
- sed -i 's/USER app/USER root/g' ./Dockerfile
- docker build -t prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT} ./
volumes:
- name: docker
path: /var/run/docker.sock
- name: docker-conf
path: /root/.docker
depends_on:
- cache-restore

- name: build-production
image: prima/ex_fuzzywuzzy-ci:${DRONE_COMMIT}
commands:
- . /etc/profile.d/ecs-credentials-endpoint
- ./deploy/build production
environment:
HEX_AUTH_KEY:
from_secret: hex_auth_key
MIX_ENV: dev
volumes:
- name: ecs
path: /etc/profile.d/ecs-credentials-endpoint
depends_on:
- build-image

volumes:
- name: docker
host:
path: /var/run/docker.sock
- name: ecs
host:
path: /etc/profile.d/ecs-credentials-endpoint
- name: docker-conf
host:
path: /home/ec2-user/.docker

trigger:
event:
- tag
ref:
- refs/tags/*.*.*

---
kind: pipeline
name: email-failure

platform:
os: linux
arch: amd64

clone:
disable: true

steps:
- name: email-failure
image: public.ecr.aws/prima/drone-email
settings:
from: [email protected]
host: email-smtp.eu-west-1.amazonaws.com
environment:
PLUGIN_PASSWORD:
from_secret: email_password
PLUGIN_USERNAME:
from_secret: email_username

trigger:
status:
- failure
target:
exclude:
- qa
- qa-stack

depends_on:
- default
- build-production

---
kind: signature
hmac: eee50f96aef7f6c6272ad55f941aa15d116cc3693cb651cdb9a4abc1f6352785

...
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM elixir:1.11.3
FROM public.ecr.aws/prima/elixir:1.11.2-1

WORKDIR /code

ENTRYPOINT ["/code/entrypoint"]
USER app

COPY ["entrypoint", "/entrypoint"]

ENTRYPOINT ["/entrypoint"]
29 changes: 29 additions & 0 deletions deploy/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

#############################################################################
# #
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN #
# #
#############################################################################

# script exit when a command fails
set -o errexit
# catch a command error in pipe execution
set -o pipefail
# exit when try to use undeclared variables
# set -o nounset
# print and expand each command to stdout before executing it
set -o xtrace

if [ $# -eq 0 ]; then
echo "Missing required argument: environment"
exit 1
fi

export ENV=$1
export AWS_DEFAULT_REGION="eu-west-1"
export VERSION="${DRONE_TAG:-$DRONE_COMMIT_SHA}"

mix hex.config api_key "$HEX_AUTH_KEY"
mix hex.user whoami
mix hex.publish --yes

0 comments on commit 7903a13

Please sign in to comment.