Skip to content

Commit 887dab8

Browse files
committed
Remove $HOME hardcodes and added a build/fmt CI
Signed-off-by: Brent Salisbury <[email protected]>
1 parent 7988809 commit 887dab8

File tree

7 files changed

+917
-845
lines changed

7 files changed

+917
-845
lines changed

.github/workflows/api-server.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: api-server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-1.0
8+
pull_request:
9+
branches:
10+
- main
11+
- release-1.0
12+
13+
jobs:
14+
fmt-build-test:
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
CGO_ENABLED: 1
19+
20+
defaults:
21+
run:
22+
working-directory: api-server
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Go
29+
uses: actions/setup-go@v4
30+
with:
31+
go-version: '1.21.6'
32+
33+
- name: Install Build Dependencies
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y build-essential pkg-config
37+
38+
- name: Install Go Dependencies
39+
run: |
40+
go mod download
41+
42+
- name: Go Format
43+
run: |
44+
unformatted=$(gofmt -l .)
45+
if [ -n "$unformatted" ]; then
46+
echo "The following files are not formatted properly:"
47+
echo "$unformatted"
48+
exit 1
49+
fi
50+
51+
- name: Build
52+
run: |
53+
go build ./...

api-server/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
module ilab-api-router
1+
module github.com/instructlab/ui/api-server
22

3-
go 1.21.6
3+
go 1.22.1
44

55
require (
66
github.com/gorilla/mux v1.8.1
77
github.com/mattn/go-sqlite3 v1.14.24
88
github.com/spf13/cobra v1.8.1
9+
go.uber.org/zap v1.27.0
910
)
1011

1112
require (
1213
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1314
github.com/spf13/pflag v1.0.5 // indirect
1415
go.uber.org/multierr v1.10.0 // indirect
15-
go.uber.org/zap v1.27.0 // indirect
1616
)

api-server/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
25
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
6+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
37
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
8+
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
49
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
10+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
11+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
512
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
13+
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
614
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
15+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
716
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
17+
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
18+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
19+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
20+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
21+
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
822
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
23+
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
924
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
1025
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
26+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1127
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

api-server/handlers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ func (srv *ILabServer) serveLatestCheckpointHandler(w http.ResponseWriter, r *ht
581581
"8001",
582582
"post-train",
583583
1,
584-
"/var/home/cloud-user",
585-
"/var/home/cloud-user",
584+
srv.homeDir,
585+
srv.homeDir,
586586
w,
587587
)
588588
} else {
@@ -612,8 +612,8 @@ func (srv *ILabServer) serveBaseModelHandler(w http.ResponseWriter, r *http.Requ
612612
"8000",
613613
"pre-train",
614614
0,
615-
"/var/home/cloud-user",
616-
"/var/home/cloud-user",
615+
srv.homeDir,
616+
srv.homeDir,
617617
w,
618618
)
619619
} else {

0 commit comments

Comments
 (0)