-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (71 loc) · 4.01 KB
/
e2e-tests-on-pull-request.yml
File metadata and controls
86 lines (71 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: E2E Tests in PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
# this is needed to wait for the new docker image to be build and published to the registry
# so that we can use the image to run the service of the needed commit related version as part of local-env
# the idea is taken from here https://stackoverflow.com/a/71489231
docker-build-and-push:
uses: ./.github/workflows/.reusable-docker-build-and-push.yml
e2e-test-against-local-env:
runs-on: ubuntu-24.04
needs: [docker-build-and-push]
steps:
- name: Checkout local-env
uses: actions/checkout@v4
with:
repository: TourmalineCore/to-dos-local-env
ref: feature/add-to-dos-api-cpp-release
- name: Deploy Local Env to Kind k8s
uses: devcontainers/ci@v0.3
with:
runCmd: |
# we need to override "latest" image tag of ui inside local-env to run e2e against the current commit api version and not against latest from master
# 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
# so for that reason we use Stream EDitor which can find needed string using regular expressions and change it to a new value
# The -i flag is needed to write new image tag directly to values file
sed -i "0,/tag:.*/s//tag: \"sha-${{ github.event.pull_request.head.sha }}\"/" deploy/values-to-dos-api-cpp.yaml.gotmpl
# 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
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.event.pull_request.head.sha }}/" deploy/helmfile.yaml.gotmpl
sed -i "0,/git::https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git@\/ci\/values.yaml?ref=.*/s//git::https:\/\/github.com\/TourmalineCore\/${{ github.event.repository.name }}.git@\/ci\/values.yaml?ref=${{ github.event.pull_request.head.sha }}/" deploy/helmfile.yaml.gotmpl
kind create cluster --name to-dos --config kind-local-config.yaml --kubeconfig ./.to-dos-cluster-kubeconfig
# we need to properly expose KUBECONFIG as an absolute path, pwd prints current working directory path
export KUBECONFIG=$(pwd)/.to-dos-cluster-kubeconfig
make apply-releases-with-cpp-api
push: never
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Download Karate JAR
run: |
curl -L https://github.com/karatelabs/karate/releases/download/v1.5.1/karate-1.5.1.jar -o karate.jar
- name: Run E2E Tests Against Local Env
run: |
java -jar karate.jar .
env:
"API_ROOT_URL": "http://localhost:30080/api/to-dos-api"
e2e-karate-tests-in-docker-compose:
runs-on: ubuntu-24.04
steps:
- name: Checkout to repo
uses: actions/checkout@v4
# If you don't create a .env file, the services in Docker Compose
# won't be able to start because they use this file.
- name: Create .env file
run: |
echo "API_HOST=0.0.0.0" >> .env
echo "API_PORT=80" >> .env
echo "API_LOG_LEVEL=INFO" >> .env
echo "API_NUMBER_OF_THREADS=1" >> .env
echo "POSTGRES_HOST=to-dos-api-cpp-db" >> .env
echo "POSTGRES_PORT=5432" >> .env
echo "POSTGRES_DB=to-dos-api-cpp-db" >> .env
echo "POSTGRES_USER=postgres" >> .env
echo "POSTGRES_PASSWORD=password" >> .env
- name: Run service via docker-compose and run Karate-tests
run: docker compose --profile MockForPullRequest up --exit-code-from to-dos-api-cpp-karate-tests