forked from kitsteam/qrstorage
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (116 loc) · 4.4 KB
/
on_push_branch__execute_tests.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
name: on_push_branch__execute_tests
on: [push, pull_request]
jobs:
build_deps:
runs-on: ubuntu-latest
# Currently, this need to be synced manually with the Dockerfile. In the future, the workflow should be changed,
# so that a development container is built from the Dockerfile, pushed, and then re-used in the following steps.
# This would also remove the need to install cmake manually in each step:
container: hexpm/elixir:1.17.3-erlang-27.1.2-debian-bookworm-20241111-slim
steps:
# See https://github.com/actions/checkout
- uses: actions/checkout@v4
# we need cmake for fast_sanitize:
- run: apt-get -y update && apt-get -y install build-essential cmake
# install hex:
- run: mix local.hex --force && mix local.rebar --force
# See https://github.com/actions/cache
- uses: actions/cache@v4
id: cache
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v4
- run: mix deps.get && mix deps.compile
if: steps.cache.outputs.cache-hit != 'true'
check_mix_test:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: hexpm/elixir:1.17.3-erlang-27.1.2-debian-bookworm-20241111-slim
needs: build_deps
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres:latest
env:
# These env variables are required by the postgres service (see above)
POSTGRES_DB: qrstorage_test
POSTGRES_HOST: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# These env vars are required by our application
DATABASE_HOST: postgres
DATABASE_NAME: qrstorage_test
DATABASE_USER: postgres
DATABASE_USER_PASSWORD: postgres
DATABASE_SSL: false
# This should only be used for the tests:
SECRET_KEY_BASE: "DFvi5ZWW/Xc/yBgPOQ0w1wWZEGjy7NMl1/fRFyWf2EgbWNcXqtAOKUjh4bVps/eQ"
VAULT_ENCRYPTION_KEY_BASE64: "h3NKY+sEnQYSSoM7Qm0mNzHgwT99GD+TQVdz+q0sdEA="
MIX_ENV: "test"
OBJECT_STORAGE_BUCKET: "qrstorage-test"
steps:
# Downloads a copy of the code in your repository before running CI tests
- uses: actions/checkout@v4
# we need cmake for fast_sanitize:
- run: apt-get -y update && apt-get -y install build-essential cmake
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v4
# install hex:
- run: mix local.hex --force && mix local.rebar --force
- run: mix compile
- run: mix ecto.create
- run: mix ecto.migrate
- run: mix test
check_mix_format:
runs-on: ubuntu-latest
container: hexpm/elixir:1.17.3-erlang-27.1.2-debian-bookworm-20241111-slim
needs: build_deps
steps:
- name: Check out repository code
uses: actions/checkout@v4
# install hex:
- run: mix local.hex --force && mix local.rebar --force
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v4
- run: mix format --check-formatted
check_mix_sobelow:
runs-on: ubuntu-latest
container: hexpm/elixir:1.17.3-erlang-27.1.2-debian-bookworm-20241111-slim
needs: build_deps
steps:
- name: Check out repository code
uses: actions/checkout@v4
# we need cmake for fast_sanitize:
- run: apt-get -y update && apt-get -y install build-essential cmake
# install hex:
- run: mix local.hex --force && mix local.rebar --force
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v4
- run: mix sobelow --config