-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (94 loc) · 3.35 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
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
main:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- elixir: "1.16.2"
otp: "26.1"
lint: true
- elixir: "1.15.6"
otp: "26.1"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- uses: actions/cache@v2
with:
path: |
artifacts/deps
artifacts/build
key: ${{ runner.os }}-mix-${{matrix.elixir}}-${{matrix.otp}}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
- name: Configure environment
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
git config --global init.defaultBranch "main"
- name: Get root dependencies
run: mix deps.get
- name: Workspace checks
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.check
if: ${{ matrix.lint }}
- name: Set environment variables
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "MODIFIED_ARGS=--modified --base origin/main" >> $GITHUB_ENV
echo "AFFECTED_ARGS=--affected --base origin/main" >> $GITHUB_ENV
else
echo "MODIFIED_ARGS=" >> $GITHUB_ENV
echo "AFFECTED_ARGS=" >> $GITHUB_ENV
fi
- name: Get workspace dependencies
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t deps.get ${{env.AFFECTED_ARGS}}
- name: Compile dependencies
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t deps.compile ${{env.AFFECTED_ARGS}} -- --skip-local-deps
- name: Compile with warnings enabled
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t compile ${{env.AFFECTED_ARGS}} -- --force --warnings-as-errors
if: ${{ matrix.lint }}
- name: Check code formatted
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t format ${{env.MODIFIED_ARGS}} -- --check-formatted
if: ${{ matrix.lint }}
- name: Tests
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t test ${{env.AFFECTED_ARGS}} -- --cover --warnings-as-errors
- name: Coverage
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.test.coverage ${{env.AFFECTED_ARGS}}
- name: Check docs
run: |
shopt -s expand_aliases
alias mix='elixir --erl "-elixir ansi_enabled true" -S mix'
mix workspace.run -t docs ${{env.MODIFIED_ARGS}} -- -f html
if: ${{ matrix.lint }}