Compare commits

..

6 commits

Author SHA1 Message Date
Imbus
b484346031 Better integration test target 2024-03-21 02:26:30 +01:00
Imbus
ed88220a47 Fix containerfile permission errors 2024-03-21 01:24:17 +01:00
Imbus
d4547e997c Merge branch 'dev' 2024-03-21 00:48:44 +01:00
Imbus
a6d7ee2de6 Merge branch 'dev' 2024-03-21 00:03:51 +01:00
Johanna
1974607fc7 Formating 2024-03-19 22:04:20 +01:00
Johanna
63fd2e9b6f //fix parse in NewWeeklyReport 2024-03-19 21:47:16 +01:00
5 changed files with 23 additions and 11 deletions

View file

@ -23,10 +23,13 @@ load-release file:
# Tests every part of the project # Tests every part of the project
testall: testall:
cd frontend && npm install
cd frontend && npm test cd frontend && npm test
cd frontend && npm run lint cd frontend && npm run lint
cd frontend && npm run build
cd backend && make test cd backend && make test
cd backend && make lint cd backend && make lint
cd backend && make itest
# Cleans up everything related to the project # Cleans up everything related to the project
clean: remove-podman-containers clean: remove-podman-containers

View file

@ -13,10 +13,13 @@ remove-podman-containers:
# Tests every part of the project # Tests every part of the project
testall: testall:
cd frontend && npm install
cd frontend && npm test cd frontend && npm test
cd frontend && npm run lint cd frontend && npm run lint
cd frontend && npm run build
cd backend && make test cd backend && make test
cd backend && make lint cd backend && make lint
cd backend && make itest
# Cleans up everything related to the project # Cleans up everything related to the project
clean: remove-podman-containers clean: remove-podman-containers

View file

@ -8,17 +8,19 @@ GOGET = $(GOCMD) get
# SQLite database filename # SQLite database filename
DB_FILE = db.sqlite3 DB_FILE = db.sqlite3
PROC_NAME = ttime_server
# Directory containing migration SQL scripts # Directory containing migration SQL scripts
MIGRATIONS_DIR = internal/database/migrations MIGRATIONS_DIR = internal/database/migrations
SAMPLE_DATA_DIR = internal/database/sample_data SAMPLE_DATA_DIR = internal/database/sample_data
# Build target # Build target
build: build:
$(GOBUILD) -o bin/server main.go $(GOBUILD) -o bin/$(PROC_NAME) main.go
# Run target # Run target
run: build run: build
./bin/server ./bin/$(PROC_NAME)
watch: build watch: build
watchexec -c -w . -r make run watchexec -c -w . -r make run
@ -37,6 +39,16 @@ clean:
test: db.sqlite3 test: db.sqlite3
$(GOTEST) ./... -count=1 $(GOTEST) ./... -count=1
# Integration test target
.PHONY: itest
itest:
pgrep $(PROC_NAME) && echo "Server already running" && exit 1 || true
make build
./bin/$(PROC_NAME) >/dev/null 2>&1 &
sleep 1 # Adjust if needed
python ../testing.py
pkill $(PROC_NAME)
# Get dependencies target # Get dependencies target
deps: deps:
$(GOGET) -v ./... $(GOGET) -v ./...

View file

@ -13,7 +13,6 @@ FROM docker.io/golang:alpine as go
RUN apk add gcompat RUN apk add gcompat
RUN apk add gcc RUN apk add gcc
RUN apk add musl-dev RUN apk add musl-dev
RUN apk add make
RUN apk add sqlite RUN apk add sqlite
WORKDIR /build WORKDIR /build
ADD backend/go.mod backend/go.sum ./ ADD backend/go.mod backend/go.sum ./
@ -24,9 +23,7 @@ RUN go mod download
# Add the source code # Add the source code
ADD backend . ADD backend .
RUN make migrate RUN go build -o server
# RUN go build -o server
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./main.go RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./main.go
# Strip the binary for a smaller image # Strip the binary for a smaller image
@ -37,6 +34,7 @@ FROM docker.io/alpine:latest as runner
RUN adduser -D nonroot RUN adduser -D nonroot
RUN addgroup nonroot nonroot RUN addgroup nonroot nonroot
WORKDIR /app WORKDIR /app
RUN chown nonroot:nonroot /app
# Copy the frontend SPA build into public # Copy the frontend SPA build into public
COPY --from=client /build/dist static COPY --from=client /build/dist static
@ -44,9 +42,6 @@ COPY --from=client /build/dist static
# Copy the server binary # Copy the server binary
COPY --from=go /build/server server COPY --from=go /build/server server
# Copy the database
COPY --from=go /build/db.sqlite3 db.sqlite3
# Expose port 8080 # Expose port 8080
EXPOSE 8080 EXPOSE 8080

View file

@ -60,8 +60,7 @@ export default function NewWeeklyReport(): JSX.Element {
type="week" type="week"
placeholder="Week" placeholder="Week"
onChange={(e) => { onChange={(e) => {
const weekNumber = parseInt(e.target.value.split("-W")[1]); setWeek(parseInt(e.target.value));
setWeek(weekNumber);
}} }}
onKeyDown={(event) => { onKeyDown={(event) => {
const keyValue = event.key; const keyValue = event.key;