Skip to content

Commit 69d0b89

Browse files
authored
Add actions for running e2e tests (#35)
* Add actions for running e2e tests * Move the whole e2e workflow to shared * Move docker-compose file to uid2-e2e repo * Add `uid2_e2e_phone_support` as inputs * Cat out config files * Use docker pull/push command directly instead of addnab/docker-run-action@v3 * Move script to a separate folder and rename it * Replace the default latest version with the provided version * Pass in operator type when doing docker compose * Remove `secrets.GHCR_PAT` * Add branch name as an input * Add step for checkingout UID2-operator * Set default image version for core and optout to be latest * Remove branch tags
1 parent 41e0349 commit 69d0b89

File tree

3 files changed

+231
-11
lines changed

3 files changed

+231
-11
lines changed
+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Run operator E2E tests
2+
on:
3+
workflow_call:
4+
inputs:
5+
core_root:
6+
description: 'The root path for uid2-core folder'
7+
type: string
8+
default: '../uid2-core'
9+
optout_root:
10+
description: 'The root path for uid2-optout folder'
11+
type: string
12+
default: '../uid2-optout'
13+
admin_root:
14+
description: 'The root path for uid2-admin folder'
15+
type: string
16+
default: '../uid2-admin'
17+
operator_root:
18+
description: 'The root path for uid2-operator folder'
19+
type: string
20+
default: '../uid2-operator'
21+
operator_image_version:
22+
description: 'The version of UID2 operator image'
23+
type: string
24+
default: 'latest'
25+
core_image_version:
26+
description: 'The version of UID2 core image'
27+
type: string
28+
default: 'latest'
29+
optout_image_version:
30+
description: 'The version of UID2 optout image'
31+
type: string
32+
default: 'latest'
33+
e2e_image_version:
34+
description: 'The version of E2E image'
35+
type: string
36+
default: 'latest'
37+
core_branch:
38+
description: 'The branch of UID2-core to test on'
39+
type: string
40+
default: 'main'
41+
optout_branch:
42+
description: 'The branch of UID2-optout to test on'
43+
type: string
44+
default: 'main'
45+
admin_branch:
46+
description: 'The branch of UID2-admin to test on'
47+
type: string
48+
default: 'main'
49+
operator_branch:
50+
description: 'The branch of UID2-operator to test on'
51+
type: string
52+
default: 'main'
53+
operator_type:
54+
description: 'The type of operator [either public or private]'
55+
type: string
56+
default: 'public'
57+
uid2_e2e_identity_scope:
58+
description: 'Environment variable to run the E2E test'
59+
required: false
60+
type: string
61+
default: 'UID2'
62+
uid2_e2e_pipeline_operator_type:
63+
description: 'Environment variable to run the E2E test'
64+
required: false
65+
type: string
66+
default: 'PUBLIC'
67+
uid2_e2e_pipeline_operator_url:
68+
description: 'Environment variable to run the E2E test'
69+
required: false
70+
type: string
71+
default: 'http://publicoperator:8080'
72+
uid2_e2e_pipeline_operator_cloud_provider:
73+
description: 'Environment variable to run the E2E test'
74+
required: false
75+
type: string
76+
default: 'PUBLIC'
77+
uid2_e2e_phone_support:
78+
description: 'Environment variable to run the E2E test'
79+
required: false
80+
type: string
81+
default: 'true'
82+
83+
env:
84+
REGISTRY: ghcr.io
85+
86+
jobs:
87+
e2e-test:
88+
name: E2E Test
89+
runs-on: ubuntu-latest
90+
permissions:
91+
contents: write
92+
packages: read
93+
id-token: write
94+
steps:
95+
- name: Log in to the Docker container registry
96+
uses: docker/login-action@v2
97+
with:
98+
registry: ${{ env.REGISTRY }}
99+
username: ${{ github.actor }}
100+
password: ${{ secrets.GHCR_PAT }}
101+
102+
- name: Checkout full history
103+
uses: actions/checkout@v3
104+
105+
- name: Checkout uid2-core repo
106+
uses: actions/checkout@v3
107+
with:
108+
ref: ${{ inputs.core_branch }}
109+
repository: IABTechLab/uid2-core
110+
path: uid2-core
111+
112+
- name: Checkout uid2-optout repo
113+
uses: actions/checkout@v3
114+
with:
115+
ref: ${{ inputs.optout_branch }}
116+
repository: IABTechLab/uid2-optout
117+
path: uid2-optout
118+
119+
- name: Checkout uid2-admin repo
120+
uses: actions/checkout@v3
121+
with:
122+
ref: ${{ inputs.admin_branch }}
123+
repository: IABTechLab/uid2-admin
124+
path: uid2-admin
125+
126+
- name: Checkout uid2-operator repo
127+
uses: actions/checkout@v3
128+
with:
129+
ref: ${{ inputs.operator_branch }}
130+
repository: IABTechLab/uid2-operator
131+
path: uid2-operator
132+
133+
- name: Checkout uid2-shared-actions repo
134+
uses: actions/checkout@v3
135+
with:
136+
repository: IABTechLab/uid2-shared-actions
137+
path: uid2-shared-actions
138+
139+
- name: Checkout uid2-e2e repo
140+
uses: actions/checkout@v3
141+
with:
142+
repository: IABTechLab/uid2-e2e
143+
path: uid2-e2e
144+
145+
- name: Bring up docker compose
146+
id: docker-compose
147+
env:
148+
CORE_ROOT: ${{ inputs.core_root }}
149+
OPTOUT_ROOT: ${{ inputs.optout_root }}
150+
ADMIN_ROOT: ${{ inputs.admin_root }}
151+
OPERATOR_ROOT: ${{ inputs.operator_root }}
152+
CORE_VERSION: ${{ inputs.core_image_version }}
153+
OPTOUT_VERSION: ${{ inputs.optout_image_version }}
154+
OPERATOR_VERSION: ${{ inputs.operator_image_version }}
155+
E2E_VERSION: ${{ inputs.e2e_image_version }}
156+
OPERATOR_TYPE: ${{ inputs.operator_type }}
157+
run: |
158+
cd e2e && bash ../uid2-shared-actions/scripts/prepare-resources-for-e2e-docker-compose.sh
159+
160+
- name: Run e2e tests
161+
id: e2e
162+
uses: IABTechLab/uid2-shared-actions/actions/run_e2e_tests@main
163+
with:
164+
e2e_image_version: ${{ inputs.e2e_image_version }}

actions/run_e2e_tests/action.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Shared E2E Test
2+
description: Pull uid2-e2e Docker image and run E2E test suite
3+
4+
inputs:
5+
e2e_image_version:
6+
description: 'The version of E2E image'
7+
required: false
8+
type: string
9+
default: 'latest'
10+
uid2_e2e_identity_scope:
11+
description: 'Environment variable to run the E2E test'
12+
required: false
13+
type: string
14+
default: 'UID2'
15+
uid2_e2e_pipeline_operator_type:
16+
description: 'Environment variable to run the E2E test'
17+
required: false
18+
type: string
19+
default: 'PUBLIC'
20+
uid2_e2e_pipeline_operator_url:
21+
description: 'Environment variable to run the E2E test'
22+
required: false
23+
type: string
24+
default: 'http://publicoperator:8080'
25+
uid2_e2e_pipeline_operator_cloud_provider:
26+
description: 'Environment variable to run the E2E test'
27+
required: false
28+
type: string
29+
default: 'PUBLIC'
30+
uid2_e2e_phone_support:
31+
description: 'Environment variable to run the E2E test'
32+
required: false
33+
type: string
34+
default: 'true'
35+
36+
runs:
37+
using: "composite"
38+
steps:
39+
- name: Run E2E tests
40+
shell: bash
41+
run: |
42+
docker pull ghcr.io/iabtechlab/uid2-e2e:${{ inputs.e2e_image_version }}
43+
docker images
44+
echo $UID2_E2E_PIPELINE_OPERATOR_TYPE
45+
docker run \
46+
--env UID2_E2E_ENV='github-test-pipeline' \
47+
--env UID2_E2E_API_KEY='UID2-C-L-999-fCXrMM.fsR3mDqAXELtWWMS+xG1s7RdgRTMqdOH2qaAo=' \
48+
--env UID2_E2E_API_KEY_OLD='UID2-C-L-1000-qxpBsF.ibeCDBpD2bq4Zm7inDacGioUk1aaLeNJrabow=' \
49+
--env UID2_E2E_API_SECRET='DzBzbjTJcYL0swDtFs2krRNu+g1Eokm2tBU4dEuD0Wk=' \
50+
--env UID2_E2E_API_SECRET_OLD='VT7+t0G/RVueMuVZAL56I2c3JJFSYQfhbu8yo0V/Tds=' \
51+
--env UID2_E2E_IDENTITY_SCOPE='${{ inputs.uid2_e2e_identity_scope }}' \
52+
--env UID2_E2E_PHONE_SUPPORT='${{ inputs.uid2_e2e_phone_support }}' \
53+
--env UID2_E2E_PIPELINE_OPERATOR_CLOUD_PROVIDER='${{ inputs.uid2_e2e_pipeline_operator_cloud_provider }}' \
54+
--env UID2_E2E_PIPELINE_OPERATOR_TYPE='${{ inputs.uid2_e2e_pipeline_operator_type }}' \
55+
--env UID2_E2E_PIPELINE_OPERATOR_URL='${{ inputs.uid2_e2e_pipeline_operator_url }}' \
56+
--env UID2_E2E_SITE_ID='999' \
57+
--network e2e_default \
58+
ghcr.io/iabtechlab/uid2-e2e:${{ inputs.e2e_image_version }}

docker-build-public.sh renamed to scripts/prepare-resources-for-e2e-docker-compose.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,16 @@ cp "$OPTOUT_ROOT/run_tool_local_e2e.sh" "$OPTOUT_CONFIG_FILE_DIR"
4141
cp -r "$OPTOUT_ROOT/src/main/resources/localstack" "$OPTOUT_RESOURCE_FILE_DIR"
4242
mkdir -p "$OPERATOR_CONFIG_FILE_DIR"
4343
cp "$OPERATOR_ROOT/conf/default-config.json" "$OPERATOR_CONFIG_FILE_DIR"
44-
cp "$OPERATOR_ROOT/conf/local-e2e-docker-$OPERATOR_TYPE-config.json" "$OPERATOR_CONFIG_FILE_DIR"
44+
cp "$OPERATOR_ROOT/conf/local-e2e-docker-$OPERATOR_TYPE-config.json" "$OPERATOR_CONFIG_FILE_DIR/local-e2e-docker-config.json"
45+
46+
cp "../uid2-e2e/docker-compose.yml" "$ROOT"
4547

4648
CORE_CONFIG_FILE="$ROOT/docker/uid2-core/conf/local-e2e-docker-config.json"
4749
OPTOUT_CONFIG_FILE="$ROOT/docker/uid2-optout/conf/local-e2e-docker-config.json"
4850
OPERATOR_CONFIG_FILE="$ROOT/docker/uid2-operator/conf/local-e2e-docker-config.json"
49-
COMPOSE_FILE="$ROOT/docker-compose.yml"
51+
DOCKER_COMPOSE_FILE="$ROOT/docker-compose.yml"
5052
OPTOUT_MOUNT="$ROOT/docker/uid2-optout/mount"
5153

52-
53-
source "$ROOT/jq_helper.sh"
54-
source "$ROOT/healthcheck.sh"
55-
5654
if [ -z "$CORE_VERSION" ]; then
5755
echo "CORE_VERSION can not be empty"
5856
exit 1
@@ -74,19 +72,19 @@ if [ -z "$E2E_VERSION" ]; then
7472
fi
7573

7674
# replace placeholders
77-
sed -i.bak "s#<CORE_VERSION>#$CORE_VERSION#g" $COMPOSE_FILE
78-
sed -i.bak "s#<OPTOUT_VERSION>#$OPTOUT_VERSION#g" $COMPOSE_FILE
79-
sed -i.bak "s#<OPERATOR_VERSION>#$OPERATOR_VERSION#g" $COMPOSE_FILE
80-
sed -i.bak "s#<E2E_VERSION>#$E2E_VERSION#g" $COMPOSE_FILE
75+
sed -i.bak "s#uid2-core:latest#uid2-core:$CORE_VERSION#g" $DOCKER_COMPOSE_FILE
76+
sed -i.bak "s#uid2-optout:latest#uid2-optout:$OPTOUT_VERSION#g" $DOCKER_COMPOSE_FILE
77+
sed -i.bak "s#uid2-operator:latest#uid2-operator:$OPERATOR_VERSION#g" $DOCKER_COMPOSE_FILE
8178

8279
cat $CORE_CONFIG_FILE
8380
cat $OPTOUT_CONFIG_FILE
8481
cat $OPERATOR_CONFIG_FILE
82+
cat $DOCKER_COMPOSE_FILE
8583

8684
mkdir -p "$OPTOUT_MOUNT" && chmod 777 "$OPTOUT_MOUNT"
8785
chmod 777 "$CORE_RESOURCE_FILE_DIR/init-aws.sh"
8886
chmod 777 "$OPTOUT_RESOURCE_FILE_DIR/init-aws.sh"
8987

90-
docker compose -f "$ROOT/e2e/docker-compose.yml" up -d
88+
docker compose --profile "$OPERATOR_TYPE" -f "$DOCKER_COMPOSE_FILE" up -d
9189
docker ps -a
9290
docker network ls

0 commit comments

Comments
 (0)