-
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (153 loc) · 5.39 KB
/
elixir_checks.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Elixir CI
on:
pull_request:
types:
- opened
- edited
- synchronize
jobs:
server:
services:
postgres:
image: postgres:12.2-alpine
env:
POSTGRES_PASSWORD: postgres
# Start in localhost
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
GH_PERSONNAL_TOKEN: ${{secrets.GH_PERSONNAL_TOKEN}}
name: server checks
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Elixir
uses: erlef/setup-beam@v1
id: beam
with:
elixir-version: "1.13" # Define the elixir version [required]
otp-version: "24" # Define the OTP version [required]
- name: Restore dependencies & build cache
uses: actions/cache@v2
with:
path: |
deps
_build
key: server-${{ runner.os }}-mix-${{ vars.CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: server-${{ runner.os }}-mix-${{ vars.CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
# (Source : https://github.com/jeremyjh/dialyxir#github-actions)
- name: Restore PLT cache
uses: actions/cache@v2
id: plt_cache
with:
key: |
server-${{ runner.os }}-${{ vars.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
restore-keys: |
server-${{ runner.os }}-${{ vars.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
path: |
.plts
- name: Install dependencies
run: mix deps.get
- name: Compile project
run: mix compile
- name: Check formatting
run: mix format --check-formatted
- name: Check code style with credo
run: mix credo --strict
- name: Run tests
run: mix test
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
- name: Run dialyzer
run: mix dialyzer
application_runner:
name: application_runner checks
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
GH_PERSONNAL_TOKEN: ${{secrets.GH_PERSONNAL_TOKEN}}
services:
postgres:
# Docker Hub image
image: postgres:15.1-alpine
# Provide the password for postgres
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
# Maps tcp port 5432 on service container to the host (localhost)
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: ./libs/application_runner
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Elixir
uses: erlef/setup-beam@v1
id: beam
with:
elixir-version: "1.13" # Define the elixir version [required]
otp-version: "24" # Define the OTP version [required]
- name: Restore dependencies & build cache
uses: actions/cache@v2
with:
path: |
deps
_build
key: application-runner-${{ runner.os }}-mix-${{ vars.CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: application-runner-${{ runner.os }}-mix-${{ vars.CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
# (Source : https://github.com/jeremyjh/dialyxir#github-actions)
- name: Restore PLT cache
uses: actions/cache@v2
id: plt_cache
with:
key: |
application-runner-${{ runner.os }}-${{ vars.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
restore-keys: |
application-runner-${{ runner.os }}-${{ vars.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
path: |
.plts
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: "5.0"
mongodb-replica-set: test-rs
- name: Install dependencies
run: MIX_ENV=test mix deps.get
- name: Compile project
run: MIX_ENV=test mix compile
- name: Check formatting
run: mix format --check-formatted
- name: Check code style with credo
run: mix credo --strict
- name: Run tests
run: mix test
- name: Run dialyzer
run: MIX_ENV=test mix dialyzer --format short