Skip to content

Commit 3f00fab

Browse files
authored
Merge pull request #1 from m8a-io/smolinari-example-ci-repo-work
Smolinari example ci repo work
2 parents 61a7a1c + 0fc8253 commit 3f00fab

File tree

10 files changed

+128
-1
lines changed

10 files changed

+128
-1
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Binaries
2+
/main
3+
/hooks-test
4+
/web-server
5+
/worker
6+
7+
# OS specifics
8+
.DS_Store

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: all build test lint clean
2+
3+
APPS := web-server worker
4+
APP_DIR := apps
5+
6+
all: lint test build
7+
8+
build:
9+
@for app in $(APPS); do \
10+
echo "Building $$app..."; \
11+
go build -o $$app ./$(APP_DIR)/$$app; \
12+
done
13+
14+
test:
15+
@for app in $(APPS); do \
16+
echo "Testing $$app..."; \
17+
(cd $(APP_DIR)/$$app && go test -v ./...); \
18+
done
19+
20+
lint:
21+
@for app in $(APPS); do \
22+
echo "Linting $$app..."; \
23+
(cd $(APP_DIR)/$$app && go fmt ./...); \
24+
(cd $(APP_DIR)/$$app && go vet ./...); \
25+
done
26+
27+
clean:
28+
rm -f web-server worker

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# hooks-test
22
Test repo for testing hooks and new ci app
33

4-
Test change 7
4+
Test change 27

apps/web-server/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/m8a-io/hooks-test/apps/web-server
2+
3+
go 1.25.4

apps/web-server/main.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"os"
7+
)
8+
9+
func handler(w http.ResponseWriter, r *http.Request) {
10+
fmt.Fprintf(w, "Hello, World!")
11+
}
12+
13+
func main() {
14+
http.HandleFunc("/", handler)
15+
port := os.Getenv("PORT")
16+
if port == "" {
17+
port = "8080"
18+
}
19+
fmt.Printf("Server listening on port %s\n", port)
20+
err := http.ListenAndServe(":"+port, nil)
21+
if err != nil {
22+
fmt.Printf("Error starting server: %s\n", err)
23+
}
24+
}

apps/web-server/main_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"net/http/httptest"
6+
"testing"
7+
)
8+
9+
func TestHandler(t *testing.T) {
10+
req, err := http.NewRequest("GET", "/", nil)
11+
if err != nil {
12+
t.Fatal(err)
13+
}
14+
15+
rr := httptest.NewRecorder()
16+
handler := http.HandlerFunc(handler)
17+
18+
handler.ServeHTTP(rr, req)
19+
20+
if status := rr.Code; status != http.StatusOK {
21+
t.Errorf("handler returned wrong status code: got %v want %v",
22+
status, http.StatusOK)
23+
}
24+
25+
expected := "Hello, World!"
26+
if rr.Body.String() != expected {
27+
t.Errorf("handler returned unexpected body: got %v want %v",
28+
rr.Body.String(), expected)
29+
}
30+
}

apps/worker/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/m8a-io/hooks-test/apps/worker
2+
3+
go 1.25.4

apps/worker/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
func main() {
9+
fmt.Println("Worker starting...")
10+
for {
11+
fmt.Println("Worker processing job...")
12+
time.Sleep(5 * time.Second)
13+
}
14+
}

apps/worker/main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import "testing"
4+
5+
func TestWorker(t *testing.T) {
6+
// Dummy test
7+
expected := true
8+
if !expected {
9+
t.Error("Worker failed")
10+
}
11+
}

go.work

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
go 1.25.4
2+
3+
use (
4+
./apps/web-server
5+
./apps/worker
6+
)

0 commit comments

Comments
 (0)