Skip to content

feat(netlify): upgrade to SDK 2.0.0 with unit + integration tests#386

Open
Tram-Nguyen87 wants to merge 2 commits into
masterfrom
feat/netlify-sdk-v2
Open

feat(netlify): upgrade to SDK 2.0.0 with unit + integration tests#386
Tram-Nguyen87 wants to merge 2 commits into
masterfrom
feat/netlify-sdk-v2

Conversation

@Tram-Nguyen87

@Tram-Nguyen87 Tram-Nguyen87 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Migrates Netlify integration from autohive-integrations-sdk~=1.0.2 to ~=2.0.0
  • All context.fetch() return values updated to access .data for the body
  • All error paths converted from ActionResult with error data to ActionError(message=...)
  • result: bool and error fields removed from all output schemas in config.json; delete_site output updated to deleted: boolean
  • config.json version bumped to 2.0.0
  • Added deploy_id None guard in create_deploy to fail fast with a clear error rather than silently making requests to /deploys/None/...
  • Replaced legacy tests/test_netlify.py (manual async runner) and tests/context.py with a proper pytest suite

Tests

Unit tests (test_netlify_unit.py) — 42 tests

  • Full coverage across all 8 actions: list_sites, create_site, get_site, update_site, delete_site, list_deploys, create_deploy, get_deploy
  • Each action covered for: happy path, request URL/method verification, ActionError on exception, VALIDATION_ERROR on missing required inputs
  • create_deploy edge cases: no required files, file upload with correct deploy_id + SHA1 in URL + Content-Type: application/octet-stream header, deploy_url priority (deploy_ssl_url -> ssl_url -> url), multiple file hashing, missing deploy ID in API response

Integration tests (test_netlify_integration.py) — 10 tests (run against live Netlify API)

  • Read-only: TestListSites, TestGetSite, TestListDeploys, TestGetDeploy
  • Destructive (site create + update + delete lifecycle, deploy with real file upload) via -m "integration and destructive"
  • real_fetch raises HTTPError on non-2xx to mirror SDK production behaviour

Test plan

  • python -m pytest netlify/tests/test_netlify_unit.py -v — 42 passed
  • python -m pytest netlify/tests/test_netlify_integration.py -m integration -v — 10 passed (live API, including destructive lifecycle)
  • validate_integration.py netlify — 0 errors, 0 warnings
  • check_code.py netlify — lint, format, security, imports, fetch patterns, config-code sync all green
  • /code-review high effort self-review run pre-PR — all findings fixed before submission

Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

🔍 Integration Validation Results

Commit: 0cfd798c7ad2de92effdc57736e575f6634d0fe7 · fix(netlify): use file path in deploy upload URL; exclude destructive tests from read-only command
Updated: 2026-06-23T01:59:07Z

Changed directories: netlify

Check Result
Structure ✅ Passed
Code ✅ Passed
Tests ✅ Passed
README ✅ Passed
Version ✅ Passed
✅ Structure Check output
Validating 1 integration(s)...

============================================================
Integration: netlify
============================================================
✅ All checks passed!

============================================================
SUMMARY
============================================================
Integrations validated: 1
Total errors: 0
Total warnings: 0

✅ All validations passed!
✅ Code Check output
----------------------------------------
Checking: netlify
----------------------------------------

📦 Installing dependencies...

🐍 Checking Python syntax...
   ✅ Syntax OK

📥 Checking imports...
   ✅ Imports OK

📄 Checking JSON files...
   ✅ JSON files OK

🔍 Linting with ruff...
   ✅ Lint OK

🎨 Checking formatting with ruff...
   ✅ Formatting OK

🔒 Scanning for security issues with bandit...
   ✅ Security OK

🛡️ Checking dependencies for vulnerabilities with pip-audit...
   ✅ Dependencies OK

🔗 Checking config-code sync...
   ✅ Config-code sync OK

🔄 Checking fetch patterns...
   ✅ Fetch patterns OK

========================================
✅ CODE CHECK PASSED
========================================
✅ Tests Check output

Integration   Tests  Coverage        Status
-------------------------------------------
netlify     42/42      100%      ✅ Passed
-------------------------------------------
Total       42/42            ✅ All passed

✅ Tests passed: netlify
✅ README Check output
========================================
✅ README CHECK PASSED
========================================
✅ Version Check output
✅ netlify: 1.0.0 → 2.0.0 (major bump)

========================================
✅ VERSION CHECK PASSED
========================================

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5864610731

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

set in the NETLIFY_ACCESS_TOKEN environment variable.

Run all read-only tests:
pytest netlify/tests/test_netlify_integration.py -m integration

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude destructive tests from the read-only command

I checked python -m pytest --help; -m runs tests matching the mark expression, so -m integration also selects the classes below that are both integration via the module pytestmark and destructive. Anyone following the advertised “read-only” command with NETLIFY_ACCESS_TOKEN set will create/update/delete real Netlify sites; use -m "integration and not destructive" for the read-only command.

Useful? React with 👍 / 👎.

Comment thread netlify/tests/test_netlify_unit.py Outdated
upload_url = upload_call.args[0] if upload_call.args else upload_call.kwargs.get("url", "")
assert upload_call.kwargs.get("method") == "PUT"
assert "deploy-2" in upload_url
assert sha1 in upload_url

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Assert file paths for deploy uploads

When Netlify returns required, those entries are SHA1 digests used to decide which file contents are needed, but the upload request must target /deploys/{deploy_id}/files/{file_path} (for example, /files/index.html) per Netlify's API guide. This new assertion makes the unit suite pass the digest-in-path URL that the real API rejects whenever a file upload is required, so please assert the original file path instead.

Useful? React with 👍 / 👎.

… tests from read-only command

- Upload URL now correctly uses the file path (/deploys/{id}/files{/path})
  instead of the SHA1 hash per the Netlify API spec; added hash_to_path
  mapping to track which path corresponds to each required SHA1
- Read-only integration test command corrected to -m "integration and not
  destructive" so destructive lifecycle tests are not accidentally run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@TheRealAgentK TheRealAgentK left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted one blocker from the integration-test review checklist.


pytestmark = pytest.mark.integration

ACCESS_TOKEN = os.environ.get("NETLIFY_ACCESS_TOKEN", "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Blocker: this new live integration test reads NETLIFY_ACCESS_TOKEN, but the PR doesn't add NETLIFY_ACCESS_TOKEN= to the root .env.example. Per the integration-test checklist, every env var read by integration tests must be documented there so reviewers and future contributors have a canonical setup contract. Please add a Netlify block with this variable before merge.

@TheRealAgentK TheRealAgentK left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because the new live integration tests read NETLIFY_ACCESS_TOKEN but the root .env.example setup contract is missing that variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants