Commit 2711b0f

mo khan <mo@mokhan.ca>
2025-07-31 16:48:04
chore: add build scripts
1 parent 187e36f
Changed files (6)
.github/workflows/ci.yml
@@ -0,0 +1,15 @@
+name: CI
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+    - uses: actions/setup-go@v3
+      with:
+        go-version: 1.24
+    - run: go test -v ./...
bin/.keep
pkg/procfile/parse.go → pkg/procfile/proc.go
@@ -2,7 +2,7 @@ package procfile
 
 import (
 	"bufio"
-	"log"
+	"io"
 	"os"
 	"os/exec"
 	"strings"
@@ -21,13 +21,17 @@ func New(name string, args []string) *Proc {
 	}
 }
 
-func Parse(procfilePath string) []*Proc {
-	file, err := os.Open(procfilePath)
+func ParseFile(path string) ([]*Proc, error) {
+	file, err := os.Open(path)
 	if err != nil {
-		log.Fatalln(err)
+		return nil, err
 	}
 	defer file.Close()
 
+	return Parse(file), nil
+}
+
+func Parse(file io.Reader) []*Proc {
 	var processes []*Proc
 	scanner := bufio.NewScanner(file)
 
.gitignore
@@ -0,0 +1,1 @@
+/bin
main.go
@@ -28,7 +28,12 @@ func main() {
 	var shutdown int32
 
 	for _, path := range strings.Split(*procfilePath, ",") {
-		for _, proc := range procfile.Parse(path) {
+		procs, err := procfile.ParseFile(path)
+		if err != nil {
+			log.Fatalln(err)
+		}
+
+		for _, proc := range procs {
 			wg.Add(1)
 			go func(proc *procfile.Proc) {
 				defer wg.Done()
Makefile
@@ -0,0 +1,10 @@
+SHELL = /bin/sh
+
+clean:
+	@rm -f ./bin/minit
+
+build:
+	@go build -o ./bin/minit main.go
+
+test: build
+	@go test ./...