-
Notifications
You must be signed in to change notification settings - Fork 143
168 lines (139 loc) · 5.15 KB
/
main.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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test (Elixir ${{ matrix.elixir }} | Erlang/OTP ${{ matrix.otp }})
# We need Ubuntu 20.04 for now to test old OTP and Elixir versions.
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- otp: 27.0
elixir: 1.17.0
- otp: 24.3
elixir: 1.12.3
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout this repo
uses: actions/checkout@v2
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.17.3"
repo-token: ${{ secrets.GITHUB_TOKEN }} # to avoid rate limiting
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v2
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}-elixir-${{ matrix.elixir }}-erlang-${{ matrix.otp }}
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: mix deps.get
# 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: Cache Dialyzer's PLT
uses: actions/cache@v2
id: cache-plt
with:
path: priv/plts
key: ${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-plt
# Create PLTs if no cache was found
- name: Create PLTs
if: steps.cache-plt.outputs.cache-hit != 'true'
run: mix dialyzer --plt
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}
- name: Compile with --warnings-as-errors
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}
- name: Check mix format
run: mix format --check-formatted
if: ${{ matrix.lint }}
- name: Run tests with coverage
run: mix coveralls.github
if: ${{ matrix.coverage }}
- name: Run tests without coverage
run: mix test --trace
if: ${{ !matrix.coverage }}
- name: Run Dialyzer
run: mix dialyzer
- name: Compile .proto files to Elixir with protoc
if: ${{ matrix.integration }}
env:
PROTO_BENCH: ./deps/google_protobuf/benchmarks
run: |
mix gen_test_protos
mix gen_bootstrap_protos
- name: Run integration tests
if: ${{ matrix.integration }}
run: mix test --only integration
- name: Check that generated files did not change
if: ${{ matrix.integration }}
run: |
rm -rf ./google_protobuf
if [[ -n "$(git status -uno --porcelain)" ]]; then
echo "CHANGES TO THE CODE SEEM TO CHANGE THE GENERATED .pb.ex FILES."
echo "MAKE SURE TO RUN THESE TASKS BEFORE MERGING:"
echo ""
echo " mix do gen_bootstrap_protos, gen_test_protos"
echo ""
echo "Run the above commands and `git diff` to verify the changes"
exit 1
else
echo "Generated .pb.ex are up to date"
fi
conformance-test:
name: Conformance test (Elixir ${{matrix.elixir}} | Erlang/OTP ${{matrix.otp}})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
otp: [24.2]
elixir: [1.14]
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Cache Elixir dependencies with compiled protoc
id: cache-deps-with-built-protoc
uses: actions/cache@v2
with:
path: deps
key: ${{ runner.os }}-mix-deps-with-protoc-${{ hashFiles('**/mix.lock') }}
- name: Install dependencies
if: steps.cache-deps-with-built-protoc.outputs.cache-hit != 'true'
run: mix deps.get
- name: Update and install OS dependencies to build protoc locally
if: steps.cache-deps-with-built-protoc.outputs.cache-hit != 'true'
# Dependencies from https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
run: sudo apt-get update && sudo apt-get install -y git cmake curl make g++
# This builds protoc inside deps (not inside _build), so we can cache that whole directory.
- name: Build protoc and the conformance runner from the local Protobuf dependency
if: steps.cache-deps-with-built-protoc.outputs.cache-hit != 'true'
run: mix build_conformance_runner
# We always need to do this, even if the cache hits.
- name: Add protoc to the PATH
run: echo "$PWD/deps/google_protobuf" >> $GITHUB_PATH
- name: Run conformance tests
run: |
echo "Using local protoc: $(protoc --version)"
mix conformance_test