1
+ # Do not forget to change status badge in ./README.md
2
+ name : on_push_branch__execute_ci_cd
3
+
4
+ on :
5
+ push :
6
+ branches : [main]
7
+ # See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
8
+ pull_request :
9
+ # Only branches and tags on the base are evaluated
10
+ branches : [main]
11
+
12
+ jobs :
13
+ build_deps :
14
+ runs-on : ubuntu-latest
15
+ # Currently, this need to be synced manually with the Dockerfile. In the future, the workflow should be changed,
16
+ # so that a development container is built from the Dockerfile, pushed, and then re-used in the following steps.
17
+ # This would also remove the need to install cmake manually in each step:
18
+ container : hexpm/elixir:1.15.7-erlang-26.2.2-debian-bullseye-20240130-slim
19
+
20
+ steps :
21
+ - uses : actions/cache@v4
22
+ id : cache
23
+ with :
24
+ path : deps
25
+ key : ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
26
+ restore-keys : ${{ runner.os }}-mix-v4
27
+
28
+ - run : mix do local.hex --force, local.rebar --force
29
+ - run : mix deps.get
30
+ if : steps.cache.outputs.cache-hit != 'true'
31
+
32
+ backend_check_mix_test :
33
+ # Containers must run in Linux based operating systems
34
+ runs-on : ubuntu-latest
35
+ # Docker Hub image that `container-job` executes in
36
+ container : hexpm/elixir:1.15.7-erlang-26.2.2-debian-bullseye-20240130-slim
37
+
38
+ needs : build_deps
39
+
40
+ # Service containers to run with `container-job`
41
+ services :
42
+ # Label used to access the service container
43
+ postgres :
44
+ image : postgres:latest
45
+ env :
46
+ # These env variables are required by the postgres service (see above)
47
+ POSTGRES_DB : mindwendel_test
48
+ POSTGRES_HOST : postgres
49
+ POSTGRES_USER : postgres
50
+ POSTGRES_PASSWORD : postgres
51
+
52
+ # Set health checks to wait until postgres has started
53
+ options : >-
54
+ --health-cmd pg_isready
55
+ --health-interval 10s
56
+ --health-timeout 5s
57
+ --health-retries 5
58
+
59
+ env :
60
+ # These env vars are required by our application
61
+ # Unfortunately, github workflow does not support yaml anchors ;-(
62
+ TEST_DATABASE_HOST : postgres
63
+ TEST_DATABASE_NAME : mindwendel_test
64
+ TEST_DATABASE_USER : postgres
65
+ TEST_DATABASE_USER_PASSWORD : postgres
66
+ MIX_ENV : " test"
67
+
68
+ steps :
69
+ # Downloads a copy of the code in your repository before running CI tests
70
+ - uses : actions/checkout@v4
71
+
72
+ - uses : actions/cache@v4
73
+ with :
74
+ path : deps
75
+ key : ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
76
+ restore-keys : ${{ runner.os }}-mix-v4
77
+
78
+ - run : mix do local.hex --force, local.rebar --force
79
+ - run : mix compile
80
+ - run : mix ecto.create
81
+ - run : mix ecto.migrate
82
+ - run : mix test
83
+
84
+ backend_check_mix_format :
85
+ runs-on : ubuntu-latest
86
+ container : hexpm/elixir:1.15.7-erlang-26.2.2-debian-bullseye-20240130-slim
87
+
88
+ needs : build_deps
89
+
90
+ steps :
91
+ - name : Check out repository code
92
+ uses : actions/checkout@v4
93
+
94
+ - uses : actions/cache@v4
95
+ with :
96
+ path : deps
97
+ key : ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
98
+ restore-keys : ${{ runner.os }}-mix-v4
99
+
100
+ - run : mix do local.hex --force, local.rebar --force
101
+
102
+ - run : mix format --check-formatted
103
+
104
+ backend_check_mix_gettext_extract_up_to_date :
105
+ runs-on : ubuntu-latest
106
+ container : hexpm/elixir:1.15.7-erlang-26.2.2-debian-bullseye-20240130-slim
107
+
108
+ needs : build_deps
109
+
110
+ steps :
111
+ - name : Check out repository code
112
+ uses : actions/checkout@v4
113
+
114
+ - uses : actions/cache@v4
115
+ with :
116
+ path : deps
117
+ key : ${{ runner.os }}-mix-v4-${{ hashFiles('**/mix.lock') }}
118
+ restore-keys : ${{ runner.os }}-mix-v4
119
+
120
+ - run : mix do local.hex --force, local.rebar --force
121
+ - run : mix compile
122
+ - run : mix gettext.extract --check-up-to-date
0 commit comments