Skip to content

Commit 31f9d54

Browse files
EliMoshkovichdanyi1212
authored andcommitted
Added PDP Tester to CI/CD
Reimplementation of #232
1 parent 9c2bf53 commit 31f9d54

File tree

4 files changed

+126
-155
lines changed

4 files changed

+126
-155
lines changed

.github/workflows/dockerhub_push.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/pdp_tests.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,9 @@ permissions:
1010

1111
jobs:
1212
pdp-tests:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
18-
- name: Set up QEMU
19-
uses: docker/setup-qemu-action@v3
20-
21-
- name: Set up Docker Buildx
22-
uses: docker/setup-buildx-action@v3
23-
24-
- uses: actions/checkout@v3
25-
with:
26-
repository: permitio/permit-opa
27-
ref: main
28-
path: './permit-opa'
29-
token: ${{ secrets.CLONE_REPO_TOKEN }}
30-
31-
- name: Pre build PDP tests
32-
run: |
33-
echo "${{ github.event.release.tag_name }}" | cut -d '-' -f 1 > permit_pdp_version
34-
rm -rf custom
35-
mkdir custom
36-
build_root="$PWD"
37-
cd ./permit-opa
38-
find * \( -name '*go*' -o -name 'LICENSE.md' \) -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*'
39-
40-
- name: Build and load image for PDP E2E tests
41-
uses: docker/build-push-action@v5
42-
with:
43-
push: false
44-
load: true
45-
context: .
46-
platforms: linux/amd64
47-
tags: permitio/pdp-v2:test
48-
cache-from: type=gha
49-
cache-to: type=gha,mode=max
50-
51-
- uses: actions/checkout@v3
52-
with:
53-
repository: permitio/permit-backend
54-
ref: main
55-
path: './permit-backend'
56-
token: ${{ secrets.CLONE_REPO_TOKEN }}
57-
58-
- name: Python setup
59-
uses: actions/setup-python@v5
60-
with:
61-
python-version: '3.11.8'
62-
63-
- name: Run Pytests
64-
run: |
65-
python -m pip install --upgrade pip
66-
pip install ".[dev]"
67-
pytest -s --cache-clear horizon/tests/
68-
69-
- name: Run E2E tests
70-
working-directory: ./permit-backend/proactive_tests/sidecar
71-
run: |
72-
pip install requests pydantic==1.8.2 docker
73-
python sidecar_tester.py -k ${{ secrets.PERMIT_TESTS_TOKEN }} -u https://api.permit.io -2 permitio/pdp-v2:test --no-pull
13+
# Call the reusable tests workflow.
14+
uses: ./.github/workflows/tests.yml@v2
15+
secrets: inherit
7416

7517
build-and-push-pdp-vanilla:
7618
needs: pdp-tests
@@ -189,4 +131,4 @@ jobs:
189131
aws ecs update-service \
190132
--cluster public-pdps-us-east-1 \
191133
--service pdp-general-redoc-service-731a74c \
192-
--force-new-deployment
134+
--force-new-deployment

.github/workflows/tests.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: PDP CI Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master, main, v*]
7+
workflow_call:
8+
secrets:
9+
PDP_TESTER_API_KEY:
10+
required: true
11+
CLONE_REPO_TOKEN:
12+
required: true
13+
14+
jobs:
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-python@v3
20+
- uses: pre-commit/[email protected]
21+
22+
pytests:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Python setup
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11.8'
29+
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Run Pytests
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install ".[dev]"
37+
pytest -s --cache-clear horizon/tests/
38+
39+
pdp-tester:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- uses: actions/checkout@v4
46+
with:
47+
repository: permitio/permit-opa
48+
ref: main
49+
path: './permit-opa'
50+
token: ${{ secrets.CLONE_REPO_TOKEN }}
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Pre build PDP tests
59+
run: |
60+
echo "next" > permit_pdp_version
61+
rm -rf custom
62+
mkdir custom
63+
build_root="$PWD"
64+
cd ./permit-opa
65+
find * \( -name '*go*' -o -name 'LICENSE.md' \) -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*'
66+
67+
- name: Build and load PDP Docker image
68+
uses: docker/build-push-action@v5
69+
with:
70+
push: false
71+
load: true
72+
context: .
73+
platforms: linux/amd64
74+
tags: permitio/pdp-v2:next
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
# Checkout the pdp-tester repository
79+
- name: Checkout pdp-tester repository
80+
uses: actions/checkout@v3
81+
with:
82+
repository: "permitio/pdp-tester"
83+
token: ${{ secrets.CLONE_REPO_TOKEN }}
84+
path: './pdp-tester'
85+
86+
# Setup Python environment
87+
- name: Setup Python
88+
uses: actions/setup-python@v3
89+
with:
90+
python-version: "3.12"
91+
92+
# Install dependencies for pdp-tester
93+
- name: Install pdp-tester dependencies
94+
working-directory: ./pdp-tester
95+
run: |
96+
pip install -r requirements.txt
97+
98+
# Run pdp-tester
99+
- name: Run pdp-tester
100+
working-directory: ./pdp-tester
101+
env:
102+
TOKEN: ${{ secrets.PDP_TESTER_API_KEY }}
103+
LOCAL_TAGS: '["next"]'
104+
INCLUDE_TAGS: '[]'
105+
AUTO_REMOVE: "False"
106+
SKIP_GENERATE: "True"
107+
ENABLE_APM: "False"
108+
run: |
109+
python -m pdp_tester.main
110+
111+
- name: Print Docker container logs
112+
if: always()
113+
run: |
114+
echo "Fetching logs for all Docker containers..."
115+
for container in $(docker ps -aq); do
116+
echo "========================================"
117+
echo "Logs for container: $container"
118+
echo "----------------------------------------"
119+
docker logs "$container" || true
120+
echo "========================================"
121+
echo ""
122+
done

0 commit comments

Comments
 (0)