WIP: speed-up drone #272
1 changed files with 9 additions and 86 deletions
95
.drone.yml
95
.drone.yml
|
|
@ -14,126 +14,49 @@ trigger:
|
||||||
- push
|
- push
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: compute cache key
|
|
||||||
image: docker.io/library/elixir:1.18.3-otp-27
|
|
||||||
commands:
|
|
||||||
- mix_lock_hash=$(sha256sum mix.lock | cut -d ' ' -f 1)
|
|
||||||
- echo "$DRONE_REPO_OWNER/$DRONE_REPO_NAME/$mix_lock_hash" >> .cache_key
|
|
||||||
# Print cache key for debugging
|
|
||||||
- cat .cache_key
|
|
||||||
|
|
||||||
- name: restore-cache
|
|
||||||
image: drillster/drone-volume-cache
|
|
||||||
settings:
|
|
||||||
restore: true
|
|
||||||
mount:
|
|
||||||
- ./deps
|
|
||||||
- ./.hex-cache
|
|
||||||
ttl: 30
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /cache
|
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
image: docker.io/library/elixir:1.18.3-otp-27
|
image: docker.io/library/elixir:1.18.3-otp-27
|
||||||
depends_on:
|
|
||||||
- restore-cache
|
|
||||||
environment:
|
|
||||||
HEX_HOME: ./.hex-cache
|
|
||||||
MIX_HOME: ./.hex-cache
|
|
||||||
commands:
|
commands:
|
||||||
# Install hex and rebar (uses cached .hex-cache if available)
|
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
# Fetch dependencies
|
|
||||||
- mix deps.get
|
- mix deps.get
|
||||||
|
|
||||||
- name: wait_for_postgres
|
- name: build
|
||||||
image: docker.io/library/postgres:17.6
|
|
||||||
commands:
|
|
||||||
# Wait for postgres to become available (POSIX-compatible)
|
|
||||||
- |
|
|
||||||
i=0
|
|
||||||
while [ $i -lt 20 ]; do
|
|
||||||
if pg_isready -h postgres -U postgres; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
i=$((i + 1))
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Postgres did not become available, aborting."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: compile
|
|
||||||
image: docker.io/library/elixir:1.18.3-otp-27
|
image: docker.io/library/elixir:1.18.3-otp-27
|
||||||
depends_on:
|
depends_on:
|
||||||
- setup
|
- setup
|
||||||
environment:
|
|
||||||
HEX_HOME: ./.hex-cache
|
|
||||||
MIX_HOME: ./.hex-cache
|
|
||||||
commands:
|
commands:
|
||||||
# Compile for dev (with warnings as errors) and test environments
|
- mix local.hex --force
|
||||||
|
- mix local.rebar --force
|
||||||
- mix compile --warnings-as-errors
|
- mix compile --warnings-as-errors
|
||||||
- MIX_ENV=test mix compile --warnings-as-errors
|
|
||||||
|
|
||||||
- name: lint
|
- name: lint
|
||||||
image: docker.io/library/elixir:1.18.3-otp-27
|
image: docker.io/library/elixir:1.18.3-otp-27
|
||||||
depends_on:
|
depends_on:
|
||||||
- compile
|
- build
|
||||||
environment:
|
|
||||||
HEX_HOME: ./.hex-cache
|
|
||||||
MIX_HOME: ./.hex-cache
|
|
||||||
commands:
|
commands:
|
||||||
# Check formatting
|
- mix local.hex --force
|
||||||
|
- mix local.rebar --force
|
||||||
- mix format --check-formatted
|
- mix format --check-formatted
|
||||||
# Security checks
|
|
||||||
- mix sobelow --config
|
- mix sobelow --config
|
||||||
# Check dependencies for known vulnerabilities
|
|
||||||
- mix deps.audit
|
- mix deps.audit
|
||||||
# Check for dependencies that are not maintained anymore
|
|
||||||
- mix hex.audit
|
- mix hex.audit
|
||||||
# Provide hints for improving code quality
|
|
||||||
- mix credo
|
- mix credo
|
||||||
# Check that translations are up to date
|
|
||||||
- mix gettext.extract --check-up-to-date
|
- mix gettext.extract --check-up-to-date
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: docker.io/library/elixir:1.18.3-otp-27
|
image: docker.io/library/elixir:1.18.3-otp-27
|
||||||
depends_on:
|
depends_on:
|
||||||
- compile
|
- setup
|
||||||
- wait_for_postgres
|
|
||||||
environment:
|
environment:
|
||||||
MIX_ENV: test
|
MIX_ENV: test
|
||||||
TEST_POSTGRES_HOST: postgres
|
TEST_POSTGRES_HOST: postgres
|
||||||
TEST_POSTGRES_PORT: 5432
|
TEST_POSTGRES_PORT: 5432
|
||||||
HEX_HOME: ./.hex-cache
|
|
||||||
MIX_HOME: ./.hex-cache
|
|
||||||
commands:
|
commands:
|
||||||
# Run tests with increased parallelism
|
- mix local.hex --force
|
||||||
|
- mix local.rebar --force
|
||||||
- mix test --max-cases 16
|
- mix test --max-cases 16
|
||||||
|
|
||||||
- name: rebuild-cache
|
|
||||||
image: drillster/drone-volume-cache
|
|
||||||
depends_on:
|
|
||||||
- lint
|
|
||||||
- test
|
|
||||||
settings:
|
|
||||||
rebuild: true
|
|
||||||
mount:
|
|
||||||
- ./deps
|
|
||||||
- ./.hex-cache
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /cache
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/drone_cache
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue