-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (44 loc) · 1.15 KB
/
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
name: Go
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Find directories
id: set-matrix
run: |
dirs=$(find go -mindepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=$dirs" >> $GITHUB_OUTPUT
test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dirs: ${{ fromJson(needs.build.outputs.matrix) }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Check out code
uses: actions/checkout@v3
- name: Run tests in each directory
run: |
for dir in "${{ matrix.dirs }}"; do
full_dir="go/$dir"
if [ -d "$full_dir" ]; then
echo "Running tests in $full_dir"
(cd "$full_dir" && go test ./...)
else
echo "No Go files in $full_dir"
fi
done