Skip to content

Commit 24ddc12

Browse files
authored
Merge pull request #246 from permitio/dan/per-12033-cherrypick-changes-from-pdp-070
Dan/per 12033 cherrypick changes from pdp 070
2 parents 87a6be6 + 8d6a010 commit 24ddc12

Some content is hidden

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

51 files changed

+1210
-1188
lines changed

.github/workflows/dockerhub_push.yml

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

.github/workflows/helm_release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Helm Release Workflow
22

33
on:
44
push:
5-
branches:
6-
- v2
7-
workflow_dispatch:
5+
paths:
6+
- 'charts/pdp/Chart.yaml'
87

98
jobs:
109
helm-release:
10+
if: github.event_name == 'push' && github.ref == 'refs/heads/v2'
1111
permissions:
1212
contents: write
1313
runs-on: ubuntu-latest
@@ -16,6 +16,7 @@ jobs:
1616
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
19+
1920
- name: Configure Git
2021
run: |
2122
git config user.name "elimoshkovich"
@@ -30,3 +31,4 @@ jobs:
3031
CR_TOKEN: "${{ secrets.PAGES }}"
3132
with:
3233
skip_existing: true
34+
mark_as_latest: false

.github/workflows/pdp_tests.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,15 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
id-token: write
9+
contents: read
10+
711
jobs:
812
pdp-tests:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v4
13-
14-
- name: Set up QEMU
15-
uses: docker/setup-qemu-action@v3
16-
17-
- name: Set up Docker Buildx
18-
uses: docker/setup-buildx-action@v3
19-
20-
- uses: actions/checkout@v3
21-
with:
22-
repository: permitio/permit-opa
23-
ref: main
24-
path: './permit-opa'
25-
token: ${{ secrets.CLONE_REPO_TOKEN }}
26-
27-
- name: Pre build PDP tests
28-
run: |
29-
echo "${{ github.event.release.tag_name }}" | cut -d '-' -f 1 > permit_pdp_version
30-
rm -rf custom
31-
mkdir custom
32-
build_root="$PWD"
33-
cd ./permit-opa
34-
find * -name '*go*' -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*'
35-
36-
- name: Build and load image for PDP E2E tests
37-
uses: docker/build-push-action@v5
38-
with:
39-
push: false
40-
load: true
41-
context: .
42-
platforms: linux/amd64
43-
tags: permitio/pdp-v2:test
44-
cache-from: type=gha
45-
cache-to: type=gha,mode=max
46-
47-
- uses: actions/checkout@v3
48-
with:
49-
repository: permitio/permit-backend
50-
ref: main
51-
path: './permit-backend'
52-
token: ${{ secrets.CLONE_REPO_TOKEN }}
53-
54-
- name: Python setup
55-
uses: actions/setup-python@v5
56-
with:
57-
python-version: '3.11.8'
58-
59-
- name: Run Pytests
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install ".[dev]"
63-
pytest -s --cache-clear horizon/tests/
64-
65-
- name: Run E2E tests
66-
working-directory: ./permit-backend/proactive_tests/sidecar
67-
run: |
68-
pip install requests pydantic==1.8.2 docker
69-
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
15+
secrets: inherit
7016

7117
build-and-push-pdp-vanilla:
7218
needs: pdp-tests
@@ -145,7 +91,7 @@ jobs:
14591
mkdir custom
14692
build_root="$PWD"
14793
cd ./permit-opa
148-
find * -name '*go*' -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*'
94+
find * \( -name '*go*' -o -name 'LICENSE.md' \) -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*'
14995
15096
- name: Build and push PDP image - (pre-release)
15197
if: "github.event.release.prerelease"
@@ -168,3 +114,21 @@ jobs:
168114
tags: permitio/pdp-v2:${{ github.event.release.tag_name }},permitio/pdp-v2:latest
169115
cache-from: type=gha
170116
cache-to: type=gha,mode=max
117+
118+
update-pdp-api-ecs-service:
119+
needs: build-and-push-pdp
120+
runs-on: ubuntu-latest
121+
if: "!github.event.release.prerelease"
122+
steps:
123+
- name: Configure AWS credentials
124+
uses: aws-actions/configure-aws-credentials@v4
125+
with:
126+
role-to-assume: ${{ secrets.PDP_CICD_AWS_ROLE }}
127+
aws-region: us-east-1
128+
129+
- name: Redeploy ECS service - pdp-general-redoc-service
130+
run: |
131+
aws ecs update-service \
132+
--cluster public-pdps-us-east-1 \
133+
--service pdp-general-redoc-service-731a74c \
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

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,11 @@ dmypy.json
130130

131131
# editors
132132
.vscode/
133+
.idea/
134+
135+
# PDP specific
136+
/opa
137+
/permit_pdp_version
138+
139+
# MacOS specific
140+
.DS_Store

.isort.cfg

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

0 commit comments

Comments
 (0)