Skip to content

Commit

Permalink
Chore: Test stack - Add Sentry config
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed Jun 10, 2024
1 parent 87835b5 commit f647b17
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- test
- infra/test-chores

env:
ENVIRONMENT: "test"
Expand All @@ -21,7 +22,7 @@ jobs:
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
GTM_ID: ${{ secrets.GTM_ID }}
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_FRONTEND: ${{ secrets.INTERSECT_SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
Expand Down
10 changes: 5 additions & 5 deletions tests/load-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.gatling.govtool</groupId>
<artifactId>govtool-backend</artifactId>
<version>0.0.1</version>
<version>1.0.0</version>
<properties>
<!-- use the following if you're compiling with JDK 8-->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- comment the 2 lines above and uncomment the line bellow if you're compiling with JDK 11 or 17 -->
<!-- <maven.compiler.release>11</maven.compiler.release>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling.version>3.9.5</gatling.version>
<gatling.version>3.11.3</gatling.version>
<gatling-maven-plugin.version>4.5.0</gatling-maven-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
Expand All @@ -28,17 +28,17 @@
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-app</artifactId>
<version>3.9.5</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-core</artifactId>
<version>3.9.5</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-recorder</artifactId>
<version>3.9.5</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
Expand Down
3 changes: 3 additions & 0 deletions tests/test-infrastructure/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
PROJECT_NAME=govtool
NPMRC_TOKEN=
SENTRY_DSN_FRONTEND=
SENTRY_DSN_BACKEND=
CARDANO_NETWORK=sanchonet
BASE_DOMAIN=govtool.cardanoapi.io
GOVTOOL_TAG=test
2 changes: 1 addition & 1 deletion tests/test-infrastructure/build-images.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/e bash
set -e
export BASE_IMAGE_NAME="govtool"
BASE_IMAGE_EXISTS=$(docker images -q "$BASE_IMAGE_NAME"/backend-base)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"port" : 8080,
"host" : "0.0.0.0",
"cachedurationseconds": 20,
"sentrydsn": "https://username:[email protected]/id",
"metadatavalidationhost": "http://metadata-validation",
"sentrydsn": "${SENTRY_DSN_BACKEND:-https://username:[email protected]/id}",
"metadatavalidationhost": "${METADATA_VALIDATION_URL:-http://metadata-validation}",
"metadatavalidationport": 3000
}
3 changes: 3 additions & 0 deletions tests/test-infrastructure/docker-compose-govtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
context: ../../govtool/frontend
args:
VITE_BASE_URL: "/api"
VITE_SENTRY_DSN: ${SENTRY_DSN_FRONTEND}
NPMRC_TOKEN: ${NPMRC_TOKEN}
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: "true"
environment:
VIRTUAL_HOST: https://${BASE_DOMAIN}
networks:
Expand Down
4 changes: 2 additions & 2 deletions tests/test-infrastructure/gen-configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ generate_secret "POSTGRES_PASSWORD" "./secrets/postgres_password"
for CONFIG_FILE in $(ls ./configs_template)
do
echo -n "Config ${PROJECT_NAME}_${CONFIG_FILE}: "
envsubst < "./configs_template/$CONFIG_FILE" > "./configs/${CONFIG_FILE}"
./scripts/envsubst.py < "./configs_template/$CONFIG_FILE" > "./configs/${CONFIG_FILE}"
done

for SECRET_FILE in $(ls ./secrets_template)
do
echo -n "Secret ${PROJECT_NAME}_${SECRET_FILE}: "
envsubst < "./secrets_template/$SECRET_FILE" > "./secrets/${SECRET_FILE}"
./scripts/envsubst.py < "./secrets_template/$SECRET_FILE" > "./secrets/${SECRET_FILE}"
done

################################################################################
Expand Down
2 changes: 2 additions & 0 deletions tests/test-infrastructure/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
chdir: "/opt/govtool/tests/test-infrastructure"
environment:
GOVTOOL_TAG: "{{ lookup('env', 'GOVTOOL_TAG') }}"
NPMRC_TOKEN: "{{ lookup('env','NPMRC_TOKEN'}}"
SENTRY_DSN_FRONTEND: "{{ lookup ('env', 'SENTRY_DSN_FRONTEND'}} "
become: yes
2 changes: 1 addition & 1 deletion tests/test-infrastructure/scripts/deploy-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ function deploy-stack(){
EXTENSION="${FILENAME##*.}"
FILENAME_WITHOUT_EXT="${FILENAME%.*}"
RENDERED_FILENAME="${FILENAME_WITHOUT_EXT}-rendered.${EXTENSION}"
envsubst < "$COMPOSE_FILE" > "$RENDERED_FILENAME"
./scripts/envsubst.py < "$COMPOSE_FILE" > "$RENDERED_FILENAME"
docker stack deploy -c "$RENDERED_FILENAME" ${STACK_NAME}
}
34 changes: 34 additions & 0 deletions tests/test-infrastructure/scripts/envsubst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/python3
import os
import re
import sys

def envsubst(template_str, env=os.environ):
"""Substitute environment variables in the template string, supporting default values."""
pattern = re.compile(r'\$\{([^}:\s]+)(?::-(.*?))?\}')

def replace(match):
var = match.group(1)
default_value = match.group(2) if match.group(2) is not None else ''
return env.get(var, default_value)

return pattern.sub(replace, template_str)

def main():
if len(sys.argv) > 2:
print("Usage: python envsubst.py [template_file]")
sys.exit(1)

if len(sys.argv) == 2:
template_file = sys.argv[1]
with open(template_file, 'r') as file:
template_str = file.read()
else:
template_str = sys.stdin.read()

result = envsubst(template_str)

print(result)

if __name__ == "__main__":
main()

0 comments on commit f647b17

Please sign in to comment.