Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 79 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TypeScript CI Pipeline
name: Full Stack CI Pipeline # Updated the name since this handles Go now too!

on:
push:
Expand All @@ -7,45 +7,103 @@ on:
branches: [ "main" ]

jobs:
# JOB 1: Local Build
fast-checks:
# ==========================================
# JOB 1: Frontend (Runs First)
# ==========================================
fast-checks-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app
working-directory: ./frontend
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest # You can pin a specific version here, e.g., '1.1.0'
bun-version: latest

- name: Install Dependencies
- name: Install TypeScript Dependencies
run: bun install --frozen-lockfile

- name: Check Lint
- name: Check TypeScript Lint
run: bun run lint

- name: Check Compile
- name: Check TypeScript Compile
run: bun run build

# JOB 2: Docker Build & Integration Tests
docker-validation:
needs: fast-checks # Only run if lint/compile passes
- name: Run TypeScript Tests
run: bun run test

- name: Verify Frontend Docker Build
run: docker build -t frontend-test .

# ==========================================
# JOB 2: Backend (Waits for Frontend)
# ==========================================
fast-checks-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout code
uses: actions/checkout@v4

steps:
- name: Checkout Code
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Install Go Dependencies
run: go mod download

- name: Check Go Lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m
working-directory: backend

- name: Run Go Tests
run: go test -v ./...
working-directory: ./backend

- name: Verify Backend Docker Build
run: docker build -t backend-test .

# ==========================================
# JOB 3: Money Module (Waits for Frontend)
# ==========================================
fast-checks-money-module:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./money-module
steps:
- name: Checkout code
uses: actions/checkout@v4

# 1. Check Docker Build
# This ensures your Dockerfile is valid and the app builds inside it.
- name: Build Docker Image
run: docker build --target dev -t ts-app-test:latest -f app/Dockerfile .
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Install Go Dependencies
run: go mod download

- name: Check Go Lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m
working-directory: money-module

# 2. Run Tests ON the Docker Image
# This runs "bun test" inside the container you just built.
- name: Run Tests in Container
run: docker run --rm ts-app-test:latest bun test
- name: Run Go Tests
run: go test -v ./...
working-directory: ./money-module
- name: Verify Money Module Docker Build
run: docker build -t money-module-test .
44 changes: 44 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "2"

run:
timeout: 5m

output:
formats:
text: {}

formatters:
enable:
- gofmt
- goimports

linters:
enable:
- bodyclose
- errcheck
- funlen
- govet
- ineffassign
- lll
- misspell
- staticcheck
- unused
settings:
funlen:
lines: 88
govet:
enable:
- shadow
lll:
line-length: 88
tab-width: 4
misspell:
locale: UK
exclusions:
paths:
- vendor
- testdata
- third_party
- builtin
- examples

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y \
golang \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://bun.com/install | bash

# default go tooling
ENV PATH="/root/go/bin:${PATH}"
RUN go install golang.org/x/tools/gopls@latest \
&& go install github.com/go-delve/delve/cmd/dlv@latest \
&& go install golang.org/x/tools/cmd/goimports@latest \
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ If this doesn't work install the docker-compose plugin
docker exec -it warchest-dev-container bash
```

3. Go linting
```bash
golangci-lint run
```

### Closing down development
1. To exit the dev environment
```bash
Expand All @@ -25,3 +30,5 @@ docker compose down
```
use `bun run lint` for lint and `bun run test` in the dev shell for tests.
tests need to end in the suffix .test.ts.


27 changes: 0 additions & 27 deletions app/Dockerfile

This file was deleted.

19 changes: 0 additions & 19 deletions app/db/db.ts

This file was deleted.

10 changes: 0 additions & 10 deletions app/db/drizzle.config.ts

This file was deleted.

11 changes: 0 additions & 11 deletions app/db/schema.ts

This file was deleted.

13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# syntax=docker/dockerfile:1
FROM golang:1.22-alpine AS base
WORKDIR /backend

FROM base AS deps
COPY go.mod go.sum* ./
RUN go mod download

FROM base AS dev
COPY . .
EXPOSE 6969

CMD ["/server"]
3 changes: 3 additions & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module backend

go 1.22.2
7 changes: 7 additions & 0 deletions backend/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# syntax=docker/dockerfile:1
FROM oven/bun:1 AS base
# Set your preferred working directory
WORKDIR /frontend

# --- DEPENDENCIES STAGE ---
FROM base AS deps
COPY package.json bun.lock* ./
RUN bun install --frozen-lockfile

# --- DEV STAGE ---
FROM base AS dev
# Notice we pull from /frontend/node_modules now
COPY --from=deps /frontend/node_modules ./node_modules
# Copy local files into the current WORKDIR (/frontend)
COPY . .
EXPOSE 3000
CMD ["bun", "run", "dev", "--host", "0.0.0.0"]

# --- BUILDER STAGE ---
FROM base AS builder
COPY --from=deps /frontend/node_modules ./node_modules
COPY . .
RUN bun run build

# --- PRODUCTION STAGE ---
FROM base AS production
COPY --from=builder /frontend/.output ./.output
COPY --from=builder /frontend/node_modules ./node_modules
COPY package.json ./
EXPOSE 3000
CMD ["bun", "run", "preview", "--host", "0.0.0.0"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions money-module/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# syntax=docker/dockerfile:1
# language which we use
FROM oven/bun:1 AS base
FROM golang:1.22-alpine AS base
WORKDIR /money-module

FROM base AS deps
COPY money-module/package.json ./
RUN bun install
COPY go.mod go.sum* ./
RUN go mod download


FROM base AS dev
COPY --from=deps /money-module/node_modules ./node_modules
COPY money-module/ .
EXPOSE 6767
CMD ["bun", "run", "index.ts"]
COPY . .
EXPOSE 6767


CMD ["go", "run", "main.go"]
15 changes: 0 additions & 15 deletions money-module/README.md

This file was deleted.

Loading
Loading