Skip to content

Commit bd859c5

Browse files
Added PDP Tester to CI/CD (#232)
* test1 * check with setup Docker step * try2 * try3 * test with local build check * without ref * Update pdp-tester.yml * Added print PDP container logs * Changed API Key variable * Added PDP Tester job to the CI * Changed CD to reuse CI * Changed PDP Tester build version to 'next' * Added branch to reusable workflow call --------- Co-authored-by: Dan Yishai <danyi1212@users.noreply.github.com>
1 parent cdd9c2e commit bd859c5

File tree

4 files changed

+136
-164
lines changed

4 files changed

+136
-164
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: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +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-
- uses: robinraju/release-downloader@v1
41-
with:
42-
repository: permitio/datasync
43-
latest: true
44-
fileName: factstore_server*
45-
token: ${{ secrets.CLONE_REPO_TOKEN }}
46-
out-file-path: "factdb"
47-
48-
- name: Build and load image for PDP E2E tests
49-
uses: docker/build-push-action@v5
50-
with:
51-
push: false
52-
load: true
53-
context: .
54-
build-args: |
55-
ALLOW_MISSING_FACTSTORE=false
56-
platforms: linux/amd64
57-
tags: permitio/pdp-v2:test
58-
cache-from: type=gha
59-
cache-to: type=gha,mode=max
60-
61-
- uses: actions/checkout@v3
62-
with:
63-
repository: permitio/permit-backend
64-
ref: main
65-
path: './permit-backend'
66-
token: ${{ secrets.CLONE_REPO_TOKEN }}
67-
68-
- name: Python setup
69-
uses: actions/setup-python@v5
70-
with:
71-
python-version: '3.11.8'
72-
73-
- name: Run Pytests
74-
run: |
75-
python -m pip install --upgrade pip
76-
pip install ".[dev]"
77-
pytest -s --cache-clear horizon/tests/
78-
79-
- name: Run E2E tests
80-
working-directory: ./permit-backend/proactive_tests/sidecar
81-
run: |
82-
pip install requests pydantic==1.8.2 docker
83-
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
8416

8517
build-and-push-pdp-vanilla:
8618
needs: pdp-tests

.github/workflows/tests.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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/action@v2.0.3
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+
- uses: robinraju/release-downloader@v1
68+
with:
69+
repository: permitio/datasync
70+
latest: true
71+
fileName: factstore_server*
72+
token: ${{ secrets.CLONE_REPO_TOKEN }}
73+
out-file-path: "factdb"
74+
75+
- name: Build and load PDP Docker image
76+
uses: docker/build-push-action@v5
77+
with:
78+
push: false
79+
load: true
80+
context: .
81+
build-args: |
82+
ALLOW_MISSING_FACTSTORE=false
83+
platforms: linux/amd64
84+
tags: permitio/pdp-v2:next
85+
cache-from: type=gha
86+
cache-to: type=gha,mode=max
87+
88+
# Checkout the pdp-tester repository
89+
- name: Checkout pdp-tester repository
90+
uses: actions/checkout@v3
91+
with:
92+
repository: "permitio/pdp-tester"
93+
token: ${{ secrets.CLONE_REPO_TOKEN }}
94+
path: './pdp-tester'
95+
96+
# Setup Python environment
97+
- name: Setup Python
98+
uses: actions/setup-python@v3
99+
with:
100+
python-version: "3.12"
101+
102+
# Install dependencies for pdp-tester
103+
- name: Install pdp-tester dependencies
104+
working-directory: ./pdp-tester
105+
run: |
106+
pip install -r requirements.txt
107+
108+
# Run pdp-tester
109+
- name: Run pdp-tester
110+
working-directory: ./pdp-tester
111+
env:
112+
TOKEN: ${{ secrets.PDP_TESTER_API_KEY }}
113+
LOCAL_TAGS: '["next"]'
114+
INCLUDE_TAGS: '[]'
115+
AUTO_REMOVE: "False"
116+
SKIP_GENERATE: "True"
117+
ENVIRONMENT: '{"PDP_ENABLE_FACTDB": true}'
118+
ENABLE_APM: "False"
119+
run: |
120+
python -m pdp_tester.main
121+
122+
- name: Print Docker container logs
123+
if: always()
124+
run: |
125+
echo "Fetching logs for all Docker containers..."
126+
for container in $(docker ps -aq); do
127+
echo "========================================"
128+
echo "Logs for container: $container"
129+
echo "----------------------------------------"
130+
docker logs "$container" || true
131+
echo "========================================"
132+
echo ""
133+
done

0 commit comments

Comments
 (0)