Skip to content

Commit eccaad7

Browse files
committed
ci(Github): refactor elixir actions with deps caching
1 parent f1c873b commit eccaad7

10 files changed

Lines changed: 233 additions & 150 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Rust Linter and Tests
15+
name: Rust NIF
1616

1717
on:
1818
push:
@@ -22,7 +22,7 @@ on:
2222

2323
jobs:
2424
test:
25-
name: Rust tests and linter
25+
name: Tests and linter
2626
runs-on: ubuntu-latest
2727

2828
steps:

.github/workflows/ci.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Copyright 2022 Giuseppe De Palma, Matteo Trentin
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Elixir
16+
17+
on:
18+
push:
19+
branches: [main]
20+
pull_request:
21+
branches: [main]
22+
23+
env:
24+
MIX_ENV: test
25+
26+
jobs:
27+
lint:
28+
name: Lint check
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
elixir: [1.14]
33+
otp: [25]
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Setup Elixir/OTP
39+
uses: erlef/setup-beam@v1
40+
with:
41+
otp-version: "=${{ matrix.otp }}"
42+
elixir-version: ${{ matrix.elixir }}
43+
install-hex: true
44+
install-rebar: true
45+
46+
- name: Retrieve Mix Dependencies Cache
47+
uses: actions/cache@v1
48+
id: mix-cache # id to use in retrieve action
49+
with:
50+
path: deps
51+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
52+
53+
- name: Install Mix Dependencies (if deps cache miss)
54+
if: steps.mix-cache.outputs.cache-hit != 'true'
55+
run: |
56+
mix local.rebar --force
57+
mix local.hex --force
58+
mix deps.get
59+
60+
- name: Check Formatting
61+
run: mix format --check-formatted
62+
63+
- name: Run Credo
64+
run: mix credo --strict
65+
66+
unit-test:
67+
name: Unit Tests
68+
strategy:
69+
matrix:
70+
os: [ubuntu-20.04, windows-2019, macos-10.15]
71+
elixir: [1.14]
72+
otp: [25]
73+
74+
runs-on: ${{ matrix.os }}
75+
steps:
76+
- uses: actions/checkout@v3
77+
78+
- name: Setup Elixir/OTP
79+
if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }}
80+
uses: erlef/setup-beam@v1
81+
with:
82+
otp-version: "=${{ matrix.otp }}"
83+
elixir-version: ${{ matrix.elixir }}
84+
install-hex: true
85+
install-rebar: true
86+
- name: Setup Elixir/OTP
87+
if: ${{ startswith(matrix.os, 'macos') }}
88+
run: |
89+
brew install erlang
90+
brew install elixir
91+
92+
- name: Retrieve Mix Dependencies Cache
93+
uses: actions/cache@v1
94+
id: mix-cache # id to use in retrieve action
95+
with:
96+
path: deps
97+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
98+
99+
- name: Install Rebar and Hex
100+
run: |
101+
mix local.rebar --force
102+
mix local.hex --force
103+
- name: Install Mix Dependencies (if deps cache miss)
104+
if: steps.mix-cache.outputs.cache-hit != 'true'
105+
run: |
106+
mix do deps.get, deps.compile
107+
108+
- name: Run Core Unit Tests
109+
run: mix core.test
110+
111+
- name: Run Worker Tests
112+
run: mix worker.test
113+
114+
integration-test:
115+
name: Integration Tests
116+
strategy:
117+
matrix:
118+
os: [ubuntu-20.04]
119+
elixir: [1.14]
120+
otp: [25]
121+
122+
runs-on: ${{ matrix.os }}
123+
services:
124+
postgres:
125+
image: postgres:latest
126+
env:
127+
POSTGRES_USER: postgres
128+
POSTGRES_PASSWORD: postgres
129+
POSTGRES_DB: core_test
130+
ports:
131+
- 5432:5432
132+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
133+
env:
134+
MIX_ENV: test
135+
136+
steps:
137+
- uses: actions/checkout@v3
138+
139+
- name: Setup Elixir/OTP
140+
if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }}
141+
uses: erlef/setup-beam@v1
142+
with:
143+
otp-version: "=${{ matrix.otp }}"
144+
elixir-version: ${{ matrix.elixir }}
145+
install-hex: true
146+
install-rebar: true
147+
- name: Setup Elixir/OTP
148+
if: ${{ startswith(matrix.os, 'macos') }}
149+
run: |
150+
brew install erlang
151+
brew install elixir
152+
153+
- name: Retrieve Mix Dependencies Cache
154+
uses: actions/cache@v1
155+
id: mix-cache # id to use in retrieve action
156+
with:
157+
path: deps
158+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
159+
160+
- name: Install Mix Dependencies (if deps cache miss)
161+
if: steps.mix-cache.outputs.cache-hit != 'true'
162+
run: |
163+
mix local.rebar --force
164+
mix local.hex --force
165+
mix deps.get
166+
167+
- name: Run Core Integration Tests
168+
run: mix core.integration_test

.github/workflows/dialyzer.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,35 @@ jobs:
2424
dialyzer:
2525
name: Dialyzer check
2626
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
elixir: [1.14]
30+
otp: [25]
2731

2832
steps:
2933
- uses: actions/checkout@v3
30-
- name: Set up Elixir
31-
id: beam
34+
35+
- name: Setup Elixir/OTP
3236
uses: erlef/setup-beam@v1
3337
with:
34-
elixir-version: 1.14
35-
otp-version: 25
38+
otp-version: "=${{ matrix.otp }}"
39+
elixir-version: ${{ matrix.elixir }}
40+
install-hex: true
41+
install-rebar: true
42+
43+
- name: Retrieve Mix Dependencies Cache
44+
uses: actions/cache@v1
45+
id: mix-cache # id to use in retrieve action
46+
with:
47+
path: deps
48+
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
3649

37-
- name: Install Dependencies
38-
run: mix deps.get
50+
- name: Install Mix Dependencies (if deps cache miss)
51+
if: steps.mix-cache.outputs.cache-hit != 'true'
52+
run: |
53+
mix local.rebar --force
54+
mix local.hex --force
55+
mix deps.get
3956
4057
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
4158
# Cache key based on Elixir & Erlang version (also useful when running in matrix)

.github/workflows/license.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Check License Headers
15+
name: License Headers
1616

1717
on:
1818
push:
@@ -22,7 +22,7 @@ on:
2222

2323
jobs:
2424
license:
25-
name: Check license headers
25+
name: Check headers
2626
runs-on: ubuntu-latest
2727

2828
steps:

.github/workflows/lint.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)