Skip to content

Commit 7ce9adb

Browse files
committed
feat: test CI
1 parent e28a9b9 commit 7ce9adb

File tree

3 files changed

+161
-20
lines changed

3 files changed

+161
-20
lines changed

.github/workflows/dataset.yml

Lines changed: 98 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,85 @@ on:
3434
description: 'The organization to deploy the dataset to'
3535
required: false
3636
default: formance
37-
kubeconfig:
38-
description: 'The kubeconfig to use'
37+
refresh:
38+
default: false
39+
description: 'Refresh the stack'
40+
required: false
41+
workflow_call:
42+
secrets:
43+
PULUMI_ACCESS_TOKEN:
44+
required: true
45+
KUBE_APISERVER:
46+
required: true
47+
KUBE_TOKEN:
48+
required: true
49+
TS_OAUTH_CLIENT_ID:
50+
required: true
51+
TS_OAUTH_SECRET:
52+
required: true
53+
inputs:
54+
ledger-version:
55+
type: string
56+
description: 'The version of the ledger to deploy'
57+
required: true
58+
preview:
59+
description: 'Preview the changes'
60+
required: false
61+
type: boolean
62+
rds-db-subnet-group-name:
63+
type: string
64+
description: 'The network to deploy the RDS instance to'
65+
required: false
66+
until-log-id:
67+
type: number
68+
description: 'The log id to stop at'
69+
required: false
70+
generator-version:
71+
type: string
72+
default: 'latest'
73+
description: 'The version of the generator to use'
74+
required: false
75+
namespace:
76+
type: string
77+
default: 'default'
78+
description: 'The namespace to deploy the dataset to'
79+
required: false
80+
create-snapshot:
81+
type: boolean
82+
default: false
83+
description: 'Create a snapshot of the dataset'
84+
required: false
85+
script:
86+
type: string
3987
required: true
88+
description: 'The script to generate the dataset'
89+
organization:
90+
type: string
91+
description: 'The organization to deploy the dataset to'
92+
required: false
93+
default: formance
94+
refresh:
95+
type: boolean
96+
default: false
97+
description: 'Refresh the stack'
98+
required: false
99+
destroy:
100+
type: boolean
101+
default: true
102+
description: 'Destroy the stack'
103+
required: false
40104

41105
concurrency:
42-
group: dataset-${{ github.event.inputs.ledger-version }}
106+
group: dataset-${{ inputs.ledger-version }}
43107
cancel-in-progress: true
44108

45109
jobs:
46110
Run:
47111
name: Generate dataset
48112
runs-on: ubuntu-latest
113+
permissions:
114+
id-token: write
115+
contents: read
49116
steps:
50117
- uses: actions/checkout@v4
51118
name: Checkout
@@ -55,13 +122,18 @@ jobs:
55122
- name: Configure AWS credentials
56123
uses: aws-actions/configure-aws-credentials@v4
57124
with:
58-
role-to-assume: arn:aws:iam::288350113309:role/github-access
125+
role-to-assume: arn:aws:iam::955332203423:role/github-access
59126
aws-region: eu-west-1
60-
#aws-region: us-east-1
127+
- name: Tailscale
128+
uses: tailscale/github-action@v2
129+
with:
130+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
131+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
132+
tags: tag:ci
61133
- name: Create kube config file
62134
env:
63-
KUBE_APISERVER: ${{ secrets.FORMANCE_DEV_KUBE_API_SERVER_ADDRESS }}
64-
KUBE_TOKEN: ${{ secrets.FORMANCE_DEV_KUBE_TOKEN }}
135+
KUBE_APISERVER: ${{ secrets.KUBE_APISERVER }}
136+
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
65137
run: |
66138
mkdir .kube;
67139
@@ -87,30 +159,37 @@ jobs:
87159
- uses: pulumi/actions@v6
88160
name: Run Pulumi
89161
with:
90-
command: ${{ github.event.inputs.preview == 'true' && 'preview' || 'up' }}
91-
stack-name: ${{ github.event.inputs.organization }}/ledger-dataset/${{ github.event.inputs.ledger-version }}
162+
command: ${{ inputs.preview && 'preview' || 'up' }}
163+
stack-name: ${{ inputs.organization }}/ledger-dataset/${{ inputs.ledger-version }}
92164
work-dir: './tools/dataset'
165+
suppress-progress: 'true'
166+
refresh: ${{ inputs.refresh }}
93167
config-map: |
94168
ledger-version:
95-
value: ${{ github.event.inputs.ledger-version }}
169+
value: ${{ inputs.ledger-version }}
96170
rds-db-subnet-group-name:
97-
value: ${{ github.event.inputs.rds-db-subnet-group-name }}
171+
value: ${{ inputs.rds-db-subnet-group-name }}
98172
until-log-id:
99-
value: ${{ github.event.inputs.until-log-id }}
173+
value: ${{ inputs.until-log-id }}
100174
generator-version:
101-
value: ${{ github.event.inputs.generator-version }}
175+
value: ${{ inputs.generator-version }}
102176
namespace:
103-
value: ${{ github.event.inputs.namespace }}
177+
value: ${{ inputs.namespace }}
104178
create-snapshot:
105-
value: ${{ github.event.inputs.create-snapshot }}
179+
value: ${{ inputs.create-snapshot }}
106180
script:
107-
value: "${{ github.event.inputs.script }}"
108-
upsert: 'true'
181+
value: "${{ inputs.script }}"
182+
upsert: true
109183
env:
110184
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
185+
KUBECONFIG: /home/runner/work/ledger/ledger/.kube/config
111186
- uses: pulumi/actions@v6
112187
name: Clean resources
188+
if: ${{ inputs.destroy && !inputs.preview }}
113189
with:
114190
command: destroy
115-
stack-name: ${{ github.event.inputs.organization }}/ledger-dataset/${{ github.event.inputs.ledger-version }}
116-
work-dir: './tools/dataset'
191+
stack-name: ${{ inputs.organization }}/ledger-dataset/${{ inputs.ledger-version }}
192+
work-dir: './tools/dataset'
193+
env:
194+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
195+
KUBECONFIG: /home/runner/work/ledger/ledger/.kube/config

.github/workflows/test_data.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test Generate V2.1
2+
on:
3+
pull_request:
4+
types: [ assigned, opened, synchronize, reopened, labeled ]
5+
6+
jobs:
7+
Run:
8+
uses: ./.github/workflows/dataset.yml
9+
secrets:
10+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
11+
KUBE_APISERVER: ${{ secrets.FORMANCE_DEV_KUBE_API_SERVER_ADDRESS }}
12+
KUBE_TOKEN: ${{ secrets.FORMANCE_DEV_KUBE_TOKEN }}
13+
TS_OAUTH_CLIENT_ID: ${{ secrets.TS_OAUTH_CLIENT_ID }}
14+
TS_OAUTH_SECRET: ${{ secrets.TS_OAUTH_SECRET }}
15+
with:
16+
ledger-version: 'v2.1'
17+
organization: 'formance'
18+
rds-db-subnet-group-name: 'staging-eu-west-1-hosting'
19+
until-log-id: 1000
20+
generator-version: 'latest'
21+
namespace: ledger-dataset-v2-1
22+
create-snapshot: false
23+
preview: false
24+
refresh: true
25+
destroy: false
26+
script: |
27+
const plain = `vars {
28+
account $order
29+
account $seller
30+
}
31+
send [USD/2 100] (
32+
source = @world
33+
destination = $order
34+
)
35+
send [USD/2 1] (
36+
source = $order
37+
destination = @fees
38+
)
39+
send [USD/2 99] (
40+
source = $order
41+
destination = $seller
42+
)`
43+
44+
function next(iteration) {
45+
return [{
46+
action: 'CREATE_TRANSACTION',
47+
data: {
48+
script: {
49+
plain,
50+
vars: {
51+
order: `orders:${uuid()}`,
52+
seller: `sellers:${iteration % 5}`
53+
}
54+
}
55+
}
56+
}]
57+
}

tools/dataset/pkg/rds.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ func NewRDSComponent(ctx *pulumi.Context, name string, args *RDSComponentArgs, o
6262
MasterPassword: masterPassword.ApplyT(func(v string) string {
6363
return v
6464
}).(pulumi.StringOutput),
65-
ClusterIdentifier: pulumi.String(ctx.Project() + "-" + strings.Replace(ctx.Stack(), ".", "-", -1)),
65+
ClusterIdentifier: pulumi.Sprintf(
66+
"%s-%s-%s",
67+
ctx.Organization(),
68+
ctx.Project(),
69+
strings.Replace(ctx.Stack(), ".", "-", -1),
70+
),
6671
}, pulumi.Parent(cmp))
6772
if err != nil {
6873
return nil, fmt.Errorf("creating RDS cluster: %w", err)

0 commit comments

Comments
 (0)