-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
169 lines (153 loc) · 6 KB
/
action.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Setup Elixir Project
description: Configures Elixir, fetches dependencies, and manages build caching.
branding:
icon: "droplet"
color: "purple"
inputs:
otp-version:
type: string
description: OTP version to set up
elixir-version:
type: string
description: Elixir version to set up
version-file:
type: string
description: a versions file (e.g. as used by `asdf`), which defines inputs
version-type:
type: string
description: strict means the versions are take as-are; loose means we try
to guess versions based on semver rules
# Optional inputs
build-deps:
required: false
type: boolean
default: true
description: True if we should compile dependencies
build-app:
required: false
type: boolean
default: true
description: True if we should compile the application itself
build-flags:
required: false
type: string
default: "--all-warnings --warnings-as-errors"
description: Flags to pass to mix compile
cache-plts:
required: false
type: boolean
default: false
description: By default, we will not cache dialyzer PLTs files
install-rebar:
required: false
type: boolean
default: true
description: By default, we will install Rebar (mix local.rebar --force).
install-hex:
required: false
type: boolean
default: true
description: By default, we will install Hex (mix local.hex --force).
cache-key:
required: false
type: string
default: "v1"
description: If you need to reset the cache for some reason, you can change this key.
outputs:
otp-version:
description: "Exact OTP version selected by the BEAM setup step"
value: ${{ steps.beam.outputs.otp-version }}
elixir-version:
description: "Exact Elixir version selected by the BEAM setup step"
value: ${{ steps.beam.outputs.elixir-version }}
runs:
using: "composite"
steps:
- name: Setup Elixir
uses: erlef/setup-beam@v1
id: beam
with:
version-type: ${{ inputs.version-type }}
version-file: ${{ inputs.version-file }}
elixir-version: ${{ inputs.elixir-version }}
otp-version: ${{ inputs.otp-version }}
- name: Get deps cache
uses: actions/cache@v4
with:
path: deps/
key: deps-${{ inputs.cache-key }}-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ inputs.cache-key }}-${{ runner.os }}-
- name: Get build cache
uses: actions/cache@v4
id: build-cache
with:
path: _build/${{env.MIX_ENV}}/
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-
- name: Get Hex cache
uses: actions/cache@v4
id: hex-cache
with:
path: ~/.hex
key: build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-
# In my experience, I have issues with incremental builds maybe 1 in 100
# times that are fixed by doing a full recompile.
# In order to not waste dev time on such trivial issues (while also reaping
# the time savings of incremental builds for *most* day-to-day development),
# I force a full recompile only on builds that we retry.
- name: Clean to rule out incremental build as a source of flakiness
if: github.run_attempt != '1'
run: |
mix deps.clean --all
mix clean
shell: sh
- name: Install Rebar
run: mix local.rebar --force
shell: sh
if: inputs.install-rebar == 'true'
- name: Install Hex
run: mix local.hex --force
shell: sh
if: inputs.install-hex == 'true'
- name: Install Dependencies
run: mix deps.get
shell: sh
# Normally we'd use `mix deps.compile` here, however that incurs a large
# performance penalty when the dependencies are already fully compiled:
# https://elixirforum.com/t/github-action-cache-elixir-always-recompiles-dependencies-elixir-1-13-3/45994/12
#
# Accoring to Jose Valim at the above link `mix loadpaths` will check and
# compile missing dependencies
- name: Compile Dependencies
run: mix loadpaths
shell: sh
if: inputs.build-deps == 'true'
- name: Compile Application
run: mix compile ${{ inputs.build-flags }}
shell: sh
if: inputs.build-app == 'true'
# 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)
- name: Restore PLT cache
uses: actions/cache@v4
id: plt-cache
with:
key: plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/*.ex') }}
restore-keys: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/*.ex') }}
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-
path: priv/plts
if: inputs.cache-plts == 'true'
# Create PLTs if no cache was found.
# Always rebuild PLT when a job is retried
# (If they were cached at all, they'll be updated when we run mix dialyzer with no flags.)
- name: Create PLTs
if: (steps.plt-cache.outputs.cache-hit != 'true' || github.run_attempt != '1') && inputs.cache-plts == 'true'
shell: sh
run: mix dialyzer --plt