-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (149 loc) · 5.11 KB
/
elixir-parallel-build.yml
File metadata and controls
170 lines (149 loc) · 5.11 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Elixir Parallel Build
on:
workflow_call:
inputs:
# Beam env
otp-version:
description: 'Erlang/OTP version to use.'
required: true
type: string
elixir-version:
description: 'Elixir version to use.'
required: true
type: string
# Test env
run-tests-with-compose:
description: 'Run tests in a docker-compose environment, requires a compose.yml file.'
required: false
default: false
type: boolean
run-tests-compose-container-name:
description: 'Service name, as in docker-compose.yml (default: testrunner).'
required: false
default: "testrunner"
type: string
# Coverage env
use-coveralls:
description: 'Use coveralls for code coverage analysis.'
required: false
default: false
type: boolean
# Workflow env
cache-version:
description: 'Cache version. Only change this if you *need* to reset build caches.'
required: false
default: "v1"
type: string
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup BEAM
uses: erlef/setup-beam@v1.10
with:
otp-version: ${{ inputs.otp-version }}
elixir-version: ${{ inputs.elixir-version }}
- name: Cache deps
uses: actions/cache@v3
with:
path: deps
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-
- name: Get dependencies
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
- name: Cache _build
uses: actions/cache@v3
with:
path: _build/dev/lib
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-build-
- name: Compile
run: mix compile
check:
name: Check
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup BEAM
uses: erlef/setup-beam@v1.10
with:
otp-version: ${{ inputs.otp-version }}
elixir-version: ${{ inputs.elixir-version }}
- name: Cache deps
uses: actions/cache@v3
with:
path: deps
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-
- name: Cache _build
uses: actions/cache@v3
with:
path: _build/dev/lib
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-build-
- name: Check dependencies
run: mix deps.unlock --check-unused
- name: Check format
run: mix format --check-formatted
- name: Run credo
run: mix credo --strict
- name: Cache PLTs
uses: actions/cache@v3
with:
path: |
_build/*/*.plt
_build/*/*.plt.hash
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-plt-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-plt-
- name: Run dialyzer
run: mix dialyzer
test:
name: Test
needs: build
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup BEAM
uses: erlef/setup-beam@v1.15.4
with:
otp-version: ${{ inputs.otp-version }}
elixir-version: ${{ inputs.elixir-version }}
- name: Cache deps
uses: actions/cache@v3
with:
path: deps
key: ${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ inputs.cache-version }}-otp-${{ inputs.otp-version }}-deps-
- name: Run ExUnit
id: run-tests
if: ${{ inputs.run-tests-with-compose == false }}
run: mix test --cover
- name: Run ExUnit (/w docker-compose)
id: run-tests-w-compose
if: ${{ inputs.run-tests-with-compose == true }}
env:
# Pass workflow params to use in docker-compose.yml
DEV_IMAGE_TAG: ${{ inputs.run-tests-compose-container-name }}-dev
ELIXIR_VERSION: ${{ inputs.elixir-version }}
OTP_VERSION: ${{ inputs.otp-version }}
# Enable buildkit extensions in docker compose
COMPOSE_DOCKER_CLI_BUILD: true
DOCKER_BUILDKIT: true
run: |
docker-compose run --use-aliases --rm ${{ inputs.run-tests-compose-container-name }} \
mix do local.hex --force, local.rebar --force, test --cover