Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
Merged
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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

# Unix-style newlines with a newline ending every file, UTF-8 charset
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# Match Nix files, set indent to spaces with width of two
[*.nix]
indent_style = space
indent_size = 2

[*.go]
indent_style = tab
indent_size = 4
28 changes: 9 additions & 19 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ permissions:
contents: read
pull-requests: write

env:
GOPATH: ${{ github.workspace }}/../go
GO_VERSION: 1.23

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -26,32 +22,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
- uses: cachix/install-nix-action@v31
with:
go-version: ${{ env.GO_VERSION }}
nix_path: nixpkgs=channel:nixos-unstable

- name: Install Task
uses: arduino/setup-task@v2
- name: Build
run: nix build

- name: Lint
run: task lint
run: nix develop -c make lint

- name: Test
run: task test-with-reports
run: nix develop -c make test

- name: Publish Test Results
if: success() || failure()
uses: dorny/test-reporter@v1.9.1
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: Unit & Integration Tests
name: test-results
path: reports/junit-report.xml
reporter: java-junit

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build
run: task build
20 changes: 20 additions & 0 deletions .github/workflows/test-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Test Report'
on:
workflow_run:
workflows: ['Integration Pipeline']
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v2
with:
artifact: test-results
name: JEST Tests
path: junit-report.xml
reporter: jest-junit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ go.work.sum

# build artifacts
bin
reports
reports
data
result
6 changes: 2 additions & 4 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
with-expecter: true
dir: testing/mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_"}}
dir: testing/mocks
filename: "{{.InterfaceName}}.go"
mockname: "Mock{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
pkgname: "mocks"
all: true
recursive: true
packages:
Expand Down
26 changes: 0 additions & 26 deletions Dockerfile

This file was deleted.

16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: lint
lint:
@golangci-lint run

.PHONY: test
test:
@mkdir -p reports
@go test -v -covermode=atomic -coverprofile=reports/coverage.out ./... | tee reports/test-result.out
@go-junit-report < reports/test-result.out > reports/junit-report.xml
@go tool cover -html=reports/coverage.out -o reports/coverage.html

.PHONY: gen
gen:
@gqlgen generate
@mockery
@go generate ./...
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
[![codecov](https://codecov.io/gh/growteer/api/graph/badge.svg?token=Y6SAD10060)](https://codecov.io/gh/growteer/api)

# Setup

- Install Nix, instructions are found here [nixos.org](https://nixos.org/download/)
- Launch a development environment with `nix develop`
- Build the project with `nix build` (output path is `result/bin`)
- Test the project with `nix develop -c make test` (or run `make test` while inside the development shell)
- Lint the project with `nix develop -c make lint` (or run `make lint` while inside the development shell)
- Build a docker image with `nix build .#container` and load the image with `docker load < result`

All current dependencies are ready and available inside `nix develop`, so it is encouraged to use it for developing.

# Upgrade

If the `go.mod` file changes due to an upgrade, please remember to run `gomod2nix generate` to rehydrate the `gomod2nix.toml` file. This file
tracks the dependencies as separatate nix packages and are thus versioned with the flake.
100 changes: 0 additions & 100 deletions Taskfile.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions cmd/main.go → cmd/growteer-api/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package main

import (
"log/slog"
"os"
"os/signal"
"syscall"

"github.com/growteer/api/internal/api"
"github.com/growteer/api/internal/infrastructure/environment"
"github.com/growteer/api/internal/infrastructure/mongodb"
Expand All @@ -9,11 +14,17 @@ import (

func main() {
env := environment.Load()
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGTERM, os.Interrupt)

db := mongodb.NewDB(env.Mongo)
tokenProvider := tokens.NewProvider(env.Token.JWTSecret, env.Token.SessionTTLMinutes, env.Token.RefreshTTLMinutes)

server := api.NewServer(env.Server, db, tokenProvider)

server.Start()

<-sig

slog.Info("shutting down")
}
14 changes: 14 additions & 0 deletions container.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ pkgs, package }:


pkgs.dockerTools.buildImage {
name = "growteer-api";
tag = "0.1";
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ package ];
pathsToLink = [ "/bin" ];
};
config.Cmd = [ "${package}/bin/growteer-api" ];
}
25 changes: 25 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:

buildGoApplication {
pname = "growteer-api";
version = "0.1";
src = ./.;
subPackages = [ "cmd/growteer-api" ];
modules = ./gomod2nix.toml;

CGO_ENABLED = 0;

ldflags = [ "-s -w" ];
}
43 changes: 0 additions & 43 deletions docker-compose.yaml

This file was deleted.

Loading