-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (106 loc) · 3.26 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ci:
runs-on: ubuntu-latest
env:
MIX_ENV: gha
steps:
- uses: erlef/setup-beam@v1
with:
elixir-version: 1.13
otp-version: 24
# Check out the code.
- name: Checkout
uses: actions/checkout@v3
- name: Add hosts entries
run: |
echo "
127.0.0.1 rabbit
127.0.0.1 rabbit_two
" | sudo tee /etc/hosts
# Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Define how to cache the `_build` directory.
# After the first run, this speeds up tests runs a lot.
# This includes not re-compiling our project's downloaded deps every run.
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
# Conditionally bust the cache when job is re-run.
# Sometimes, we may have issues with incremental builds that are fixed by doing a full recompile.
# In order to not waste dev time on such trivial issues force a full recompile only on builds that are retried.
# See https://fly.io/docs/elixir/advanced-guides/github-actions-elixir-ci-cd/ for more infos
- name: Clean to rule out incremental build as a source of flakiness
if: github.run_attempt != '1'
run: |
mix deps.clean --all
mix clean
- name: Deps get
run: mix deps.get
- name: Dependencies Check
run: mix deps.unlock --check-unused
- name: Compiles without warnings
run: mix compile --warnings-as-errors
- name: Check Formatting
run: mix format --check-formatted
- name: Credo
run: mix credo -a --strict
- name: Test
run: mix test
- name: Dialyzer
run: mix dialyzer
services:
rabbit1:
image: rabbitmq:3.11.26-management
ports:
- 5672:5672
- 15672:15672
env:
RABBITMQ_DEFAULT_VHOST: /
RABBITMQ_DEFAULT_PASS: amqpx
RABBITMQ_DEFAULT_USER: amqpx
options: --name rabbit
rabbit2:
image: rabbitmq:3.11.26-management
ports:
- 5673:5672
- 15673:15672
env:
RABBITMQ_DEFAULT_VHOST: /two
RABBITMQ_DEFAULT_PASS: amqpx
RABBITMQ_DEFAULT_USER: amqpx
options: --name rabbit_two
alls-green:
if: always()
needs:
- ci
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}