-
-
Notifications
You must be signed in to change notification settings - Fork 463
72 lines (64 loc) · 2.02 KB
/
gobuild.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
name: Build GoFiber Recipes
on:
push:
branches:
- master
- main
paths-ignore:
- "**.md"
pull_request:
branches:
- '*'
paths-ignore:
- "**.md"
jobs:
builds:
strategy:
matrix:
go-version:
- oldstable
- stable
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so diffs can be performed
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Get directories to process
id: get_dirs
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Get the changed directories for the entire pull request
changed_dirs=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | awk -F'/' '{print $1}' | sort -u | tr '\n' ' ')
else
# For master branch, process all directories with go.mod
changed_dirs=$(find . -name go.mod -exec dirname {} \; | tr '\n' ' ')
fi
echo "changed_dirs<<EOF" >> $GITHUB_ENV
echo "${changed_dirs}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run go vet for changed directories
run: |
for dir in ${{ env.changed_dirs }}; do
echo "Running go vet in directory: ${dir}"
if [ -f "${dir}/go.mod" ]; then
(cd $dir; go vet ./...);
fi
done
- name: Run go build for changed directories
run: |
for dir in ${{ env.changed_dirs }}; do
echo "Running go build in directory: ${dir}"
if [ -f "${dir}/go.mod" ]; then
(cd $dir; go build -race ./...);
fi
done