-
Notifications
You must be signed in to change notification settings - Fork 117
chore: remove some infrastructure tests (moved to dedicated repository) #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f0c054e
165c764
6421ffb
497cb24
e28a9b9
b2b240e
8298be8
bdf9a16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Generate dataset | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ledger-version: | ||
description: 'The version of the ledger to deploy' | ||
required: true | ||
preview: | ||
description: 'Preview the changes' | ||
required: false | ||
type: boolean | ||
rds-db-subnet-group-name: | ||
description: 'The network to deploy the RDS instance to' | ||
required: false | ||
until-log-id: | ||
description: 'The log id to stop at' | ||
required: false | ||
generator-version: | ||
default: 'latest' | ||
description: 'The version of the generator to use' | ||
required: false | ||
namespace: | ||
default: 'default' | ||
description: 'The namespace to deploy the dataset to' | ||
required: false | ||
create-snapshot: | ||
default: 'false' | ||
description: 'Create a snapshot of the dataset' | ||
required: false | ||
script: | ||
required: true | ||
description: 'The script to generate the dataset' | ||
|
||
jobs: | ||
GenerateDataset: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pulumi/actions@v6 | ||
with: | ||
command: ${{ github.event.inputs.preview == 'true' && 'preview' || 'up' }} | ||
stack-name: formancehq/${{ github.event.inputs.ledger-version }} | ||
work-dir: './tools/dataset' | ||
config-map: | ||
ledger-version: ${{ github.event.inputs.ledger-version }} | ||
rds-db-subnet-group-name: ${{ github.event.inputs.rds-db-subnet-group-name }} | ||
until-log-id: ${{ github.event.inputs.until-log-id }} | ||
generator-version: ${{ github.event.inputs.generator-version }} | ||
namespace: ${{ github.event.inputs.namespace }} | ||
create-snapshot: ${{ github.event.inputs.create-snapshot }} | ||
script: ${{ github.event.inputs.script }} | ||
env: | ||
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
VERSION 0.8 | ||
PROJECT FormanceHQ/ledger | ||
|
||
IMPORT github.com/formancehq/earthly:tags/v0.19.0 AS core | ||
|
||
FROM core+base-image | ||
|
||
CACHE --sharing=shared --id go-mod-cache /go/pkg/mod | ||
CACHE --sharing=shared --id go-cache /root/.cache/go-build | ||
CACHE --sharing=shared --id golangci-cache /root/.cache/golangci-lint | ||
|
||
sources: | ||
FROM core+builder-image | ||
WORKDIR /src | ||
COPY *.go go.* Pulumi.yaml . | ||
COPY --dir pkg . | ||
SAVE ARTIFACT /src | ||
|
||
tidy: | ||
FROM +sources | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
RUN go mod tidy | ||
|
||
SAVE ARTIFACT go.mod AS LOCAL go.mod | ||
SAVE ARTIFACT go.sum AS LOCAL go.sum | ||
|
||
lint: | ||
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 main.go AS LOCAL main.go | ||
SAVE ARTIFACT pkg AS LOCAL pkg | ||
|
||
pre-commit: | ||
BUILD +tidy | ||
BUILD +lint | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
package main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"errors" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/formancehq/ledger/deployments/pulumi/ledger/pkg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func main() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pulumi.Run(func(ctx *pulumi.Context) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
conf := config.New(ctx, "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
postgresURI := conf.Require("postgres.uri") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
namespace, err := conf.Try("namespace") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
namespace = "default" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version, err := conf.Try("version") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version = "latest" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout, err := conf.TryInt("timeout") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if errors.Is(err, config.ErrMissingVar) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout = 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("error reading timeout: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
debug, _ := conf.TryBool("debug") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
imagePullPolicy, _ := conf.Try("image.pullPolicy") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
replicaCount, _ := conf.TryInt("replicaCount") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
experimentalFeatures, _ := conf.TryBool("experimentalFeatures") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling consistency for optional configurations. The error handling is inconsistent across optional configurations. Some errors are silently ignored which could lead to unexpected behavior. Consider validating and logging when using default values: - debug, _ := conf.TryBool("debug")
- imagePullPolicy, _ := conf.Try("image.pullPolicy")
- replicaCount, _ := conf.TryInt("replicaCount")
- experimentalFeatures, _ := conf.TryBool("experimentalFeatures")
+ debug, err := conf.TryBool("debug")
+ if err != nil && !errors.Is(err, config.ErrMissingVar) {
+ return fmt.Errorf("invalid debug configuration: %w", err)
+ }
+
+ imagePullPolicy, err := conf.Try("image.pullPolicy")
+ if err != nil && !errors.Is(err, config.ErrMissingVar) {
+ return fmt.Errorf("invalid imagePullPolicy configuration: %w", err)
+ }
+
+ replicaCount, err := conf.TryInt("replicaCount")
+ if err != nil && !errors.Is(err, config.ErrMissingVar) {
+ return fmt.Errorf("invalid replicaCount configuration: %w", err)
+ }
+ if replicaCount < 0 {
+ return fmt.Errorf("replicaCount must be non-negative")
+ }
+
+ experimentalFeatures, err := conf.TryBool("experimentalFeatures")
+ if err != nil && !errors.Is(err, config.ErrMissingVar) {
+ return fmt.Errorf("invalid experimentalFeatures configuration: %w", err)
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_, err = pulumi_ledger.NewLedgerComponent(ctx, "ledger", &pulumi_ledger.LedgerComponentArgs{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Namespace: pulumi.String(namespace), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Timeout: pulumi.Int(timeout), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tag: pulumi.String(version), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ImagePullPolicy: pulumi.String(imagePullPolicy), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PostgresURI: pulumi.String(postgresURI), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Debug: pulumi.Bool(debug), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ReplicaCount: pulumi.Int(replicaCount), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ExperimentalFeatures: pulumi.Bool(experimentalFeatures), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package pulumi_ledger | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/helm/v3" | ||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||
"github.com/pulumi/pulumi/sdk/v3/go/pulumix" | ||
) | ||
|
||
type LedgerComponent struct { | ||
pulumi.ResourceState | ||
|
||
ServiceName pulumix.Output[string] | ||
ServiceNamespace pulumix.Output[string] | ||
ServicePort pulumix.Output[int] | ||
ServiceInternalURL pulumix.Output[string] | ||
} | ||
|
||
type LedgerComponentArgs struct { | ||
Namespace pulumix.Input[string] | ||
Timeout pulumix.Input[int] | ||
Tag pulumix.Input[string] | ||
ImagePullPolicy pulumix.Input[string] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Include 'ImagePullPolicy' in Container specification The Apply this diff to include v3.ContainerArgs{
Name: pulumi.String("ledger"),
Image: pulumi.Sprintf("ghcr.io/formancehq/ledger:%s", tag),
+ ImagePullPolicy: args.ImagePullPolicy.ToStringPtrOutput(), Ensure that Also applies to: 102-102 |
||
PostgresURI pulumix.Input[string] | ||
Debug pulumix.Input[bool] | ||
ReplicaCount pulumix.Input[int] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the 'ReplicaCount' argument in Deployment specification The Apply this diff to utilize v1.DeploymentSpecArgs{
- Replicas: pulumi.Int(1),
+ Replicas: args.ReplicaCount.ToIntPtrOutput(),
Selector: &v2.LabelSelectorArgs{ Ensure that Also applies to: 86-86 |
||
ExperimentalFeatures pulumix.Input[bool] | ||
} | ||
|
||
func NewLedgerComponent(ctx *pulumi.Context, name string, args *LedgerComponentArgs, opts ...pulumi.ResourceOption) (*LedgerComponent, error) { | ||
cmp := &LedgerComponent{} | ||
err := ctx.RegisterComponentResource("Formance:Ledger", name, cmp, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
rel, err := helm.NewRelease(ctx, "ledger", &helm.ReleaseArgs{ | ||
Chart: pulumi.String("../../../helm"), | ||
Namespace: pulumix.Cast[pulumi.StringOutput](args.Namespace), | ||
CreateNamespace: pulumi.BoolPtr(true), | ||
Timeout: pulumix.Cast[pulumi.IntOutput](args.Timeout), | ||
Values: pulumi.Map(map[string]pulumi.Input{ | ||
"image": pulumi.Map{ | ||
"repository": pulumi.String("ghcr.io/formancehq/ledger"), | ||
"tag": args.Tag, | ||
"pullPolicy": args.ImagePullPolicy, | ||
}, | ||
"postgres": pulumi.Map{ | ||
"uri": args.PostgresURI, | ||
}, | ||
"debug": args.Debug, | ||
"replicaCount": args.ReplicaCount, | ||
"experimentalFeatures": args.ExperimentalFeatures, | ||
}), | ||
}, pulumi.Parent(cmp)) | ||
if err != nil { | ||
return nil, fmt.Errorf("installing release: %w", err) | ||
} | ||
|
||
cmp.ServiceName = pulumix.Apply(rel.Status.Name().ToStringPtrOutput(), func(a1 *string) string { | ||
return *a1 | ||
}) | ||
cmp.ServiceNamespace = pulumix.Apply(rel.Status.Namespace().ToStringPtrOutput(), func(a1 *string) string { | ||
return *a1 | ||
}) | ||
cmp.ServicePort = pulumix.Val(8080) | ||
cmp.ServiceInternalURL = pulumix.Apply(pulumi.Sprintf( | ||
"http://%s.%s.svc.cluster.local:%d", | ||
cmp.ServiceName, | ||
cmp.ServiceNamespace, | ||
cmp.ServicePort, | ||
), func(a1 string) string { | ||
return a1 | ||
}) | ||
|
||
if err := ctx.RegisterResourceOutputs(cmp, pulumi.Map{ | ||
"service-name": cmp.ServiceName, | ||
"service-namespace": cmp.ServiceNamespace, | ||
"service-port": cmp.ServicePort, | ||
"service-internal-url": cmp.ServiceInternalURL, | ||
}); err != nil { | ||
return nil, fmt.Errorf("registering resource outputs: %w", err) | ||
} | ||
|
||
return cmp, nil | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
VERSION 0.8 | ||
PROJECT FormanceHQ/ledger | ||
|
||
IMPORT github.com/formancehq/earthly:tags/v0.19.0 AS core | ||
|
||
FROM core+base-image | ||
|
||
CACHE --sharing=shared --id go-mod-cache /go/pkg/mod | ||
CACHE --sharing=shared --id go-cache /root/.cache/go-build | ||
CACHE --sharing=shared --id golangci-cache /root/.cache/golangci-lint | ||
|
||
sources: | ||
FROM core+builder-image | ||
WORKDIR /src | ||
COPY *.go go.* Pulumi.yaml . | ||
COPY --dir pkg . | ||
SAVE ARTIFACT /src | ||
|
||
tidy: | ||
FROM +sources | ||
CACHE --id go-mod-cache /go/pkg/mod | ||
CACHE --id go-cache /root/.cache/go-build | ||
RUN go mod tidy | ||
|
||
SAVE ARTIFACT go.mod AS LOCAL go.mod | ||
SAVE ARTIFACT go.sum AS LOCAL go.sum | ||
|
||
lint: | ||
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 main.go AS LOCAL main.go | ||
SAVE ARTIFACT pkg AS LOCAL pkg | ||
|
||
pre-commit: | ||
BUILD +tidy | ||
BUILD +lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: postgres | ||
description: A minimal Kubernetes Go Pulumi program | ||
runtime: go | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: kubernetes-go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider enhancing pre-commit checks
The pre-commit target could benefit from additional validation steps: