Skip to content
Open

Ci/cd #124

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3682795
makefile updated to run example files
KshitijaChoudhari Apr 7, 2026
d46ea8e
makefile updated tun run example file - so ci/cd can run
KshitijaChoudhari Apr 7, 2026
0cc4acf
updated make file to run alll integration tests and have ddedd integr…
KshitijaChoudhari Apr 7, 2026
f4a33d9
updates varibles and oauth client example file sto pickup runtime env…
KshitijaChoudhari Apr 7, 2026
6248b9e
updates variables and ouath client exampel files to use run time work…
KshitijaChoudhari Apr 7, 2026
40975a8
updates variables and uath client exampel files to use run time works…
KshitijaChoudhari Apr 7, 2026
74739bf
makecheck file restored to orginial one and updated integration file …
KshitijaChoudhari Apr 7, 2026
9699016
intgeration-test.yml, configuration_version and query/-run
KshitijaChoudhari Apr 9, 2026
65a08aa
Updated integration-test to remove true
KshitijaChoudhari Apr 9, 2026
6093e21
Updated integration-test, configuration-version and query_run
KshitijaChoudhari Apr 9, 2026
2293756
have kepttrue on for oauth client and token
KshitijaChoudhari Apr 9, 2026
58c2563
Updated integration-test.yml
KshitijaChoudhari Apr 9, 2026
bab9c41
Updated integration-test.yml for oauth-token.py
KshitijaChoudhari Apr 9, 2026
bf8f476
Updated integration-test.yml for oauth-token.py
KshitijaChoudhari Apr 9, 2026
aeb7025
made changes to example files notification_configuration and registr…
KshitijaChoudhari Apr 9, 2026
f2d121c
made changes to example files notification_configuration and integra…
KshitijaChoudhari Apr 10, 2026
eccc98e
made changes to example files notification_configuration and integra…
KshitijaChoudhari Apr 10, 2026
5c5e75c
Updated organization_mebership and respectiev integration tests
KshitijaChoudhari Apr 10, 2026
7095e73
formatted organization_mebership
KshitijaChoudhari Apr 10, 2026
229ea98
Merge pull request #125 from KshitijaChoudhari/main
KshitijaChoudhari Apr 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
name: SDK Integration Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: make dev-install

- name: Run format check
run: make fmt-check

- name: Run lint
run: make lint

- name: Run unit tests
run: make type-check && .venv/bin/python -m pytest -v tests/

integration-tests:
name: Integration Tests (Example Files)
runs-on: ubuntu-latest
needs: unit-tests # only runs if unit tests pass

env:
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
TFE_ORG: ${{ secrets.TFE_ORG }}
TFE_ADDRESS: ${{ secrets.TFE_ADDRESS }}
TFE_WORKSPACE_ID: ${{ secrets.TFE_WORKSPACE_ID }}
TFE_WORKSPACE_NAME: ${{ secrets.TFE_WORKSPACE_NAME }}
TFE_TEAM_ID: ${{ secrets.TFE_TEAM_ID }}
TFE_RUN_ID: ${{ secrets.TFE_RUN_ID }}
TFE_APPLY_ID: ${{ secrets.TFE_APPLY_ID }}
TFE_PLAN_ID: ${{ secrets.TFE_PLAN_ID }}
TFE_TASK_STAGE_ID: ${{ secrets.TFE_TASK_STAGE_ID }}
TFE_POLICY_SET_ID: ${{ secrets.TFE_POLICY_SET_ID }}
TFE_POLICY_NAME: ${{ secrets.TFE_POLICY_NAME }}
TFE_REG_PROV_NS: ${{ secrets.TFE_REG_PROV_NS }}
TFE_REG_PROV_NAME: ${{ secrets.TFE_REG_PROV_NAME }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
OAUTH_CLIENT_GITHUB_TOKEN: ${{ secrets.OAUTH_CLIENT_GITHUB_TOKEN }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
TEST_MEMBER_EMAIL: ${{ secrets.TEST_MEMBER_EMAIL }}
TEAM_MEMBERSHIP_ID: ${{secretS.TEAM_MEBERSHIP_ID}}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: make dev-install

- name: agent.py
run: .venv/bin/python examples/agent.py

- name: agent_pool.py
run: .venv/bin/python examples/agent_pool.py

- name: apply.py
if: ${{ env.TFE_APPLY_ID != '' }}
run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID"

- name: configuration_version.py
if: ${{ env.TFE_WORKSPACE_ID != '' }}
run: .venv/bin/python examples/configuration_version.py

- name: notification_configuration.py
if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }}
run: .venv/bin/python examples/notification_configuration.py

- name: oauth_client.py
run: .venv/bin/python examples/oauth_client.py

- name: oauth_token.py
run: .venv/bin/python examples/oauth_token.py

- name: org.py
run: .venv/bin/python examples/org.py

- name: organization_membership.py
run: .venv/bin/python examples/organization_membership.py

- name: plan.py
if: ${{ env.TFE_PLAN_ID != '' }}
run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID"

- name: policy_check.py
if: ${{ env.TFE_RUN_ID != '' }}
run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID"

- name: policy_evaluation.py
if: ${{ env.TFE_TASK_STAGE_ID != '' }}
run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID"

- name: policy_set_parameter.py
if: ${{ env.TFE_POLICY_SET_ID != '' }}
run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID"

- name: policy_set.py
run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG"

- name: policy.py
if: ${{ env.TFE_POLICY_NAME != '' }}
run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME"

- name: project.py
run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG"

- name: query_run.py
if: ${{ env.TFE_WORKSPACE_NAME != '' }}
run: .venv/bin/python examples/query_run.py

- name: registry_module.py
run: .venv/bin/python examples/registry_module.py

- name: registry_provider_version.py
if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }}
run: |
.venv/bin/python examples/registry_provider_version.py \
--organization "$TFE_ORG" \
--namespace "$TFE_REG_PROV_NS" \
--name "$TFE_REG_PROV_NAME"

- name: registry_provider.py
run: .venv/bin/python examples/registry_provider.py

- name: reserved_tag_key.py
run: .venv/bin/python examples/reserved_tag_key.py

- name: run_events.py
if: ${{ env.TFE_RUN_ID != '' }}
run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID"

- name: run_task.py
run: .venv/bin/python examples/run_task.py --org "$TFE_ORG"

- name: run_trigger.py
run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG"

- name: run.py
run: .venv/bin/python examples/run.py --organization "$TFE_ORG"

- name: ssh_keys.py
if: ${{ env.SSH_PRIVATE_KEY != '' }}
run: .venv/bin/python examples/ssh_keys.py

- name: state_versions.py
if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }}
run: |
.venv/bin/python examples/state_versions.py \
--org "$TFE_ORG" \
--workspace "$TFE_WORKSPACE_NAME" \
--workspace-id "$TFE_WORKSPACE_ID"

- name: variable_sets.py
run: .venv/bin/python examples/variable_sets.py

- name: variables.py
if: ${{ env.TFE_WORKSPACE_ID != '' }}
run: .venv/bin/python examples/variables.py

- name: workspace_resources.py
if: ${{ env.TFE_WORKSPACE_ID != '' }}
run: |
.venv/bin/python examples/workspace_resources.py \
--list \
--workspace-id "$TFE_WORKSPACE_ID" \
--page-size 10

- name: workspace.py
run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ clean:
find . -type d -name ".ruff_cache" -exec rm -rf {} +
rm -rf build/ dist/ $(VENV)

all: clean dev-install fmt lint test
all: clean dev-install fmt lint test
2 changes: 1 addition & 1 deletion examples/configuration_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def main():

# Initialize the TFE client
client = TFEClient(TFEConfig.from_env())
workspace_id = "ws-zLgDCHFz9mBfri2Q" # Replace with your workspace ID
workspace_id = os.getenv("TFE_WORKSPACE_ID") # Replace with your workspace ID

# Variables to store created resources for dependent tests
created_cv_id = None
Expand Down
6 changes: 3 additions & 3 deletions examples/notification_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ def main():

# Resolve organization and workspace from environment variables
org_name = os.environ["TFE_ORG"]
workspace_name = os.getenv("TFE_WORKSPACE_NAME", "test-api")
workspace_id = os.getenv("TFE_WORKSPACE_ID", "")
workspace_name = os.getenv("TFE_WORKSPACE_NAME")
workspace_id = os.getenv("TFE_WORKSPACE_ID")
if not workspace_id:
print(f"Looking up workspace '{workspace_name}' in org '{org_name}'...")
ws = client.workspaces.read(workspace_name, organization=org_name)
workspace_id = ws.id
print(f"Resolved workspace ID: {workspace_id}")
print(f"Using workspace: {workspace_name} (ID: {workspace_id})")

team_id = os.getenv("TFE_TEAM_ID", "team-example123456789")
team_id = os.getenv("TFE_TEAM_ID")
if team_id == "team-example123456789":
print("Using fake team ID for demonstration (teams may require paid plan)")
else:
Expand Down
2 changes: 1 addition & 1 deletion examples/oauth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def main():

# Initialize the TFE client
client = TFEClient(TFEConfig.from_env())
organization_name = "aayush-test" # Replace with your organization
organization_name = os.getenv("TFE_ORG")

# Variables to store created resources for dependent tests
created_oauth_client = None
Expand Down
12 changes: 8 additions & 4 deletions examples/organization_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
python examples/organization_membership.py <organization-name>
"""

import os
import sys

from pytfe import TFEClient
Expand All @@ -28,7 +29,8 @@
def main():
"""Demonstrate organization membership list functionality."""

organization_name = "aayush-test"
organization_name = os.getenv("TFE_ORG")
team_id = os.getenv("TFE_TEAM_ID")

# Initialize the client (reads TFE_TOKEN and TFE_ADDRESS from environment)
try:
Expand Down Expand Up @@ -272,13 +274,13 @@ def main():
from pytfe.models import OrganizationMembershipCreateOptions, Team

# Replace with a valid email for your organization
new_member_email = "sivaselvan.i@hashicorp.com"
new_member_email = os.getenv("TEST_MEMBER_EMAIL")

# Create membership with teams (uncomment to use)
from pytfe.models import OrganizationAccess

team = Team(
id="team-dx24FR9xQUuwNTHA",
id=team_id,
organization_access=OrganizationAccess(read_workspaces=True),
) # Replace with actual team ID
create_options = OrganizationMembershipCreateOptions(
Expand All @@ -300,7 +302,9 @@ def main():
try:
from pytfe.errors import NotFound

membership_id = "ou-9mG77c6uE5GScg9k" # Replace with actual membership ID
membership_id = os.getenv(
"TFE_MEMBERSHIP_ID"
) # Replace with actual membership ID
print(f"Attempting to delete membership: {membership_id}")

client.organization_memberships.delete(membership_id)
Expand Down
4 changes: 2 additions & 2 deletions examples/query_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
def get_client_and_workspace():
"""Initialize client and get workspace ID."""
client = TFEClient(TFEConfig.from_env())
organization = os.getenv("TFE_ORG", "aayush-test")
workspace_name = "query-test" # Default workspace for testing
organization = os.getenv("TFE_ORG")
workspace_name = os.getenv("TFE_WORKSPACE_NAME") # Default workspace for testing

# Get workspace
workspace = client.workspaces.read(workspace_name, organization=organization)
Expand Down
2 changes: 1 addition & 1 deletion examples/registry_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
def get_client_and_org():
"""Initialize client and get organization name."""
client = TFEClient()
organization_name = os.getenv("TFE_ORGANIZATION", "aayush-test")
organization_name = os.environ["TFE_ORG"]
return client, organization_name


Expand Down
4 changes: 3 additions & 1 deletion examples/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def main():
client = TFEClient(TFEConfig.from_env())

# Replace this with your actual workspace ID
workspace_id = "ws-example123456789" # Get this from your TFE workspace
workspace_id = os.environ.get(
"TFE_WORKSPACE_ID"
) # Get this from your TFE workspace

print(f"Testing all variable operations in workspace: {workspace_id}")
print("=" * 60)
Expand Down
Loading