Skip to content

Commit

Permalink
feat: import payments (#41)
Browse files Browse the repository at this point in the history
* feat: remove payments

* feat: add payments
  • Loading branch information
gfyrag committed Feb 7, 2023
1 parent 3dba442 commit e275da1
Show file tree
Hide file tree
Showing 63 changed files with 1,485 additions and 208 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
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.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
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.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
33 changes: 33 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '35 21 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
92 changes: 92 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
on:
push:
branches:
- 'main'
- 'features/**'
- 'feature/**'
- 'feat/**'
- 'fix/**'
- 'hotfix/**'
pull_request:
types: [ assigned, opened, synchronize, reopened ]
release:
types: [ prereleased, released ]

name: Main
jobs:
pr-style:
if: github.event_name == 'pull_request'
uses: numary/gh-workflows/.github/workflows/pr-style.yml@main

lint:
uses: numary/gh-workflows/.github/workflows/golang-lint.yml@main

test:
uses: numary/gh-workflows/.github/workflows/golang-test.yml@main

goreleaser-build:
if: github.event_name != 'release'
uses: numary/gh-workflows/.github/workflows/goreleaser-build.yml@main
needs:
- lint
- test

goreleaser-release:
if: github.event_name == 'release'
uses: numary/gh-workflows/.github/workflows/goreleaser-release.yml@main
secrets:
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
NUMARY_GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
needs:
- lint
- test

docker-build-push:
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- run: go mod vendor
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: "NumaryBot"
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- if: github.event.action == 'released'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/formancehq/payments:latest,ghcr.io/formancehq/payments:${{ github.event.release.tag_name }}
build-args: |
APP_SHA=${{ github.sha }}
VERSION=${{ github.event.release.tag_name }}
- if: github.event.action == 'prereleased'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/formancehq/payments:${{ github.event.release.tag_name }}
build-args: |
APP_SHA=${{ github.sha }}
VERSION=${{ github.event.release.tag_name }}
- if: github.event.action != 'released' || github.event.action != 'prereleased'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/formancehq/payments:${{ github.sha }}
build-args: |
APP_SHA=${{ github.sha }}
VERSION=develop
4 changes: 2 additions & 2 deletions .gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = payments
branch = main
commit = e4c0f219fda7416c2a3d30fe7ec4184870134999
parent = b2827a506b6324812752e3689b2a4845480a397e
commit = 5e3b64477ac01e4101e043d7615f6eb7e89770cd
parent = dbe6ffd24f70f31891411c03c2377ad30d32160c
method = merge
cmdver = 0.4.5
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
linters-settings:
interfacebloat:
max: 20
dupl:
threshold: 30
funlen:
Expand Down
100 changes: 51 additions & 49 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
project_name: payments

monorepo:
tag_prefix: components/payments/
dir: ./components/payments/
env:
- GO111MODULE=on
- GOPROXY=https://proxy.golang.org
before:
hooks:
- go mod download

builds:
- binary: payments
id: payments
ldflags:
- -X github.com/numary/payments/cmd.BuildDate={{ .Date }}
- -X github.com/numary/payments/cmd.Version={{ .Version }}
- -X github.com/numary/payments/cmd.Commit={{ .ShortCommit }}
- -X github.com/formancehq/payments/cmd.BuildDate={{ .Date }}
- -X github.com/formancehq/payments/cmd.Version={{ .Version }}
- -X github.com/formancehq/payments/cmd.Commit={{ .ShortCommit }}
- -extldflags "-static"
env:
- CGO_ENABLED=0
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
flags:
- -tags=json1

archives:
- id: "{{.ProjectName}}"
- id: "payments"
builds:
- payments
format: tar.gz
format_overrides:
- goos: windows
format: zip
name_template: "{{.ProjectName}}_{{.Os}}-{{.Arch}}"


checksum:
name_template: '{{.ProjectName}}_checksums.txt'
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}"
Expand Down Expand Up @@ -58,47 +67,40 @@ changelog:

release:
prerelease: auto
draft: true
footer: |
**Full Changelog**: https://github.com/formancehq/payments/compare/{{ .PreviousTag }}...{{ .Tag }}
## What to do next?
- Read the [documentation](https://docs.formance.com/)
- Join our [Slack server](https://formance.com/slack)
- Read the [documentation](https://docs.formance.com/oss/payments/get-started/installation)
- Join our [Discord server](https://discord.gg/xyHvcbzk4w)
brews:
- tap:
owner: numary
name: homebrew-tap
name: payments
folder: Formula
homepage: https://formance.com
skip_upload: 'false'
test: |
system "#{bin}/payments version"
install: |
bin.install "payments"
nfpms:
- id: packages
package_name: payments
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
builds:
- payments
homepage: https://formance.com
maintainer: Maxence Maireaux <maxence@formance.com>
formats:
- deb
- rpm

dockers:
- image_templates: ["ghcr.io/formancehq/{{ .ProjectName }}:v{{ .Version }}-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 }}:v{{ .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 }}:v{{ .Version }}
image_templates:
- ghcr.io/formancehq/{{ .ProjectName }}:v{{ .Version }}-amd64
- ghcr.io/formancehq/{{ .ProjectName }}:v{{ .Version }}-arm64
- name_template: ghcr.io/formancehq/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/formancehq/{{ .ProjectName }}:v{{ .Version }}-amd64
- ghcr.io/formancehq/{{ .ProjectName }}:v{{ .Version }}-arm64
publishers:
- name: fury.io
ids:
- packages
dir: "{{ dir .ArtifactPath }}"
cmd: curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/numary/
48 changes: 32 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
FROM golang:1.18 AS builder
FROM golang:1.19.3-bullseye AS builder

RUN apt-get update && \
apt-get install -y gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu && \
ln -s /usr/bin/aarch64-linux-gnu-gcc /usr/bin/arm64-linux-gnu-gcc && \
ln -s /usr/bin/x86_64-linux-gnu-gcc /usr/bin/amd64-linux-gnu-gcc

ARG TARGETARCH
ARG APP_SHA
ARG VERSION
WORKDIR /src

WORKDIR /go/src/github.com/formancehq/payments

# get deps first so it's cached
COPY . .
WORKDIR /src/components/payments
RUN go mod download
RUN GOOS=linux go build -o payments \
-ldflags="-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.Version=${VERSION} \
-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.BuildDate=$(date +%s) \
-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.Commit=${APP_SHA}" ./

FROM ubuntu:jammy
RUN apt update && apt install -y ca-certificates curl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/components/payments/payments /payments
EXPOSE 3068
ENV OTEL_SERVICE_NAME payments
ENTRYPOINT ["/payments"]
CMD ["serve"]

RUN go mod vendor

RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH \
CC=$TARGETARCH-linux-gnu-gcc \
go build -o bin/payments \
-ldflags="-X github.com/formancehq/payments/cmd.Version=${VERSION} \
-X github.com/formancehq/payments/cmd.BuildDate=$(date +%s) \
-X github.com/formancehq/payments/cmd.Commit=${APP_SHA}" ./

FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/formancehq/payments/bin/payments /usr/local/bin/payments

EXPOSE 8080

ENTRYPOINT ["payments"]
ENV OTEL_SERVICE_NAME=payments
CMD ["server"]
6 changes: 0 additions & 6 deletions build.Dockerfile

This file was deleted.

Loading

0 comments on commit e275da1

Please sign in to comment.