From 63fd2e9b6f46aa1ca81ce358a4aed5cde5844648 Mon Sep 17 00:00:00 2001 From: Johanna Date: Tue, 19 Mar 2024 21:47:16 +0100 Subject: [PATCH 1/4] //fix parse in NewWeeklyReport --- frontend/src/Components/NewWeeklyReport.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index ab9084d..1d029c3 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -54,8 +54,7 @@ export default function NewWeeklyReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - const weekNumber = parseInt(e.target.value.split("-W")[1]); - setWeek(weekNumber); + setWeek(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; From 1974607fc705fc17165732ff6282bea955cd55b4 Mon Sep 17 00:00:00 2001 From: Johanna Date: Tue, 19 Mar 2024 22:04:20 +0100 Subject: [PATCH 2/4] Formating --- frontend/src/Components/NewWeeklyReport.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index 1d029c3..4542855 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -54,7 +54,7 @@ export default function NewWeeklyReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - setWeek(parseInt(e.target.value)); + setWeek(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; From ed88220a47cfcbc77c970f713984981c8057f556 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 21 Mar 2024 01:24:17 +0100 Subject: [PATCH 3/4] Fix containerfile permission errors --- container/Containerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/container/Containerfile b/container/Containerfile index ecd2f84..f9cb39d 100644 --- a/container/Containerfile +++ b/container/Containerfile @@ -13,7 +13,6 @@ FROM docker.io/golang:alpine as go RUN apk add gcompat RUN apk add gcc RUN apk add musl-dev -RUN apk add make RUN apk add sqlite WORKDIR /build ADD backend/go.mod backend/go.sum ./ @@ -24,9 +23,7 @@ RUN go mod download # Add the source code 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 # Strip the binary for a smaller image @@ -37,6 +34,7 @@ FROM docker.io/alpine:latest as runner RUN adduser -D nonroot RUN addgroup nonroot nonroot WORKDIR /app +RUN chown nonroot:nonroot /app # Copy the frontend SPA build into public COPY --from=client /build/dist static @@ -44,9 +42,6 @@ COPY --from=client /build/dist static # Copy the server binary COPY --from=go /build/server server -# Copy the database -COPY --from=go /build/db.sqlite3 db.sqlite3 - # Expose port 8080 EXPOSE 8080 From b48434603125167faba7915c32ceae374dba512b Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 21 Mar 2024 02:26:30 +0100 Subject: [PATCH 4/4] Better integration test target --- Justfile | 3 +++ Makefile | 3 +++ backend/Makefile | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Justfile b/Justfile index cb905e4..90fabf6 100644 --- a/Justfile +++ b/Justfile @@ -23,10 +23,13 @@ load-release file: # Tests every part of the project testall: + cd frontend && npm install cd frontend && npm test cd frontend && npm run lint + cd frontend && npm run build cd backend && make test cd backend && make lint + cd backend && make itest # Cleans up everything related to the project clean: remove-podman-containers diff --git a/Makefile b/Makefile index 97db62e..51fb206 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,13 @@ remove-podman-containers: # Tests every part of the project testall: + cd frontend && npm install cd frontend && npm test cd frontend && npm run lint + cd frontend && npm run build cd backend && make test cd backend && make lint + cd backend && make itest # Cleans up everything related to the project clean: remove-podman-containers diff --git a/backend/Makefile b/backend/Makefile index 331f8d5..3443e94 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -8,17 +8,19 @@ GOGET = $(GOCMD) get # SQLite database filename DB_FILE = db.sqlite3 +PROC_NAME = ttime_server + # Directory containing migration SQL scripts MIGRATIONS_DIR = internal/database/migrations SAMPLE_DATA_DIR = internal/database/sample_data # Build target build: - $(GOBUILD) -o bin/server main.go + $(GOBUILD) -o bin/$(PROC_NAME) main.go # Run target run: build - ./bin/server + ./bin/$(PROC_NAME) watch: build watchexec -c -w . -r make run @@ -37,6 +39,16 @@ clean: test: db.sqlite3 $(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 deps: $(GOGET) -v ./...