Skip to content

Instantly share code, notes, and snippets.

@cblavier
Created October 7, 2019 16:54
Show Gist options
  • Save cblavier/db7fb947aa8158449608557faafb1216 to your computer and use it in GitHub Desktop.
Save cblavier/db7fb947aa8158449608557faafb1216 to your computer and use it in GitHub Desktop.
SemaphoreCI pipeline
version: v1.0
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
fail_fast:
stop:
when: "true"
auto_cancel:
running:
when: "true"
execution_time_limit:
minutes: 20
global_job_config:
secrets:
- name: ssh_key
prologue:
commands:
- chmod 0600 ~/.keys/*
- ssh-add ~/.keys/*
- checkout
- git submodule init
- git submodule update
env_vars:
- name: MIX_ENV
value: test
blocks:
- name: Code compilation
dependencies: []
task:
prologue:
commands:
- .semaphore/setup_ci_elixir
- sem-version elixir 1.8.2
- cache restore deps-$(checksum mix.lock)
- cache restore build-$(checksum mix.lock)
jobs:
- name: compile
commands:
- mix deps.get
- mix compile --warnings-as-errors
- cache delete deps-$(checksum mix.lock) && cache store deps-$(checksum mix.lock) deps
- cache delete build-$(checksum mix.lock) && cache store build-$(checksum mix.lock) _build
- name: Assets compilation
dependencies: []
task:
prologue:
commands:
- .semaphore/setup_ci_elixir
- sem-version elixir 1.8.2
- sem-version node 9.6.1
- cache restore deps-$(checksum mix.lock)
jobs:
- name: assets compilation
commands:
- mix deps.get
- echo node-modules-$(checksum assets/package-lock.json) > NODE_CACHE_KEY
- cache restore `cat NODE_CACHE_KEY`
- cd assets; npm install; cd -
- cache store `cat NODE_CACHE_KEY` assets/node_modules
- cd assets; npm run compile-test; cd -
- cache delete assets && cache store assets priv/static
- name: Code checks
dependencies: ["Code compilation"]
task:
prologue:
commands:
- .semaphore/setup_ci_elixir
- sem-version elixir 1.8.2
- cache restore deps-$(checksum mix.lock)
- cache restore build-$(checksum mix.lock)
jobs:
- name: mix credo
commands:
- mix credo
- name: mix format
commands:
- mix format --check-formatted mix.exs config/**/*.{ex,exs} apps/**/*.{ex,exs}
- name: Tests
dependencies: ["Code compilation", "Assets compilation"]
task:
prologue:
commands:
- .semaphore/setup_ci_elixir
- sem-version elixir 1.8.2
- cache restore deps-$(checksum mix.lock)
- cache restore build-$(checksum mix.lock)
- cache restore assets
jobs:
- name: mix test
parallelism: 6
commands:
- docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASS=postgres -e POSTGRES_DBNAME=test kartoza/postgis:10.0-2.4
- chromedriver &
- mix ecto.create
- mix ecto.migrate
- mix n_test $SEMAPHORE_JOB_INDEX $SEMAPHORE_JOB_COUNT || mix n_test $SEMAPHORE_JOB_INDEX $SEMAPHORE_JOB_COUNT --failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment