From be186ae2c7b9da93f6099c20002e0fb145e3a2c7 Mon Sep 17 00:00:00 2001 From: Maxence Maireaux Date: Wed, 25 Sep 2024 17:48:38 +0200 Subject: [PATCH] refactor: Switch from monorepo --- .all-contributorsrc | 136 ---------------- .github/CODEOWNERS | 9 -- .github/FUNDING.yml | 1 - .github/ISSUE_TEMPLATE/bug_report.md | 27 ---- .github/ISSUE_TEMPLATE/feature_request.md | 22 --- .../pull_request_sdk_template.md | 8 - .../pull_request_template.md | 22 --- .github/actions/env/action.yml | 29 ++++ .github/dependabot.yml | 47 +++++- .github/labeler.yml | 23 --- .github/workflows/main.yml | 128 ++++++++++++--- .github/workflows/release.yml | 70 --------- .github/workflows/releases.yml | 74 +++++++++ .gitrepo | 12 -- .goreleaser.ledger.yml | 147 ------------------ .goreleaser.yml | 23 ++- CODEOWNERS | 1 + Earthfile | 35 +++-- LICENSE | 33 ++-- build.Dockerfile | 5 - docker-compose.release.yml | 39 ----- docker-compose.yml | 2 +- .../storage/ledgerstore/transactions_test.go | 2 +- sdkconfig.yaml | 0 test/integration/environment_test.go | 3 +- test/integration/suite_test.go | 3 +- test/performance/performance_test.go | 11 +- 27 files changed, 319 insertions(+), 593 deletions(-) delete mode 100644 .all-contributorsrc delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_sdk_template.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/actions/env/action.yml delete mode 100644 .github/labeler.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/releases.yml delete mode 100644 .gitrepo delete mode 100644 .goreleaser.ledger.yml create mode 100644 CODEOWNERS delete mode 100644 build.Dockerfile delete mode 100644 docker-compose.release.yml delete mode 100644 sdkconfig.yaml diff --git a/.all-contributorsrc b/.all-contributorsrc deleted file mode 100644 index 255ca97e8..000000000 --- a/.all-contributorsrc +++ /dev/null @@ -1,136 +0,0 @@ -{ - "projectName": "ledger", - "projectOwner": "formancehq", - "repoType": "github", - "repoHost": "https://github.com", - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": true, - "commitConvention": "none", - "contributors": [ - { - "login": "Azorlogh", - "name": "Alix Bott", - "avatar_url": "https://avatars.githubusercontent.com/u/17968319?v=4", - "profile": "https://github.com/Azorlogh", - "contributions": [ - "code" - ] - }, - { - "login": "flemzord", - "name": "Maxence Maireaux", - "avatar_url": "https://avatars.githubusercontent.com/u/1952914?v=4", - "profile": "https://www.flemzord.fr/", - "contributions": [ - "infra", - "platform", - "code" - ] - }, - { - "login": "henry-jackson", - "name": "Henry Jackson", - "avatar_url": "https://avatars.githubusercontent.com/u/34102861?v=4", - "profile": "https://github.com/henry-jackson", - "contributions": [ - "code" - ] - }, - { - "login": "matiasinsaurralde", - "name": "Matias Insaurralde", - "avatar_url": "https://avatars.githubusercontent.com/u/20110?v=4", - "profile": "https://matias.insaurral.de/", - "contributions": [ - "code", - "review" - ] - }, - { - "login": "S0c5", - "name": "David barinas", - "avatar_url": "https://avatars.githubusercontent.com/u/5241972?v=4", - "profile": "https://github.com/S0c5", - "contributions": [ - "code" - ] - }, - { - "login": "djimnz", - "name": "David Jimenez", - "avatar_url": "https://avatars.githubusercontent.com/u/949997?v=4", - "profile": "https://github.com/djimnz", - "contributions": [ - "code" - ] - }, - { - "login": "altitude", - "name": "Clément Salaün", - "avatar_url": "https://avatars.githubusercontent.com/u/1770991?v=4", - "profile": "http://32b6.com/", - "contributions": [ - "ideas" - ] - }, - { - "login": "karmanyaahm", - "name": "Karmanyaah Malhotra", - "avatar_url": "https://avatars.githubusercontent.com/u/32671690?v=4", - "profile": "https://karmanyaah.malhotra.cc/", - "contributions": [ - "userTesting" - ] - }, - { - "login": "antoinegelloz", - "name": "Antoine Gelloz", - "avatar_url": "https://avatars.githubusercontent.com/u/42968436?v=4", - "profile": "https://www.linkedin.com/in/antoinegelloz/", - "contributions": [ - "code" - ] - }, - { - "login": "jdupas22", - "name": "jdupas22", - "avatar_url": "https://avatars.githubusercontent.com/u/106673437?v=4", - "profile": "https://github.com/jdupas22", - "contributions": [ - "code" - ] - }, - { - "login": "edwardmp", - "name": "Edward Poot", - "avatar_url": "https://avatars.githubusercontent.com/u/1686739?v=4", - "profile": "https://edwardpoot.com", - "contributions": [ - "code" - ] - }, - { - "login": "nicoabie", - "name": "Nico Gallinal", - "avatar_url": "https://avatars.githubusercontent.com/u/2797992?v=4", - "profile": "https://github.com/nicoabie", - "contributions": [ - "bug" - ] - }, - { - "login": "gfyrag", - "name": "Ragot Geoffrey", - "avatar_url": "https://avatars.githubusercontent.com/u/9094799?v=4", - "profile": "https://github.com/gfyrag", - "contributions": [ - "code" - ] - } - ], - "contributorsPerLine": 7, - "skipCi": true -} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index c381fc0f5..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,9 +0,0 @@ -/api/ @formancehq/dev-backend -/cmd/ @formancehq/dev-backend -/config/ @formancehq/dev-backend -/core/ @formancehq/dev-backend -/ledger/ @formancehq/dev-backend -*.go @formancehq/dev-backend - -/.devcontainer @flemzord -/.github @flemzord diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index f90bcb15a..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: FormanceHQ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index f7757cdf9..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Logs** -If applicable, add logs to help explain your problem. - -**Environment (please complete the following information):** - - OS: [e.g. ubuntu 20.04] - - Numary Version [e.g. 1.0.0-beta.4] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index b36319bac..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement, rfc -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Summary** - -**Solution proposal** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_sdk_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_sdk_template.md deleted file mode 100644 index 3f9f8c2a9..000000000 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_sdk_template.md +++ /dev/null @@ -1,8 +0,0 @@ -# SDK : OPEN API GENERATOR NAME - -__Please add a description to this PR.__ - -## How to deploy - -__Please provide steps to deploy the generated sdk to official channels.__ -__Please be as exhaustive as possible__ diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md deleted file mode 100644 index 3d9bbad90..000000000 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ /dev/null @@ -1,22 +0,0 @@ -# Title - -__Please add a description to this PR.__ - -## Type of change - -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Refactoring / Technical debt - -## What parts of the code are impacted ? -__Please describe the impacted parts of the code.__ - -# Checklist: - -- [ ] My code follows the style guidelines of this project -- [ ] I have performed a self-review of my code -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] My changes generate no new warnings -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/actions/env/action.yml b/.github/actions/env/action.yml new file mode 100644 index 000000000..6cb2e5837 --- /dev/null +++ b/.github/actions/env/action.yml @@ -0,0 +1,29 @@ +name: Setup Env +description: Setup Env for Linux x64 +inputs: + token: + description: 'A Github PAT' + required: true +runs: + using: composite + steps: + - uses: earthly/actions-setup@v1 + with: + github-token: ${{ inputs.token }} + version: "latest" + use-cache: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: "Put back the git branch into git (Earthly uses it for tagging)" + shell: bash + run: | + branch="" + if [ -n "$GITHUB_HEAD_REF" ]; then + branch="$GITHUB_HEAD_REF" + else + branch="${GITHUB_REF##*/}" + fi + git checkout -b "$branch" || true + diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cd51d2c60..77cbf46b6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,51 @@ version: 2 updates: + - package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 40 + labels: [ "dependencies" ] + # Groups are updated together in one pull request + groups: + otel: + patterns: + - "go.opentelemetry.io/otel*" + otel-collector: + patterns: + - "go.opentelemetry.io/collector*" + - "github.com/open-telemetry/o*-collector-contrib/*" + otel-instrumentation: + patterns: + - "go.opentelemetry.io/contrib/instrumentation/*" + go-openapi: + patterns: + - "github.com/go-openapi/*" + - package-ecosystem: gomod + directory: "/ee/**" + schedule: + interval: daily + open-pull-requests-limit: 40 + labels: [ "dependencies" ] + # Groups are updated together in one pull request + groups: + otel: + patterns: + - "go.opentelemetry.io/otel*" + otel-collector: + patterns: + - "go.opentelemetry.io/collector*" + - "github.com/open-telemetry/o*-collector-contrib/*" + otel-instrumentation: + patterns: + - "go.opentelemetry.io/contrib/instrumentation/*" + go-openapi: + patterns: + - "github.com/go-openapi/*" + - package-ecosystem: "github-actions" directory: "/" schedule: - # Check for updates to GitHub Actions every weekday - interval: "daily" + interval: "weekly" + labels: [ "dependencies" ] diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 66ae675cd..000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,23 +0,0 @@ -'@domain/core': - - core/* - - core/**/* - -'@domain/api': - - api/* - - api/**/* - -'@domain/ledger': - - ledger/* - - ledger/**/* - -'@domain/storage': - - storage/* - - storage/**/* - -'@domain/cmd': - - cmd/* - - cmd/**/* - -'@domain/ci': - - .github/* - - .github/**/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 74b43540b..9f354aca5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,33 +1,115 @@ +name: Default on: + merge_group: push: branches: - main + - releases/* + pull_request: + types: [ assigned, opened, synchronize, reopened, labeled ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true -name: Main jobs: - Tests: + PR: + if: github.event_name == 'pull_request' + name: Check PR Title runs-on: ubuntu-latest + permissions: + statuses: write + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + Dirty: + runs-on: "ubuntu-latest" + steps: + - uses: 'actions/checkout@v4' + with: + fetch-depth: 0 + - name: Setup Env + uses: ./.github/actions/env + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - run: > + earthly + --allow-privileged --auto-skip + --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY + ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} + +pre-commit + env: + SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} + - name: Get changed files + id: changed-files + shell: bash + run: | + hasChanged=$(git status --porcelain) + if (( $(echo ${#hasChanged}) != 0 )); then + git status + echo "There are changes in the repository" + exit 1 + fi + + Tests: + runs-on: "ubuntu-latest" + needs: + - Dirty steps: - - uses: actions/checkout@v3 + - uses: 'actions/checkout@v4' with: fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Install Task - uses: arduino/setup-task@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - cache-dependency-path: go.sum - cache: true - - run: task tests - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - name: 'Ledger' - fail_ci_if_error: false # optional (default = false) - verbose: true # optional (default = false) + - name: Setup Env + uses: ./.github/actions/env + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - run: > + earthly + --no-output --auto-skip + --allow-privileged + --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY + ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} + +tests + env: + SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} + + GoReleaser: + runs-on: "ubuntu-latest" + if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group' + needs: + - Dirty + steps: + - uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: "latest" + - uses: 'actions/checkout@v4' + with: + fetch-depth: 0 + - name: Setup Env + uses: ./.github/actions/env + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: "NumaryBot" + password: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - run: > + earthly + --no-output + --allow-privileged + --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY + --secret GITHUB_TOKEN=$GITHUB_TOKEN + --secret FURY_TOKEN=$FURY_TOKEN + --secret GORELEASER_KEY=$GORELEASER_KEY + ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} + +release --mode=ci + env: + GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} + SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} + FURY_TOKEN: ${{ secrets.FURY_TOKEN }} + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 42c1bd2a6..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Ledger - Release -on: - push: - tags: - - 'v*.*.*' - -jobs: - Tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Install Task - uses: arduino/setup-task@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - cache-dependency-path: go.sum - cache: true - - run: task tests - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - name: 'Ledger' - fail_ci_if_error: false # optional (default = false) - verbose: true # optional (default = false) - - GoReleaser: - name: GoReleaser - runs-on: ubuntu-latest - env: - DOCKER_CLI_EXPERIMENTAL: "enabled" - needs: - - Tests - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' - cache: true - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: "NumaryBot" - password: ${{ secrets.NUMARY_GITHUB_TOKEN }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - distribution: goreleaser-pro - version: latest - install-only: true - - run: goreleaser release --clean -f .goreleaser.ledger.yml - env: - GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} - FURY_TOKEN: ${{ secrets.FURY_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 000000000..6a2fbada2 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,74 @@ +name: Release +on: + push: + tags: + - 'v*.*.*' +permissions: + contents: write + +jobs: + Dirty: + runs-on: "ubuntu-latest" + steps: + - uses: 'actions/checkout@v4' + with: + fetch-depth: 0 + - name: Setup Env + uses: ./.github/actions/env + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - run: > + earthly + --allow-privileged + --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY + ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} + +pre-commit + env: + SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} + - name: Get changed files + id: changed-files + run: | + hasChanged=$(git status --porcelain) + if (( $(echo ${#hasChanged}) != 0 )); then + git status + echo "There are changes in the repository" + exit 1 + fi + + GoReleaser: + runs-on: "ubuntu-latest" + needs: + - Dirty + steps: + - uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: "latest" + - uses: 'actions/checkout@v4' + with: + fetch-depth: 0 + - name: Setup Env + uses: ./.github/actions/env + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: "NumaryBot" + password: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - run: > + earthly + --no-output + --allow-privileged + --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY + --secret GITHUB_TOKEN=$GITHUB_TOKEN + --secret FURY_TOKEN=$FURY_TOKEN + --secret GORELEASER_KEY=$GORELEASER_KEY + ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} + +release --mode=release + env: + GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} + SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} + FURY_TOKEN: ${{ secrets.FURY_TOKEN }} + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.gitrepo b/.gitrepo deleted file mode 100644 index 7b7ba7e66..000000000 --- a/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme -; -[subrepo] - remote = ledger - branch = main - commit = b2cc1d284edad80e8ecb5faa83ed0c64aa57e0ba - method = merge - cmdver = 0.4.6 - parent = ce1a99ea700f99e23777eddd863e0155537a4c48 diff --git a/.goreleaser.ledger.yml b/.goreleaser.ledger.yml deleted file mode 100644 index 54fa95176..000000000 --- a/.goreleaser.ledger.yml +++ /dev/null @@ -1,147 +0,0 @@ -project_name: ledger -builds: - - binary: ledger - id: ledger - ldflags: - - -X github.com/formancehq/ledger/cmd.BuildDate={{ .Date }} - - -X github.com/formancehq/ledger/cmd.Version=v{{ .Version }} - - -X github.com/formancehq/ledger/cmd.Commit={{ .ShortCommit }} - - -extldflags "-static" - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - -archives: - - id: "ledger" - builds: - - ledger - format: tar.gz - format_overrides: - - goos: windows - format: zip - name_template: >- - {{ .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - -nfpms: - - id: packages - package_name: ledger - file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" - builds: - - ledger - homepage: https://formance.com - maintainer: Maxence Maireaux - formats: - - deb - - rpm - -publishers: - - name: fury.io - ids: - - packages - dir: "{{ dir .ArtifactPath }}" - cmd: curl --http1.1 -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/ledger/ - -brews: - - repository: - owner: formancehq - name: homebrew-tap - name: ledger - folder: Formula - homepage: https://formance.com - skip_upload: auto - test: | - system "#{bin}/ledger version" - install: | - bin.install "ledger" - -nightly: - name_template: '{{ .FullCommit }}' - publish_release: false - -checksum: - name_template: '{{.ProjectName}}_checksums.txt' - -snapshot: - name_template: "{{ .Version }}" - -changelog: - sort: asc - use: github - filters: - exclude: - - '^docs:' - - '^test:' - - '^spec:' - - Merge pull request - - Merge remote-tracking branch - - Merge branch - - go mod tidy - groups: - - title: 'New Features' - regexp: "^.*feat[(\\w)]*:+.*$" - order: 0 - - title: 'Bug fixes' - regexp: "^.*fix[(\\w)]*:+.*$" - order: 10 - - title: Other work - order: 999 - -release: - prerelease: auto - footer: | - ## What to do next? - - Read the [documentation](https://docs.formance.com/) - - Join our [Slack server](https://formance.com/slack) - - - -dockers: - - image_templates: ["ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-amd64"] - goarch: amd64 - dockerfile: build.Dockerfile - use: buildx - build_flag_templates: - - --platform=linux/amd64 - - --label=org.opencontainers.image.title={{ .ProjectName }} - - --label=org.opencontainers.image.description={{ .ProjectName }} - - --label=org.opencontainers.image.url=https://github.com/formancehq/stack - - --label=org.opencontainers.image.source=https://github.com/formancehq/stack - - --label=org.opencontainers.image.version={{ .Version }} - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} - - --label=org.opencontainers.image.revision={{ .FullCommit }} - - --label=org.opencontainers.image.licenses=MIT - - image_templates: [ "ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-arm64" ] - goarch: arm64 - dockerfile: build.Dockerfile - use: buildx - build_flag_templates: - - --platform=linux/arm64/v8 - - --label=org.opencontainers.image.title={{ .ProjectName }} - - --label=org.opencontainers.image.description={{ .ProjectName }} - - --label=org.opencontainers.image.url=https://github.com/formancehq/stack - - --label=org.opencontainers.image.source=https://github.com/formancehq/stack - - --label=org.opencontainers.image.version={{ .Version }} - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} - - --label=org.opencontainers.image.revision={{ .FullCommit }} - - --label=org.opencontainers.image.licenses=MIT - -docker_manifests: - - name_template: 'ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}' - image_templates: - - 'ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-amd64' - - 'ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-arm64' - - name_template: '{{ if not .IsNightly }}ghcr.io/formancehq/{{ .ProjectName }}:latest{{ end }}' - image_templates: - - 'ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-amd64' - - 'ghcr.io/formancehq/{{ .ProjectName }}:{{ if not .IsNightly }}v{{ end }}{{ .Version }}-arm64' diff --git a/.goreleaser.yml b/.goreleaser.yml index a10afbcbc..06a7b68a3 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,11 +1,11 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json +version: 2 project_name: ledger -monorepo: - tag_prefix: v - dir: ./ includes: - - from_file: - path: ./../../.goreleaser.default.yaml + - from_url: + url: https://raw.githubusercontent.com/formancehq/earthly/refs/heads/main/.goreleaser.default.yaml + builds: - binary: ledger @@ -55,3 +55,16 @@ publishers: - packages dir: "{{ dir .ArtifactPath }}" cmd: curl --http1.1 -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/ledger/ + +brews: + - repository: + owner: formancehq + name: homebrew-tap + name: ledger + directory: Formula + homepage: https://formance.com + skip_upload: auto + test: | + system "#{bin}/ledger version" + install: | + bin.install "ledger" diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 000000000..0309a823b --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @formancehq/backend diff --git a/Earthfile b/Earthfile index 4a629183f..242cf74d7 100644 --- a/Earthfile +++ b/Earthfile @@ -1,14 +1,13 @@ VERSION 0.8 +PROJECT FormanceHQ/ledger IMPORT github.com/formancehq/earthly:tags/v0.16.0 AS core -IMPORT ../../releases AS releases -IMPORT ../.. AS stack -IMPORT .. AS components +IMPORT github.com/formancehq/stack/releases:main AS releases FROM core+base-image sources: - WORKDIR /src/components/ledger + WORKDIR /src COPY go.mod go.sum . COPY --dir internal pkg cmd . COPY main.go . @@ -19,7 +18,7 @@ generate: RUN apk update && apk add openjdk11 DO --pass-args core+GO_INSTALL --package=go.uber.org/mock/mockgen@latest COPY (+sources/*) /src - WORKDIR /src/components/ledger + WORKDIR /src DO --pass-args core+GO_GENERATE SAVE ARTIFACT internal AS LOCAL internal SAVE ARTIFACT pkg AS LOCAL pkg @@ -28,7 +27,7 @@ generate: compile: FROM core+builder-image COPY (+sources/*) /src - WORKDIR /src/components/ledger + WORKDIR /src ARG VERSION=latest DO --pass-args core+GO_COMPILE --VERSION=$VERSION @@ -46,7 +45,7 @@ tests: RUN go install github.com/onsi/ginkgo/v2/ginkgo@latest COPY (+sources/*) /src - WORKDIR /src/components/ledger + WORKDIR /src COPY --dir --pass-args (+generate/*) . COPY --dir test . @@ -97,15 +96,15 @@ deploy: RUN kubectl patch Versions.formance.com default -p "{\"spec\":{\"ledger\": \"${tag}\"}}" --type=merge deploy-staging: - BUILD --pass-args stack+deployer-module --MODULE=ledger + BUILD --pass-args core+deployer-module --MODULE=ledger lint: FROM core+builder-image COPY (+sources/*) /src - WORKDIR /src/components/ledger + WORKDIR /src COPY --pass-args +tidy/go.* . COPY --dir test . - DO --pass-args stack+GO_LINT --ADDITIONAL_ARGUMENTS="--build-tags it" + DO --pass-args core+GO_LINT --ADDITIONAL_ARGUMENTS="--build-tags it" SAVE ARTIFACT cmd AS LOCAL cmd SAVE ARTIFACT internal AS LOCAL internal SAVE ARTIFACT pkg AS LOCAL pkg @@ -126,10 +125,9 @@ bench: FROM core+builder-image DO --pass-args core+GO_INSTALL --package=golang.org/x/perf/cmd/benchstat@latest COPY (+sources/*) /src - WORKDIR /src/components/ledger + WORKDIR /src COPY --dir test . - WORKDIR /src/components/ledger/test/performance - + WORKDIR /src/test/performance ARG benchTime=1s ARG count=1 ARG GOPROXY @@ -163,7 +161,7 @@ openapi: FROM node:20-alpine RUN apk update && apk add yq RUN npm install -g openapi-merge-cli - WORKDIR /src/components/ledger + WORKDIR /src COPY --dir openapi openapi RUN openapi-merge-cli --config ./openapi/openapi-merge.json RUN yq -oy ./openapi.json > openapi.yaml @@ -172,12 +170,15 @@ openapi: tidy: FROM core+builder-image COPY --pass-args (+sources/src) /src - WORKDIR /src/components/ledger + WORKDIR /src COPY --dir test . - DO --pass-args stack+GO_TIDY + DO --pass-args core+GO_TIDY release: - BUILD --pass-args stack+goreleaser --path=components/ledger + FROM core+builder-image + ARG mode=local + COPY --dir . /src + DO core+GORELEASER --mode=$mode generate-client: FROM node:20-alpine diff --git a/LICENSE b/LICENSE index 90bf910c2..4f864e6f8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,22 @@ MIT License -Copyright (c) 2021 Formance, Inc +Copyright (c) 2021-present Formance Solutions -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.Dockerfile b/build.Dockerfile deleted file mode 100644 index 66a786a6f..000000000 --- a/build.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM ghcr.io/formancehq/base:22.04 -COPY ledger /usr/bin/ledger -ENV OTEL_SERVICE_NAME ledger -ENTRYPOINT ["/usr/bin/ledger"] -CMD ["serve"] diff --git a/docker-compose.release.yml b/docker-compose.release.yml deleted file mode 100644 index d450c7631..000000000 --- a/docker-compose.release.yml +++ /dev/null @@ -1,39 +0,0 @@ -version: '3.8' -volumes: - postgres: -services: - postgres: - image: "postgres:13-alpine" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ledger"] - interval: 10s - timeout: 5s - retries: 5 - ports: - - "5432:5432" - command: - - -c - - max_connections=200 - environment: - POSTGRES_USER: "ledger" - POSTGRES_PASSWORD: "ledger" - POSTGRES_DB: "ledger" - PGDATA: /data/postgres - volumes: - - postgres:/data/postgres - - ledger: - image: "ghcr.io/formancehq/ledger:v1.10.4" - healthcheck: - test: ["CMD", "wget", "http://127.0.0.1:3068/_info", "-O", "-", "-q"] - interval: 10s - timeout: 5s - retries: 5 - depends_on: - postgres: - condition: service_healthy - ports: - - "3068:3068" - environment: - STORAGE_DRIVER: "postgres" - STORAGE_POSTGRES_CONN_STRING: "postgresql://ledger:ledger@postgres/ledger?sslmode=disable" diff --git a/docker-compose.yml b/docker-compose.yml index 5be7f5fc6..0b1ffdbf0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ volumes: postgres: services: postgres: - image: "postgres:15-alpine" + image: "postgres:16-alpine" healthcheck: test: ["CMD-SHELL", "pg_isready -U ledger"] interval: 10s diff --git a/internal/storage/ledgerstore/transactions_test.go b/internal/storage/ledgerstore/transactions_test.go index 90fd9e11a..62a2a0142 100644 --- a/internal/storage/ledgerstore/transactions_test.go +++ b/internal/storage/ledgerstore/transactions_test.go @@ -1104,7 +1104,7 @@ func TestGetTransactions(t *testing.T) { if tc.expectError != nil { require.True(t, errors.Is(err, tc.expectError)) } else { - require.NoError(t, err) + require.NoError(t, err) require.Len(t, cursor.Data, len(tc.expected.Data)) internaltesting.RequireEqual(t, *tc.expected, *cursor) diff --git a/sdkconfig.yaml b/sdkconfig.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration/environment_test.go b/test/integration/environment_test.go index 8a0c463b9..70841afe8 100644 --- a/test/integration/environment_test.go +++ b/test/integration/environment_test.go @@ -4,13 +4,14 @@ package test_suite import ( "encoding/json" + "os" + "github.com/formancehq/go-libs/logging" "github.com/formancehq/go-libs/testing/docker" . "github.com/formancehq/go-libs/testing/platform/pgtesting" . "github.com/formancehq/go-libs/testing/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "os" ) var ( diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go index 8f527c415..d9f0dbfc8 100644 --- a/test/integration/suite_test.go +++ b/test/integration/suite_test.go @@ -3,9 +3,10 @@ package test_suite import ( + "testing" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "testing" ) func Test(t *testing.T) { diff --git a/test/performance/performance_test.go b/test/performance/performance_test.go index ad8aff9fe..b35030e01 100644 --- a/test/performance/performance_test.go +++ b/test/performance/performance_test.go @@ -5,6 +5,12 @@ package benchmarks import ( "bytes" "fmt" + "math/big" + "runtime" + "sync" + "sync/atomic" + "testing" + "github.com/formancehq/go-libs/logging" "github.com/formancehq/go-libs/pointer" "github.com/formancehq/go-libs/testing/docker" @@ -15,11 +21,6 @@ import ( "github.com/formancehq/stack/ledger/client/models/components" "github.com/google/uuid" "github.com/stretchr/testify/require" - "math/big" - "runtime" - "sync" - "sync/atomic" - "testing" ) var (