Skip to content

Commit 79509e3

Browse files
authored
add ci and e2e suites (#18)
* add ci and e2e suites * test * fix uninstaller bug * feedback * bump versions
1 parent 4227b4d commit 79509e3

Some content is hidden

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

41 files changed

+1257
-719
lines changed

.github/workflows/aws.yaml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: E2E AWS
2+
3+
on:
4+
workflow_call: {}
5+
6+
permissions:
7+
contents: read
8+
id-token: write
9+
10+
jobs:
11+
up:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 60
14+
environment: aws-e2e
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set stack name
21+
run: |
22+
if [ -n "$PR_NUMBER" ]; then
23+
echo "STACK_NAME=ci-aws-pr${PR_NUMBER}-${GITHUB_SHA::7}" >> "$GITHUB_ENV"
24+
else
25+
echo "STACK_NAME=ci-aws-${GITHUB_SHA::7}" >> "$GITHUB_ENV"
26+
fi
27+
env:
28+
PR_NUMBER: ${{ github.event.pull_request.number }}
29+
30+
- name: Configure AWS credentials (OIDC)
31+
uses: aws-actions/configure-aws-credentials@v4
32+
with:
33+
role-to-assume: ${{ secrets.AWS_E2E_ROLE_ARN }}
34+
aws-region: us-east-1
35+
role-duration-seconds: 43200
36+
37+
- uses: astral-sh/setup-uv@v5
38+
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Install Pulumi CLI
44+
uses: pulumi/actions@v6
45+
46+
- name: Install kubectl
47+
uses: azure/setup-kubectl@v4
48+
49+
- name: Run wizard (headless)
50+
id: wizard
51+
env:
52+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
53+
PINECONE_REGION: us-east-1
54+
PINECONE_AZS: "us-east-1a,us-east-1b"
55+
PINECONE_VPC_CIDR: "10.0.0.0/16"
56+
PINECONE_DELETION_PROTECTION: "false"
57+
PINECONE_PUBLIC_ACCESS: "false"
58+
PINECONE_PROJECT_NAME: "pinecone-byoc"
59+
run: |
60+
uv run --with rich --with pyyaml python setup/wizard.py \
61+
--cloud aws \
62+
--headless \
63+
--stack-name "$STACK_NAME" \
64+
--skip-install \
65+
--output-dir ./e2e-project
66+
67+
- name: Patch __main__.py with CI overrides
68+
working-directory: ./e2e-project
69+
run: |
70+
python3 << 'PATCH'
71+
path = "__main__.py"
72+
content = open(path).read()
73+
content = content.replace(
74+
" tags=config.get_object(\"tags\"),",
75+
""" tags=config.get_object("tags"),
76+
global_env=config.require("global-env"),
77+
api_url=config.require("api-url"),
78+
auth0_domain=config.require("auth0-domain"),
79+
gcp_project=config.require("gcp-project"),""",
80+
)
81+
open(path, "w").write(content)
82+
PATCH
83+
84+
- name: Replace PyPI dep with local source
85+
working-directory: ./e2e-project
86+
run: |
87+
sed -i 's|"pulumi-pinecone-byoc\[aws\]"|"pulumi-pinecone-byoc[aws] @ file://'"$GITHUB_WORKSPACE"'"|' pyproject.toml
88+
grep -q 'file://' pyproject.toml || { echo "ERROR: local source substitution failed"; exit 1; }
89+
90+
- name: Install dependencies
91+
working-directory: ./e2e-project
92+
run: uv sync
93+
94+
- name: Setup Pulumi stack
95+
working-directory: ./e2e-project
96+
env:
97+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
98+
run: |
99+
pulumi stack select --create "$STACK_NAME"
100+
101+
- name: Set Pulumi config
102+
working-directory: ./e2e-project
103+
env:
104+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
105+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
106+
run: |
107+
pulumi config set --secret pinecone-api-key "$PINECONE_API_KEY" --stack "$STACK_NAME"
108+
pulumi config set global-env ci --stack "$STACK_NAME"
109+
pulumi config set api-url "https://api-staging.pinecone.io" --stack "$STACK_NAME"
110+
pulumi config set auth0-domain "https://internal-beta-pinecone-io.us.auth0.com" --stack "$STACK_NAME"
111+
pulumi config set gcp-project "development-pinecone" --stack "$STACK_NAME"
112+
113+
- name: Pulumi up
114+
working-directory: ./e2e-project
115+
env:
116+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
117+
run: pulumi up --yes --stack "$STACK_NAME"
118+
119+
down:
120+
needs: up
121+
if: always() && needs.up.result != 'skipped'
122+
runs-on: ubuntu-latest
123+
timeout-minutes: 60
124+
environment: aws-e2e
125+
steps:
126+
- uses: actions/checkout@v4
127+
with:
128+
fetch-depth: 0
129+
130+
- name: Set stack name
131+
run: |
132+
if [ -n "$PR_NUMBER" ]; then
133+
echo "STACK_NAME=ci-aws-pr${PR_NUMBER}-${GITHUB_SHA::7}" >> "$GITHUB_ENV"
134+
else
135+
echo "STACK_NAME=ci-aws-${GITHUB_SHA::7}" >> "$GITHUB_ENV"
136+
fi
137+
env:
138+
PR_NUMBER: ${{ github.event.pull_request.number }}
139+
140+
- name: Configure AWS credentials (OIDC)
141+
uses: aws-actions/configure-aws-credentials@v4
142+
with:
143+
role-to-assume: ${{ secrets.AWS_E2E_ROLE_ARN }}
144+
aws-region: us-east-1
145+
role-duration-seconds: 43200
146+
147+
- uses: astral-sh/setup-uv@v5
148+
149+
- uses: actions/setup-python@v5
150+
with:
151+
python-version: "3.12"
152+
153+
- name: Install Pulumi CLI
154+
uses: pulumi/actions@v6
155+
156+
- name: Run wizard (headless)
157+
env:
158+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
159+
PINECONE_REGION: us-east-1
160+
PINECONE_AZS: "us-east-1a,us-east-1b"
161+
PINECONE_VPC_CIDR: "10.0.0.0/16"
162+
PINECONE_DELETION_PROTECTION: "false"
163+
PINECONE_PUBLIC_ACCESS: "false"
164+
PINECONE_PROJECT_NAME: "pinecone-byoc"
165+
run: |
166+
uv run --with rich --with pyyaml python setup/wizard.py \
167+
--cloud aws \
168+
--headless \
169+
--stack-name "$STACK_NAME" \
170+
--skip-install \
171+
--output-dir ./e2e-project
172+
173+
- name: Replace PyPI dep with local source
174+
working-directory: ./e2e-project
175+
run: |
176+
sed -i 's|"pulumi-pinecone-byoc\[aws\]"|"pulumi-pinecone-byoc[aws] @ file://'"$GITHUB_WORKSPACE"'"|' pyproject.toml
177+
grep -q 'file://' pyproject.toml || { echo "ERROR: local source substitution failed"; exit 1; }
178+
179+
- name: Install dependencies
180+
working-directory: ./e2e-project
181+
run: uv sync
182+
183+
- name: Cancel stale locks
184+
working-directory: ./e2e-project
185+
env:
186+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
187+
run: pulumi cancel --yes --stack "$STACK_NAME" 2>/dev/null || true
188+
189+
- name: Pulumi destroy
190+
working-directory: ./e2e-project
191+
env:
192+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
193+
run: pulumi destroy --yes --stack "$STACK_NAME"
194+
195+
- name: Pulumi stack rm
196+
working-directory: ./e2e-project
197+
env:
198+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
199+
run: pulumi stack rm "$STACK_NAME" --yes --force

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: astral-sh/setup-uv@v5
19+
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install dependencies
25+
run: uv sync --all-extras --group dev
26+
27+
- name: Check formatting
28+
run: uv run ruff format --check .
29+
30+
- name: Run linting
31+
run: uv run ruff check .
32+
33+
- name: Run type checking
34+
run: uv run ty check

.github/workflows/e2e.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: E2E
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
workflow_dispatch: {}
7+
8+
concurrency:
9+
group: e2e-${{ github.head_ref || github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
aws: ${{ steps.filter.outputs.aws }}
21+
gcp: ${{ steps.filter.outputs.gcp }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: dorny/paths-filter@v3
25+
id: filter
26+
with:
27+
filters: |
28+
aws:
29+
- 'pulumi_pinecone_byoc/aws/**'
30+
- 'pulumi_pinecone_byoc/common/**'
31+
- 'config/aws.py'
32+
- 'config/base.py'
33+
- 'config/__init__.py'
34+
- 'setup/wizard.py'
35+
- 'setup/aws_wizard.py'
36+
gcp:
37+
- 'pulumi_pinecone_byoc/gcp/**'
38+
- 'pulumi_pinecone_byoc/common/**'
39+
- 'config/gcp.py'
40+
- 'config/base.py'
41+
- 'config/__init__.py'
42+
- 'setup/wizard.py'
43+
- 'setup/gcp_wizard.py'
44+
45+
aws:
46+
needs: changes
47+
if: needs.changes.outputs.aws == 'true' || github.event_name == 'workflow_dispatch'
48+
uses: ./.github/workflows/aws.yaml
49+
secrets: inherit
50+
51+
gcp:
52+
needs: changes
53+
if: needs.changes.outputs.gcp == 'true' || github.event_name == 'workflow_dispatch'
54+
uses: ./.github/workflows/gcp.yaml
55+
secrets: inherit
56+
57+
result:
58+
if: always()
59+
needs: [changes, aws, gcp]
60+
runs-on: ubuntu-latest
61+
steps:
62+
- run: |
63+
echo "AWS: ${{ needs.aws.result }}"
64+
echo "GCP: ${{ needs.gcp.result }}"
65+
if [ "${{ needs.aws.result }}" = "failure" ] || [ "${{ needs.gcp.result }}" = "failure" ]; then
66+
echo "E2E failed"
67+
exit 1
68+
fi
69+
if [ "${{ needs.aws.result }}" = "cancelled" ] || [ "${{ needs.gcp.result }}" = "cancelled" ]; then
70+
echo "E2E cancelled"
71+
exit 1
72+
fi
73+
echo "OK"

0 commit comments

Comments
 (0)