Skip to content

Commit c393694

Browse files
committed
Added pydantic v1/v2 matrix to Tests CI
1 parent 980df3a commit c393694

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

.github/workflows/test.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ env:
1616
jobs:
1717
pytest:
1818
runs-on: ubuntu-latest
19-
name: pytest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
pydantic-version: ['pydantic<2.0.0', 'pydantic>=2.0.0']
23+
name: pytest (Pydantic ${{ matrix.pydantic-version }})
2024
services:
2125
pdp:
2226
image: permitio/pdp-v2:latest
@@ -34,23 +38,27 @@ jobs:
3438
with:
3539
python-version: '3.11.8'
3640

37-
- name: Creation env ${{ env.ENV_NAME }} under 'Permit.io Tests' workspace
41+
- name: Creation env ${{ env.ENV_NAME }}-${{ github.run_id }}-${{ matrix.pydantic-version }}
42+
id: create_env
3843
run: |
44+
ENV_KEY="${{ env.ENV_NAME }}-${{ github.run_id }}-${{ matrix.pydantic-version == 'pydantic<2.0.0' && 'v1' || 'v2' }}"
45+
echo "ENV_KEY=$ENV_KEY" >> $GITHUB_ENV
46+
3947
response=$(curl -X POST \
4048
https://api.permit.io/v2/projects/${{ env.PROJECT_ID }}/envs \
4149
-H 'Authorization: Bearer ${{ secrets.PROJECT_API_KEY }}' \
4250
-H 'Content-Type: application/json' \
4351
-d '{
44-
"key": "${{ env.ENV_NAME }}",
45-
"name": "${{ env.ENV_NAME }}"
52+
"key": "'"$ENV_KEY"'",
53+
"name": "'"$ENV_KEY"'"
4654
}')
4755
4856
# Extract the new env id
4957
echo "ENV_ID=$(echo "$response" | jq -r '.id')" >> $GITHUB_ENV
5058
51-
echo "New env ID: $ENV_ID"
59+
echo "New env ID: $ENV_ID with key: $ENV_KEY"
5260
53-
- name: Fetch API_KEY of ${{ env.ENV_NAME }}
61+
- name: Fetch API_KEY of ${{ env.ENV_KEY }}
5462
run: |
5563
response=$(curl -X GET \
5664
https://api.permit.io/v2/api-key/${{ env.PROJECT_ID }}/${{ env.ENV_ID }} \
@@ -61,6 +69,18 @@ jobs:
6169
6270
echo "New env api key: $ENV_API_KEY"
6371
72+
- name: Install dependencies
73+
run: |
74+
python -m pip install --upgrade pip
75+
pip install flake8 pytest pytest-cov
76+
# Pin pydantic version according to matrix
77+
pip install "${{ matrix.pydantic-version }}"
78+
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
79+
if [ -f requirements.txt ]; then pip install -r requirements.txt --no-deps; fi
80+
81+
- name: Show installed packages
82+
run: pip list
83+
6484
- name: Test with pytest
6585
env:
6686
PDP_URL: http://localhost:7766
@@ -69,13 +89,9 @@ jobs:
6989
PROJECT_PDP_API_KEY: ${{ env.ENV_API_KEY }}
7090
PDP_API_KEY: ${{ env.ENV_API_KEY }}
7191
run: |
72-
python -m pip install --upgrade pip
73-
pip install flake8 pytest pytest-cov
74-
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
75-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
7692
pytest -s --cache-clear tests/
7793
78-
- name: Delete env ${{ env.ENV_NAME }}
94+
- name: Delete env ${{ env.ENV_KEY }}
7995
if: always()
8096
run: |
8197
curl -X DELETE \

0 commit comments

Comments
 (0)