Skip to content

Commit ee664f0

Browse files
authored
Merge pull request #447 from ellemouton/checkCommits
github+scripts: check commits compile
2 parents 7db68ba + d2b843f commit ee664f0

File tree

3 files changed

+86
-6
lines changed

3 files changed

+86
-6
lines changed

.github/workflows/main.yml

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ env:
1818
GO_VERSION: 1.18
1919

2020
jobs:
21+
########################
22+
# frontend build checks
23+
########################
2124
frontend:
2225
name: frontend tests on ${{ matrix.os }}
2326
runs-on: ${{ matrix.os }}
@@ -72,6 +75,9 @@ jobs:
7275
working-directory: ./app
7376
run: yarn test:ci
7477

78+
########################
79+
# backend build checks
80+
########################
7581
backend:
7682
name: backend build on ${{ matrix.os }}
7783
runs-on: ${{ matrix.os }}
@@ -126,6 +132,9 @@ jobs:
126132
- name: build CLI binaries
127133
run: make go-install-cli
128134

135+
########################
136+
# proto compile check
137+
########################
129138
proto-compile-check:
130139
name: RPC proto compilation check
131140
runs-on: ubuntu-latest
@@ -147,10 +156,10 @@ jobs:
147156
uses: actions/cache@v1
148157
with:
149158
path: /home/runner/work/download_cache
150-
key: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
159+
key: litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
151160
restore-keys: |
152-
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
153-
lnd-${{ runner.os }}-download-
161+
litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
162+
litd-${{ runner.os }}-download-
154163
155164
- name: get yarn cache dir
156165
id: yarn-cache-dir
@@ -182,6 +191,48 @@ jobs:
182191
- name: run check
183192
run: make mod-check
184193

194+
########################
195+
# check commits
196+
########################
197+
check-commits:
198+
name: check commits
199+
runs-on: ubuntu-latest
200+
steps:
201+
- name: git checkout
202+
uses: actions/checkout@v2
203+
with:
204+
fetch-depth: 0
205+
206+
- name: go cache
207+
uses: actions/cache@v1
208+
with:
209+
path: /home/runner/work/go
210+
key: litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
211+
restore-keys: |
212+
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
213+
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
214+
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-
215+
litd-${{ runner.os }}-go-
216+
217+
- name: setup go ${{ env.GO_VERSION }}
218+
uses: actions/setup-go@v2
219+
with:
220+
go-version: '${{ env.GO_VERSION }}'
221+
222+
- name: fetch and rebase on ${{ github.base_ref }}
223+
run: |
224+
git remote add upstream https://github.com/${{ github.repository }}
225+
git fetch upstream
226+
export GIT_COMMITTER_EMAIL="[email protected]"
227+
export GIT_COMMITTER_NAME="LiT CI"
228+
git rebase upstream/${{ github.base_ref }}
229+
230+
- name: check commits
231+
run: scripts/check-each-commit.sh upstream/${{ github.base_ref }}
232+
233+
########################
234+
# lint code
235+
########################
185236
lint:
186237
name: lint
187238
runs-on: ubuntu-latest
@@ -202,6 +253,9 @@ jobs:
202253
- name: run check
203254
run: make lint mod-check
204255

256+
########################
257+
# unit race tests
258+
########################
205259
unit-race:
206260
name: unit-race
207261
runs-on: ubuntu-latest
@@ -219,6 +273,9 @@ jobs:
219273
- name: run check
220274
run: make unit-race
221275

276+
########################
277+
# unit tests
278+
########################
222279
unit:
223280
name: unit tests
224281
runs-on: ubuntu-latest
@@ -236,6 +293,9 @@ jobs:
236293
- name: run check
237294
run: make unit
238295

296+
########################
297+
# integration tests
298+
########################
239299
itest:
240300
name: integration test
241301
runs-on: ubuntu-latest
@@ -257,10 +317,10 @@ jobs:
257317
uses: actions/cache@v1
258318
with:
259319
path: /home/runner/work/download_cache
260-
key: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
320+
key: litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
261321
restore-keys: |
262-
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
263-
lnd-${{ runner.os }}-download-
322+
litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
323+
litd-${{ runner.os }}-download-
264324
265325
- name: get yarn cache dir
266326
id: yarn-cache-dir

scripts/check-commit.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
echo Testing $(git log -1 --oneline)
5+
make unit pkg=... case=_NONE_

scripts/check-each-commit.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
if [[ "$1" = "" ]]; then
3+
echo "USAGE: $0 remote/head_branch"
4+
echo "eg $0 upstream/master"
5+
exit 1
6+
fi
7+
8+
set -e
9+
set -x
10+
11+
if [[ "$(git log --pretty="%H %D" | grep "^[0-9a-f]*.* $1")" = "" ]]; then
12+
echo "It seems like the current checked-out commit is not based on $1"
13+
exit 1
14+
fi
15+
git rebase --exec scripts/check-commit.sh $1

0 commit comments

Comments
 (0)