-
Notifications
You must be signed in to change notification settings - Fork 126
feat: add DST setup #879
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
base: main
Are you sure you want to change the base?
feat: add DST setup #879
Changes from 52 commits
f66f8e2
df41f3d
eead415
3b91230
24c347a
0addc57
dc15569
d64d1ef
32759cc
a380c0b
b22e498
0919823
8aa8fb7
6d3747a
256bfb9
10acc49
a2351d6
58524d7
4ed1eb5
8aaa393
3ec2e4c
9f22e06
aa9fa2b
e8b6e82
9fc1cf7
e52be33
40c1a39
c8ab708
f8fa1ba
979b33a
49b0414
9248bd8
424b4c1
d4f161b
c5dac59
7664eb6
0966637
c152718
0f879a9
c3cb880
9db3f81
fddeb96
fa66ba7
62309de
1ee5795
65042d5
af6956b
59ddcbf
3242e71
3c8a68b
d2d57b7
0484df1
a5e3d61
6b8fd2e
f51e01f
47401f6
c40afec
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,91 @@ | ||
name: Antithesis Integration | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
run_tests: | ||
description: "Run Antithesis tests after pushing images" | ||
type: boolean | ||
default: true | ||
# push: | ||
# branches: | ||
# - main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- "test/antithesis/**" | ||
schedule: | ||
- cron: "0 10 * * *" | ||
|
||
jobs: | ||
push-antithesis-images: | ||
name: Push Images to Antithesis | ||
runs-on: shipfox-4vcpu-ubuntu-2404 | ||
env: | ||
ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} | ||
ANTITHESIS_SLACK_REPORT_RECIPIENT: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} | ||
ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REPOSITORY }} | ||
OPERATOR_TAG: "v2.10.1" | ||
OPERATOR_UTILS_TAG: "v2.0.14" | ||
GATEWAY_TAG: "v2.0.24" | ||
# LEDGER_PREVIOUS_TAG: "v2.2.47" | ||
# temporary: remove this when support for multiple image versions is added | ||
LEDGER_PREVIOUS_TAG: "v2.3.0" | ||
LEDGER_LATEST_TAG: "v2.3.0" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Earthly | ||
uses: earthly/actions-setup@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: "latest" | ||
|
||
- name: Setup Just | ||
uses: extractions/setup-just@v3 | ||
with: | ||
just-version: "1.40.0" | ||
|
||
- name: Setup Environment | ||
uses: ./.github/actions/default | ||
with: | ||
token: ${{ secrets.NUMARY_GITHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: "NumaryBot" | ||
password: ${{ secrets.NUMARY_GITHUB_TOKEN }} | ||
|
||
- name: Login to Antithesis Docker Registry | ||
run: | | ||
echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin | ||
|
||
- name: Build and Push Config Image | ||
run: | | ||
cd test/antithesis | ||
just requirements-build | ||
|
||
- name: Run Antithesis Tests | ||
# if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} | ||
uses: antithesishq/antithesis-trigger-action@v0.8 | ||
with: | ||
notebook_name: formance-k8s | ||
tenant: formance | ||
username: ${{ secrets.ANTITHESIS_USERNAME }} | ||
password: ${{ secrets.ANTITHESIS_PASSWORD }} | ||
github_token: ${{ secrets.NUMARY_GITHUB_TOKEN }} | ||
# images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" | ||
# temporary: remove this when support for multiple image versions is added | ||
images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" | ||
config_image: "antithesis-config:k8s_test" | ||
email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Antithesis Integration | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
push-antithesis-images: | ||
name: Push Images to Antithesis | ||
runs-on: shipfox-4vcpu-ubuntu-2404 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Earthly | ||
uses: earthly/actions-setup@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: "latest" | ||
|
||
- name: Setup Just | ||
uses: extractions/setup-just@v3 | ||
with: | ||
just-version: "1.40.0" | ||
|
||
- name: Setup Environment | ||
uses: ./.github/actions/default | ||
with: | ||
token: ${{ secrets.NUMARY_GITHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: "NumaryBot" | ||
password: ${{ secrets.NUMARY_GITHUB_TOKEN }} | ||
|
||
- name: Login to Antithesis Docker Registry | ||
run: | | ||
echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin | ||
|
||
- name: Build and Push Config Image | ||
run: | | ||
cd test/antithesis/image | ||
earthly --push ./image+build --ANTITHESIS_REPOSITORY="${{ secrets.ANTITHESIS_REPOSITORY }}" --LEDGER_LATEST_TAG="${{ env.GITHUB_REF_NAME }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
VERSION 0.7 | ||
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. Stop using Earthfile, there is no Earthfile anymore in the repsoitory ;) |
||
|
||
FROM --platform=linux/amd64 golang:1.22.2 | ||
|
||
client: | ||
FROM scratch | ||
COPY . /client | ||
SAVE ARTIFACT /client client |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run-6min: requirements-build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
curl --fail \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
--user "formance:$ANTITHESIS_PASSWORD" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"params": { \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"custom.duration": "0.1", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.config_image": "antithesis-config:k8s_test", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+2
to
+11
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 Stop leaking credentials; switch to netrc, add JSON header, and harden curl. Passing Apply this diff: - curl --fail \
- --user "formance:$ANTITHESIS_PASSWORD" \
- -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \
+ # Preconditions & secure auth (avoid exposing secrets in process list)
+ : "${ANTITHESIS_PASSWORD:?ANTITHESIS_PASSWORD is required}"
+ : "${ANTITHESIS_SLACK_REPORT_RECIPIENT:?ANTITHESIS_SLACK_REPORT_RECIPIENT is required}"
+ tmp_netrc="$(mktemp)"; trap 'rm -f "$tmp_netrc"' EXIT
+ printf 'machine formance.antithesis.com login formance password %s\n' "$ANTITHESIS_PASSWORD" > "$tmp_netrc"
+ chmod 600 "$tmp_netrc"
+ curl --fail --silent --show-error --retry 3 --retry-all-errors \
+ --netrc-file "$tmp_netrc" \
+ -H 'Content-Type: application/json' \
+ -X POST 'https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s' -d '{ \ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run-1h: requirements-build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
curl --fail \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
--user "formance:$ANTITHESIS_PASSWORD" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"params": { \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"custom.duration": "1", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.config_image": "antithesis-config:k8s_test", \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+14
to
+23
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 Mirror the security and resiliency fixes in run-1h. Apply the same netrc, JSON header, and curl hardening here. - curl --fail \
- --user "formance:$ANTITHESIS_PASSWORD" \
- -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \
+ : "${ANTITHESIS_PASSWORD:?ANTITHESIS_PASSWORD is required}"
+ : "${ANTITHESIS_SLACK_REPORT_RECIPIENT:?ANTITHESIS_SLACK_REPORT_RECIPIENT is required}"
+ tmp_netrc="$(mktemp)"; trap 'rm -f "$tmp_netrc"' EXIT
+ printf 'machine formance.antithesis.com login formance password %s\n' "$ANTITHESIS_PASSWORD" > "$tmp_netrc"
+ chmod 600 "$tmp_netrc"
+ curl --fail --silent --show-error --retry 3 --retry-all-errors \
+ --netrc-file "$tmp_netrc" \
+ -H 'Content-Type: application/json' \
+ -X POST 'https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s' -d '{ \ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
requirements-build: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
just config/push | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" --LEDGER_LATEST_TAG="$LEDGER_LATEST_TAG" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tmp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM scratch | ||
COPY tmp/* /manifests/ |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
build-manifest: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rm -f -- tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mkdir -p tmp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cat manifests/namespace.yaml >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "---" >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cat manifests/postgres.yaml >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "---" >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
helm template regions oci://ghcr.io/formancehq/helm/regions --version 2.15.2 --namespace formance-systems >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# helm template operator oci://ghcr.io/formancehq/helm/operator-crds --version v2.8.0 --namespace formance-systems >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "---" >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cat manifests/stack.yaml >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "---" >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yq '.spec.version = strenv(LEDGER_PREVIOUS_TAG)' manifests/ledger.yaml >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "---" >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cat manifests/workload.yaml >> tmp/resources.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+16
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 Harden recipes: fail fast and guard required env. Add strict shell flags and verify LEDGER_PREVIOUS_TAG is set before templating. build-manifest:
- rm -f -- tmp/resources.yaml
+ set -euo pipefail
+ : "${LEDGER_PREVIOUS_TAG:?LEDGER_PREVIOUS_TAG is required}"
+ rm -f -- tmp/resources.yaml
mkdir -p tmp
cat manifests/namespace.yaml >> tmp/resources.yaml
echo "---" >> tmp/resources.yaml
cat manifests/postgres.yaml >> tmp/resources.yaml
echo "---" >> tmp/resources.yaml
helm template regions oci://ghcr.io/formancehq/helm/regions --version 2.15.2 --namespace formance-systems >> tmp/resources.yaml
# helm template operator oci://ghcr.io/formancehq/helm/operator-crds --version v2.8.0 --namespace formance-systems >> tmp/resources.yaml
echo "---" >> tmp/resources.yaml
cat manifests/stack.yaml >> tmp/resources.yaml
echo "---" >> tmp/resources.yaml
yq '.spec.version = strenv(LEDGER_PREVIOUS_TAG)' manifests/ledger.yaml >> tmp/resources.yaml
echo "---" >> tmp/resources.yaml
cat manifests/workload.yaml >> tmp/resources.yaml 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
push: build-manifest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
docker build -f Dockerfile.config -t $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
docker push $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: formance.com/v1beta1 | ||
kind: Ledger | ||
metadata: | ||
name: stack0-ledger | ||
spec: | ||
stack: stack0 | ||
version: LEDGER_VERSION_PLACEHOLDER |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: formance-systems |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres | ||
namespace: formance-systems | ||
spec: | ||
selector: | ||
app: postgres | ||
ports: | ||
- protocol: TCP | ||
port: 5432 | ||
targetPort: 5432 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: postgres | ||
namespace: formance-systems | ||
labels: | ||
app: postgres | ||
spec: | ||
containers: | ||
- name: postgres | ||
image: postgres:15-alpine | ||
imagePullPolicy: IfNotPresent | ||
args: ["-c", "max_connections=100"] | ||
env: | ||
- name: "POSTGRES_USER" | ||
value: "ledger" | ||
- name: "POSTGRES_PASSWORD" | ||
value: "ledger" | ||
- name: "POSTGRES_DB" | ||
value: "ledger" | ||
- name: "PGDATA" | ||
value: /data/postgres | ||
livenessProbe: | ||
exec: | ||
command: ["pg_isready", "-Uledger"] | ||
initialDelaySeconds: 0 | ||
periodSeconds: 10 | ||
timeoutSeconds: 5 | ||
failureThreshold: 5 |
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.
I know comments are useful, but this kind of comment just rephrase the code ^^