-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/broken-installation-link
- Loading branch information
Showing
366 changed files
with
15,181 additions
and
9,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
use flake --impure | ||
dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ dist | |
vendor | ||
worktrees | ||
dumps | ||
.env | ||
!.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
VERSION 0.8 | ||
VERSION --wildcard-builds 0.8 | ||
PROJECT FormanceHQ/ledger | ||
|
||
IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core | ||
|
||
FROM core+base-image | ||
|
||
CACHE --sharing=shared --id go-mod-cache /go/pkg/mod | ||
CACHE --sharing=shared --id golangci-cache /root/.cache/golangci-lint | ||
CACHE --sharing=shared --id go-cache /root/.cache/go-build | ||
IMPORT github.com/formancehq/earthly:tags/v0.19.0 AS core | ||
|
||
postgres: | ||
FROM postgres:15-alpine | ||
|
@@ -22,29 +16,12 @@ sources: | |
WORKDIR /src | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY --dir internal pkg cmd tools . | ||
COPY --dir internal pkg cmd . | ||
COPY main.go . | ||
SAVE ARTIFACT /src | ||
|
||
generate: | ||
FROM core+builder-image | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
RUN apk update && apk add openjdk11 | ||
RUN go install go.uber.org/mock/[email protected] | ||
RUN go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest | ||
COPY (+sources/*) /src | ||
WORKDIR /src | ||
RUN go generate ./... | ||
SAVE ARTIFACT internal AS LOCAL internal | ||
SAVE ARTIFACT pkg AS LOCAL pkg | ||
SAVE ARTIFACT cmd AS LOCAL cmd | ||
|
||
compile: | ||
FROM +sources | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
WORKDIR /src | ||
LOCALLY | ||
ARG VERSION=latest | ||
RUN go build -o main -ldflags="-X ${GIT_PATH}/cmd.Version=${VERSION} \ | ||
-X ${GIT_PATH}/cmd.BuildDate=$(date +%s) \ | ||
|
@@ -60,49 +37,6 @@ build-image: | |
ARG tag=latest | ||
DO --pass-args core+SAVE_IMAGE --COMPONENT=ledger --REPOSITORY=${REPOSITORY} --TAG=$tag | ||
|
||
tests: | ||
FROM +tidy | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
RUN go install github.com/onsi/ginkgo/v2/ginkgo@latest | ||
COPY --dir --pass-args (+generate/*) . | ||
|
||
ARG includeIntegrationTests="true" | ||
ARG includeEnd2EndTests="true" | ||
ARG coverage="" | ||
ARG debug=false | ||
|
||
ENV DEBUG=$debug | ||
ENV CGO_ENABLED=1 # required for -race | ||
RUN apk add gcc musl-dev | ||
|
||
LET goFlags="-race" | ||
IF [ "$coverage" = "true" ] | ||
SET goFlags="$goFlags -covermode=atomic" | ||
SET goFlags="$goFlags -coverpkg=github.com/formancehq/ledger/internal/..." | ||
SET goFlags="$goFlags,github.com/formancehq/ledger/pkg/events/..." | ||
SET goFlags="$goFlags,github.com/formancehq/ledger/pkg/accounts/..." | ||
SET goFlags="$goFlags,github.com/formancehq/ledger/pkg/assets/..." | ||
SET goFlags="$goFlags,github.com/formancehq/ledger/cmd/..." | ||
SET goFlags="$goFlags -coverprofile coverage.txt" | ||
END | ||
|
||
IF [ "$includeIntegrationTests" = "true" ] | ||
SET goFlags="$goFlags -tags it" | ||
WITH DOCKER --load=postgres:15-alpine=+postgres | ||
RUN go test $goFlags ./... | ||
END | ||
ELSE | ||
RUN go test $goFlags ./... | ||
END | ||
IF [ "$coverage" = "true" ] | ||
# as special case, exclude files suffixed by debug.go | ||
# toremovelater: exclude machine code as it will be updated soon | ||
RUN cat coverage.txt | grep -v debug.go | grep -v "/machine/" > coverage2.txt | ||
RUN mv coverage2.txt coverage.txt | ||
SAVE ARTIFACT coverage.txt AS LOCAL coverage.txt | ||
END | ||
|
||
deploy: | ||
COPY (+sources/*) /src | ||
LET tag=$(tar cf - /src | sha1sum | awk '{print $1}') | ||
|
@@ -115,32 +49,10 @@ deploy: | |
deploy-staging: | ||
BUILD --pass-args core+deploy-staging | ||
|
||
lint: | ||
#todo: get config from core | ||
FROM +tidy | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
CACHE --id golangci-cache /root/.cache/golangci-lint | ||
|
||
RUN golangci-lint run --fix --build-tags it --timeout 5m | ||
|
||
SAVE ARTIFACT cmd AS LOCAL cmd | ||
SAVE ARTIFACT internal AS LOCAL internal | ||
SAVE ARTIFACT pkg AS LOCAL pkg | ||
SAVE ARTIFACT test AS LOCAL test | ||
SAVE ARTIFACT tools AS LOCAL tools | ||
SAVE ARTIFACT main.go AS LOCAL main.go | ||
|
||
pre-commit: | ||
WAIT | ||
BUILD +tidy | ||
BUILD +lint | ||
BUILD +openapi | ||
BUILD +openapi-markdown | ||
END | ||
BUILD +generate | ||
BUILD +openapi | ||
BUILD +openapi-markdown | ||
BUILD +generate-client | ||
BUILD +export-docs-events | ||
|
||
openapi: | ||
FROM node:20-alpine | ||
|
@@ -159,20 +71,6 @@ openapi-markdown: | |
RUN widdershins openapi.yaml -o README.md --search false --language_tabs 'http:HTTP' --summary --omitHeader | ||
SAVE ARTIFACT README.md AS LOCAL docs/api/README.md | ||
|
||
tidy: | ||
FROM +sources | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
WORKDIR /src | ||
COPY --dir test . | ||
RUN go mod tidy | ||
|
||
release: | ||
FROM core+builder-image | ||
ARG mode=local | ||
COPY --dir . /src | ||
DO core+GORELEASER --mode=$mode | ||
|
||
generate-client: | ||
FROM node:20-alpine | ||
RUN apk update && apk add yq jq | ||
|
@@ -189,18 +87,23 @@ generate-client: | |
export-database-schema: | ||
FROM +sources | ||
RUN go install github.com/roerohan/wait-for-it@latest | ||
COPY --dir scripts scripts | ||
WITH DOCKER --load=postgres:15-alpine=+postgres --pull schemaspy/schemaspy:6.2.4 | ||
RUN ./scripts/export-database-schema.sh | ||
RUN bash -c ' | ||
echo "Creating PG server..."; | ||
postgresContainerID=$(docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -e POSTGRES_DB=formance --net=host postgres:15-alpine); | ||
wait-for-it -w 127.0.0.1:5432; | ||
echo "Creating bucket..."; | ||
go run main.go buckets upgrade _default --postgres-uri "postgres://root:[email protected]:5432/formance?sslmode=disable"; | ||
echo "Exporting schemas..."; | ||
docker run --rm -u root \ | ||
-v ./docs/database:/output \ | ||
--net=host \ | ||
schemaspy/schemaspy:6.2.4 -u root -db formance -t pgsql11 -host 127.0.0.1 -port 5432 -p root -schemas _system,_default; | ||
docker kill "$postgresContainerID"; | ||
' | ||
END | ||
SAVE ARTIFACT docs/database/_system/diagrams AS LOCAL docs/database/_system/diagrams | ||
SAVE ARTIFACT docs/database/_default/diagrams AS LOCAL docs/database/_default/diagrams | ||
|
||
export-docs-events: | ||
FROM +tidy | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
|
||
RUN go run tools/docs/events/main.go --write-dir docs/events | ||
|
||
SAVE ARTIFACT docs/events AS LOCAL docs/events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
set dotenv-load | ||
|
||
default: | ||
@just --list | ||
|
||
pre-commit: generate earthly tidy lint export-docs-events | ||
|
||
earthly: | ||
@earthly --no-output +pre-commit | ||
|
||
lint: | ||
@golangci-lint run --fix --build-tags it --timeout 5m | ||
@cd {{justfile_directory()}}/tools/generator && golangci-lint run --fix --build-tags it --timeout 5m | ||
@cd {{justfile_directory()}}/deployments/pulumi && golangci-lint run --fix --build-tags it --timeout 5m | ||
|
||
tidy: | ||
@go mod tidy | ||
@cd {{justfile_directory()}}/tools/generator && go mod tidy | ||
@cd {{justfile_directory()}}/deployments/pulumi && go mod tidy | ||
|
||
generate: | ||
@go generate ./... | ||
|
||
export-docs-events: | ||
@go run . docs events --write-dir docs/events | ||
|
||
tests: | ||
@go test -race -covermode=atomic \ | ||
-coverpkg=github.com/formancehq/ledger/internal/... \ | ||
-coverpkg=github.com/formancehq/ledger/pkg/events/... \ | ||
-coverpkg=github.com/formancehq/ledger/pkg/accounts/... \ | ||
-coverpkg=github.com/formancehq/ledger/pkg/assets/... \ | ||
-coverpkg=github.com/formancehq/ledger/cmd/... \ | ||
-coverprofile coverage.txt \ | ||
-tags it \ | ||
./... | ||
@cat coverage.txt | grep -v debug.go | grep -v "/machine/" > coverage2.txt | ||
@mv coverage2.txt coverage.txt | ||
|
||
release-local: | ||
@goreleaser release --nightly --skip=publish --clean | ||
|
||
release-ci: | ||
@goreleaser release --nightly --clean | ||
|
||
release: | ||
@goreleaser release --clean |
Oops, something went wrong.