Skip to content

Commit bd12ae0

Browse files
committed
Merge branch 'master' into feature/#42-remove-values-local-env.yaml
# Conflicts: # .github/workflows/prod-docker-publish.yml # Api/ci/values-local-env.yaml
2 parents 2f6aa2c + d44783c commit bd12ae0

58 files changed

Lines changed: 1715 additions & 1149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3+
{
4+
"name": "Existing Dockerfile",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../e2e/KarateDockerfile"
10+
},
11+
"features": {
12+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1.6.0": {}
13+
},
14+
"runArgs": [
15+
"--network=host"
16+
],
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"karatelabs.karate",
21+
"bierner.markdown-mermaid"
22+
]
23+
}
24+
},
25+
"containerEnv": {
26+
"API_ROOT_URL": "http://localhost:6503/api",
27+
}
28+
}

.editorconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1+
# command to run:
2+
# dotnet format --exclude "**/Migrations/**" --verbosity detailed
3+
14
[*.cs]
25

36
#### Core EditorConfig Options ####
47
charset = utf-8
58

69
# Indentation and spacing
7-
indent_size = 4
10+
indent_size = 2
811
indent_style = space
9-
tab_width = 4
12+
tab_width = 2
1013

1114
# New line preferences
1215
end_of_line = lf
13-
insert_final_newline = false
16+
insert_final_newline = true
17+
18+
# Wrapping preferences
19+
csharp_preserve_single_line_blocks = true
20+
csharp_preserve_single_line_statements = true
1421

22+
# error unnecessary usings
23+
dotnet_diagnostic.IDE0005.severity = error
1524

1625
#### .NET Coding Conventions ####
1726

@@ -199,4 +208,4 @@ dotnet_diagnostic.SA1131.severity = none
199208
dotnet_diagnostic.SA1118.severity = none
200209

201210
# SA1500: Braces for multi-line statements should not share line
202-
dotnet_diagnostic.SA1500.severity = none
211+
dotnet_diagnostic.SA1500.severity = none
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Template to describe a bug
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Environment**
21+
- Device (desktop / mobile)
22+
- OS: [e.g. iOS]
23+
- Browser [e.g. chrome, safari]
24+
- Version [e.g. 22]
25+
26+
**Additional context**
27+
Add any other context about the problem here.
28+
29+
**Screenshots / Video**
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Task template
3+
about: Template to describe a task
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**I as** a <role>
11+
**Want to** <goal>
12+
**So that** <value / expected outcome>
13+
14+
**Description**
15+
For example:
16+
- Component's fields or design elements (if applicable)
17+
- Behavior of interactive elements (if applicable)
18+
19+
**Definition of Done**
20+
For example:
21+
1. Unit or e2e tests are successful in pipeline (if applicable).
22+
2. <Role> can <do something>. E.g., a user can open and close mobile menu.
23+
24+
**Additional Info**
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- feature/*
8+
# to allow to wait for a docker image to be published to proceed in another workflow
9+
workflow_call:
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to Git Registry
14+
runs-on: ubuntu-22.04
15+
permissions:
16+
packages: write
17+
contents: read
18+
attestations: write
19+
steps:
20+
- name: Check out the repo
21+
uses: actions/checkout@v4
22+
# multi-platform build configured using this https://docs.docker.com/build/ci/github-actions/multi-platform/
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
- name: Log in to GitHub Container Registry
28+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
37+
with:
38+
images: ghcr.io/tourmalinecore/${{ github.event.repository.name }}
39+
tags: |
40+
# minimal (short sha)
41+
type=sha
42+
# full length sha
43+
type=sha,format=long
44+
# set latest tag for default branch
45+
# https://github.com/docker/metadata-action/issues/171 explains how to tag latest only on default branch
46+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
47+
48+
- name: Build and push Docker image
49+
id: push
50+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
51+
with:
52+
context: .
53+
file: ./Api/Dockerfile
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
platforms: linux/amd64,linux/arm64
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- feature/*
7+
8+
jobs:
9+
# this is needed to wait for the new docker image to be build and published to the registry
10+
# so that we can use the image to run ui of the needed commit related version as part of local-env
11+
# the idea is taken from here https://stackoverflow.com/a/71489231
12+
push_to_registry:
13+
uses: ./.github/workflows/docker-build-and-push.yml
14+
# without this it cannot login to the registry
15+
secrets: inherit
16+
17+
e2e-test-without-local-env:
18+
runs-on: ubuntu-24.04
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Run service via docker-compose and run Karate-tests
22+
# Hide credentials and token from logs, get the number of failed and passed tests
23+
# Find text with 'failed' and 'passed' in logs from karate-testing container
24+
run: |
25+
LOGS=$(docker compose --profile MockForPullRequest up --abort-on-container-exit)
26+
FILTERED_LOGS=$(echo "$LOGS" | sed -E 's/"login":"[^"]*"/"login":"****"/g' \
27+
| sed -E 's/"password":"[^"]*"/"password":"****"/g' \
28+
| sed -E 's/"accessToken":[^,}]*"[^"]*"/"accessToken":"****"/g' \
29+
| sed -E 's/"Authorization":"[^"]*"/"Authorization":"****"/g' \
30+
| sed -E 's/"X-DEBUG-TOKEN":[^,}]*"[^"]*"/"X-DEBUG-TOKEN":"****"/g' \
31+
| sed -E 's/accessToken":\{[^}]*\}/accessToken":{"value":"****"}/g' \
32+
| sed -E 's/X-DEBUG-TOKEN: [^ ]*/X-DEBUG-TOKEN: ****/g')
33+
echo "$FILTERED_LOGS"
34+
FAILED=$(echo "$FILTERED_LOGS" | grep -oP 'failed: *\K\d+')
35+
PASSED=$(echo "$FILTERED_LOGS" | grep -oP 'passed: *\K\d+')
36+
echo "Failed tests: $FAILED"
37+
echo "Passed tests: $PASSED"
38+
if [ "$FAILED" -gt 0 ]; then
39+
echo "Failed tests found! Failing the pipeline..."
40+
exit 1
41+
fi
42+
if [ "$PASSED" -eq 0 ]; then
43+
echo "No tests passed! Failing the pipeline..."
44+
exit 1
45+
fi
46+
env:
47+
TEST_AUTH_LOGIN: ${{ secrets.TEST_AUTH_LOGIN }}
48+
TEST_AUTH_PASSWORD: ${{ secrets.TEST_AUTH_PASSWORD }}
49+
50+
e2e-test-with-local-env:
51+
name: Run karate tests in local env
52+
runs-on: ubuntu-22.04
53+
needs: [push_to_registry]
54+
steps:
55+
- name: Checkout local-env
56+
uses: actions/checkout@v4
57+
with:
58+
repository: TourmalineCore/inner-circle-local-env
59+
60+
- name: Deploy Local Env to Kind k8s
61+
uses: devcontainers/ci@v0.3
62+
with:
63+
runCmd: |
64+
# we need to override "latest" image tag of ui inside local-env to run e2e against the current commit ui version and not against latest from master
65+
# We tried to use yq to change the image tag, but in the values files for helmfile we have non-yaml code that yq can`t parse or ignore
66+
# so for that reason we use Stream EDitor which can find needed string using regular expressions and change it to a new value
67+
# The -i flag is needed to write new image tag directly to values file
68+
sed -i "0,/tag:.*/s//tag: \"sha-${{ github.sha }}\"/" deploy/values-auth-api.yaml.gotmpl
69+
70+
# we need to override "latest" ref of service chart inside local-env to run tests against the current commit service chart version and not against latest from master
71+
sed -i "0,/git+https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git?ref=.*/s//git+https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git?ref=${{ github.sha }}/" deploy/helmfile.yaml
72+
73+
sed -i "0,/git::https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git@\/Api\/ci\/values-local-env.yaml?ref=.*/s//git::https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git@\/Api\/ci\/values-local-env.yaml?ref=${{ github.sha }}/" deploy/helmfile.yaml
74+
75+
kind create cluster --name inner-circle --config kind-local-config.yaml --kubeconfig ./.inner-circle-cluster-kubeconfig
76+
# we need to properly expose KUBECONFIG as an absolute path, pwd prints current working directory path
77+
export KUBECONFIG=$(pwd)/.inner-circle-cluster-kubeconfig
78+
79+
helmfile --environment local --namespace local -f deploy/helmfile.yaml apply
80+
push: never
81+
82+
- name: Checkout api
83+
uses: actions/checkout@v4
84+
85+
- name: Set up JDK 17
86+
uses: actions/setup-java@v3
87+
with:
88+
java-version: '17'
89+
distribution: 'temurin'
90+
91+
- name: Download Karate JAR
92+
run: |
93+
curl -L https://github.com/karatelabs/karate/releases/download/v1.5.1/karate-1.5.1.jar -o karate.jar
94+
95+
- name: Run Karate Tests
96+
run: |
97+
java -jar karate.jar .
98+
env:
99+
API_ROOT_URL: "http://localhost:30090/api"
100+
AUTH_LOGIN: "ceo@tourmalinecore.com"
101+
AUTH_PASSWORD: "cEoPa$$wo1d"
Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,48 @@
1-
name: deploy service to prod k8s
1+
name: Deploy to Prod
22

33
on:
44
push:
55
branches:
66
- master
7-
pull_request:
8-
9-
env:
10-
GITHUB_REGISTRY: ghcr.io
117

128
jobs:
9+
# this is needed to wait for the new docker image to be build and published to the registry
10+
# so that we can use the image to run ui of the needed commit related version as part of local-env
11+
# the idea is taken from here https://stackoverflow.com/a/71489231
12+
push_to_registry:
13+
uses: ./.github/workflows/docker-build-and-push.yml
14+
# without this it cannot login to the registry
15+
secrets: inherit
1316

14-
build-image:
15-
name: Build and push service image
17+
deploy-to-prod:
18+
name: Deploy service to k8s for prod environment
19+
needs: [push_to_registry]
1620
runs-on: ubuntu-22.04
1721
steps:
18-
- name: checkout
19-
uses: actions/checkout@v1
20-
- name: Build and push image
22+
- name: Check out the repo
23+
uses: actions/checkout@v4
24+
25+
- name: Create default global .kube/config file
2126
run: |
22-
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
23-
docker build -t $GITHUB_REGISTRY/tourmalinecore/inner-circle/auth-api:latest -t $GITHUB_REGISTRY/tourmalinecore/inner-circle/auth-api:${{ github.sha }} -f Api/Dockerfile .
24-
docker push $GITHUB_REGISTRY/tourmalinecore/inner-circle/auth-api:latest
25-
docker push $GITHUB_REGISTRY/tourmalinecore/inner-circle/auth-api:${{ github.sha }}
27+
cd $HOME
28+
mkdir .kube
29+
echo "${{ secrets.DEV_KUBECONFIG }}" > .kube/config
2630
27-
deploy-to-prod-k8s:
28-
needs: build-image
29-
name: Deploy service to k8s for prod environment
30-
if: github.event_name == 'push'
31-
runs-on: ubuntu-22.04
32-
steps:
33-
- name: checkout
34-
uses: actions/checkout@v1
3531
- name: Deploy
36-
uses: WyriHaximus/github-action-helm3@v3
32+
uses: helmfile/helmfile-action@v1.9.0
3733
with:
38-
exec: |
39-
RELEASE_NAME=auth-api
40-
helm repo add bitnami https://charts.bitnami.com/bitnami
41-
helm upgrade --install --namespace dev-inner-circle --create-namespace --values ./Api/ci/values.yaml \
42-
--set "image.tag=${{ github.sha }}" \
43-
--set "ingress.enabled=true" \
44-
--set "ingress.hostname=${{ secrets.DEV_HOST }}" \
45-
--set "extraSecretEnvVars.ConnectionStrings__DefaultConnection=${{ secrets.DEV_POSTGRESQL_CONNECTION_STRING }}" \
46-
--set "extraSecretEnvVars.AuthenticationOptions__PublicSigningKey=${{ secrets.DEV_AUTH_PUBLIC_SIGNING_KEY }}" \
47-
--set "extraSecretEnvVars.AuthenticationOptions__PrivateSigningKey=${{ secrets.DEV_AUTH_PRIVATE_SIGNING_KEY }}" \
48-
--set "extraSecretEnvVars.InnerCircleServiceUrls__MailServiceUrl=${{ secrets.DEV_MAIL_SERVICE_URL }}" \
49-
--set "extraSecretEnvVars.InnerCircleServiceUrls__AuthUIServiceUrl=${{ secrets.DEV_AUTH_UI_SERVICE_URL }}" \
50-
--set "extraSecretEnvVars.InnerCircleServiceUrls__AccountsServiceUrl=${{ secrets.DEV_ACCOUNTS_SERVICE_URL }}" \
51-
--set "extraSecretEnvVars.InnerCircleServiceUrls__EmployeesServiceUrl=${{ secrets.DEV_EMPLOYEES_SERVICE_URL }}" \
52-
"${RELEASE_NAME}" \
53-
bitnami/aspnet-core --version 4.4.7
54-
kubeconfig: "${{ secrets.DEV_KUBECONFIG }}"
34+
helmfile-version: 'v0.164.0'
35+
helm-version: 'v3.18.0'
36+
helmfile-args: >
37+
apply --namespace dev-inner-circle -f Api/ci/helmfile.yaml
38+
--state-values-set image.tag=sha-${{ github.sha }}
39+
--state-values-set ingress.enabled=true
40+
--state-values-set ingress.hostname=${{ secrets.DEV_HOST }}
41+
--state-values-set extraSecretEnvVars.ConnectionStrings__DefaultConnection=${{ secrets.DEV_POSTGRESQL_CONNECTION_STRING }}
42+
--state-values-set extraSecretEnvVars.AuthenticationOptions__PublicSigningKey=${{ secrets.DEV_AUTH_PUBLIC_SIGNING_KEY }}
43+
--state-values-set extraSecretEnvVars.AuthenticationOptions__PrivateSigningKey=${{ secrets.DEV_AUTH_PRIVATE_SIGNING_KEY }}
44+
--state-values-set extraSecretEnvVars.InnerCircleServiceUrls__MailServiceUrl=${{ secrets.DEV_MAIL_SERVICE_URL }}
45+
--state-values-set extraSecretEnvVars.InnerCircleServiceUrls__AuthUIServiceUrl=${{ secrets.DEV_AUTH_UI_SERVICE_URL }}
46+
--state-values-set extraSecretEnvVars.InnerCircleServiceUrls__AccountsServiceUrl=${{ secrets.DEV_ACCOUNTS_SERVICE_URL }}
47+
--state-values-set extraSecretEnvVars.InnerCircleServiceUrls__EmployeesServiceUrl=${{ secrets.DEV_EMPLOYEES_SERVICE_URL }}
48+
helmfile-auto-init: "false"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj/
77
.vs
88
*.sln.DotSettings.user
99
*.csproj.user
10+
target
1011

1112
# storage for pgadmin
1213
*/pgadmin/sessions/

0 commit comments

Comments
 (0)