-
Notifications
You must be signed in to change notification settings - Fork 36
172 lines (136 loc) · 4.82 KB
/
build.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
169
170
171
172
name: Build & Test PR
on:
pull_request:
branches:
- master
- hotfix-*
- prerelease-*
- nextgen-ux
jobs:
elixir-build-test:
name: Elixir build and test
runs-on: ubuntu-latest
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
- name: 🔧 Configure
run: |
cp postgres.example.env postgres.env
cp oli.example.env oli.env
- name: 🗄 Start test database
run: docker compose up -d postgres
- name: 💾 Restore the deps cache
id: mix-deps-cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
- name: 💾 Restore the Node.js cache
id: yarn-cache
uses: actions/cache@v3
with:
path: assets/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('assets/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 🧪 Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: 1.17.2 # Define the elixir version [required]
otp-version: 27.0.1 # Define the OTP version [required]
- name: ⬇️ Install elixir dependencies
run: mix deps.get
- name: 🔨 Build dependencies
run: mix deps.compile
- name: 🧹 Clean on master
if: github.ref == 'refs/heads/master'
run: set -a;source oli.env && mix clean
- name: 🔨 Build project
run: set -a; source oli.env && mix compile --warnings-as-errors
- name: 📋 Check Formatting
run: mix format --check-formatted
- name: ▶️ Run unit tests
run: set -a;source oli.env && MIX_ENV=test mix ecto.reset && mix test
- name: 📦 Install node_module dependencies
run: yarn --cwd assets --frozen-lockfile
check-simon-token:
name: Check simon-bot access token
runs-on: ubuntu-latest
outputs:
available: ${{ steps.check_token.outputs.available }}
steps:
- name: Check whether SIMON_BOT_PERSONAL_ACCESS_TOKEN is set
id: check_token
run: echo "available=$(if [ "${{ secrets.SIMON_BOT_PERSONAL_ACCESS_TOKEN }}" != "" ] ; then echo true ; else echo false ; fi)" >> $GITHUB_OUTPUT
auto-format:
name: Auto format and lint
runs-on: ubuntu-latest
needs: check-simon-token
if: needs.check-simon-token.outputs.available == 'true'
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.SIMON_BOT_PERSONAL_ACCESS_TOKEN }}
- name: 🔧 Configure
uses: actions/setup-node@v1
with:
node-version: "16.14.2"
- name: 🧪 Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: 1.17.2 # Define the elixir version [required]
otp-version: 27.0.1 # Define the OTP version [required]
- name: ⬇️ Install elixir dependencies
run: mix deps.get
- name: 📦 Install node_module dependencies
run: yarn --cwd assets --frozen-lockfile
- name: 🤖 Auto format Elixir
run: mix format
- name: 🤖 Auto format Typescript
run: yarn --cwd assets run format
- name: ✅ Commit
uses: EndBug/add-and-commit@v9
with:
message: Auto format
committer_name: Simon Bot (GitHub Actions)
committer_email: [email protected]
ts-build-test:
name: TypeScript build and test
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: 🔧 Configure
uses: actions/setup-node@v1
with:
node-version: "16.14.2"
- name: 🧪 Setup elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: 1.17.2 # Define the elixir version [required]
otp-version: 27.0.1 # Define the OTP version [required]
- name: ⬇️ Install elixir dependencies
run: mix deps.get
- name: 📦 Install node_module dependencies
run: yarn --cwd assets --frozen-lockfile
- name: 🧹 Lint
run: yarn --cwd assets run prettier && yarn --cwd assets run lint
- name: 👁️ Typecheck
run: yarn --cwd assets run check-types
- name: 🔨 Build
run: yarn --cwd assets run deploy
- name: ⚙️ Test
run: yarn --cwd assets run test