-
Notifications
You must be signed in to change notification settings - Fork 50
174 lines (170 loc) · 6.08 KB
/
astarte-apps-build-workflow.yaml
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
171
172
173
174
name: Build and Test Astarte Apps
on:
# Run when pushing to stable branches
push:
paths:
- 'apps/**'
- '.github/workflows/astarte-apps-build-workflow.yaml'
branches:
- 'master'
- 'release-*'
# Run on branch/tag creation
create:
# Run on pull requests matching apps
pull_request:
paths:
- 'apps/**'
- '.github/workflows/astarte-apps-build-workflow.yaml'
env:
elixir_version: "1.15"
otp_version: "25.3.2"
jobs:
test-dialyzer:
name: Check Dialyzer
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
app:
- astarte_appengine_api
- astarte_data_updater_plant
- astarte_housekeeping
- astarte_housekeeping_api
- astarte_pairing
- astarte_pairing_api
- astarte_realm_management
- astarte_realm_management_api
- astarte_trigger_engine
env:
MIX_ENV: ci
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: apps/${{ matrix.app }}/deps
key: ${{ runner.os }}-dialyzer-mix-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-${{ hashFiles(format('{0}{1}{2}{3}', github.workspace, '/apps/', matrix.app, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-dialyzer-mix-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-
- uses: actions/cache@v1
with:
path: apps/${{ matrix.app }}/_build
key: ${{ runner.os }}-dialyzer-_build-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-dialyzer-_build-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-
- uses: actions/cache@v1
id: plt_cache
with:
path: apps/${{ matrix.app }}/dialyzer_cache
key: ${{ runner.os }}-dialyzer_cache-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-dialyzer_cache-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-
- uses: erlef/setup-beam@v1.15
with:
otp-version: ${{ env.otp_version }}
elixir-version: ${{ env.elixir_version }}
- name: Install Dependencies
working-directory: ./apps/${{ matrix.app }}
run: mix deps.get
- name: Create PLTs dir
working-directory: ./apps/${{ matrix.app }}
if: ${{ steps.plt_cache.outputs.cache-hit != 'true' }}
run: mkdir -p dialyzer_cache && mix dialyzer --plt
- name: Run dialyzer
working-directory: ./apps/${{ matrix.app }}
# FIXME: This should be set to fail when dialyzer issues are fixed
run: mix dialyzer || exit 0
test-coverage:
name: Build and Test
runs-on: ubuntu-22.04
# Wait for Dialyzer to give it a go before building
needs:
- test-dialyzer
strategy:
fail-fast: false
matrix:
app:
- astarte_appengine_api
- astarte_data_updater_plant
- astarte_housekeeping
- astarte_housekeeping_api
- astarte_pairing
- astarte_pairing_api
- astarte_realm_management
- astarte_realm_management_api
- astarte_trigger_engine
database:
- "cassandra:3.11.15"
- "scylladb/scylla:5.2.2"
rabbitmq:
- "rabbitmq:3.12.0-management"
services:
rabbitmq:
image: ${{ matrix.rabbitmq }}
ports:
- 5672:5672
- 15672:15672
database:
image: ${{ matrix.database }}
ports:
- 9042:9042
cfssl:
image: ispirata/docker-alpine-cfssl-autotest:astarte
ports:
- 8080/tcp
env:
MIX_ENV: test
CASSANDRA_NODES: localhost
RABBITMQ_HOST: localhost
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: apps/${{ matrix.app }}/deps
key: ${{ runner.os }}-apps-mix-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-${{ hashFiles(format('{0}{1}{2}{3}', github.workspace, '/apps/', matrix.app, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-apps-mix-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-
# Caching _build is causing tests to fail rather unexpectedly.
# TODO try to undestand why and restore the cache step.
# - uses: actions/cache@v1
# with:
# path: apps/${{ matrix.app }}/_build
# key: ${{ runner.os }}-apps-_build-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-apps-_build-${{ env.otp_version }}-${{ env.elixir_version }}-${{ matrix.app }}-
- uses: erlef/setup-beam@v1.15
with:
otp-version: ${{ env.otp_version }}
elixir-version: ${{ env.elixir_version }}
- name: Install Dependencies
working-directory: ./apps/${{ matrix.app }}
run: mix deps.get
- name: Check formatting
working-directory: ./apps/${{ matrix.app }}
run: mix format --check-formatted
- name: Setup Events Exchange
if: matrix.app == 'astarte_appengine_api'
run: |
wget http://guest:guest@localhost:15672/cli/rabbitmqadmin -O rabbitmqadmin
chmod +x ./rabbitmqadmin
./rabbitmqadmin declare exchange name=astarte_events type=direct
rm rabbitmqadmin
- name: Compile
working-directory: ./apps/${{ matrix.app }}
run: mix do compile
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Wait for Cassandra
run: |
npm install -g wait-for-cassandra
wait-for-cassandra -T 120000 -h $CASSANDRA_NODES
- name: Test and Coverage
working-directory: ./apps/${{ matrix.app }}
run: mix coveralls.json --exclude wip -o coverage_results
env:
CFSSL_API_URL: http://localhost:${{ job.services.cfssl.ports[8080] }}
- name: Upload Coverage Results to CodeCov
# Don't upload more than once per component
if: matrix.database == 'scylladb/scylla:5.2.2'
working-directory: ./apps/${{ matrix.app }}
run: bash <(curl -s https://codecov.io/bash)