ocean icon indicating copy to clipboard operation
ocean copied to clipboard

[Integration][Github] Added Support for Pull Request Kind

Open emekanwaoma opened this issue 7 months ago • 1 comments

Description

What - Added Pull Request resource support to the GitHub V2 integration. This feature allows syncing GitHub pull requests into Port as entities and receiving webhooks for real-time updates.

Why - This enhancement provides users with the ability to track and monitor pull requests directly in Port, enabling better visibility into development workflows and metrics like lead time.

How - Implemented a PullRequestExporter class to fetch pull request data, added webhook support for real-time pull request events, and included configuration options to select pull requests by state (open, closed, or all).

Type of change

Please leave one option from the following and delete the rest:

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] New Integration (non-breaking change which adds a new integration)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Non-breaking change (fix of existing functionality that will not change current behavior)
  • [ ] Documentation (added/updated documentation)

All tests should be run against the port production environment(using a testing org).

Core testing checklist

  • [ ] Integration able to create all default resources from scratch
  • [ ] Resync finishes successfully
  • [ ] Resync able to create entities
  • [ ] Resync able to update entities
  • [ ] Resync able to detect and delete entities
  • [ ] Scheduled resync able to abort existing resync and start a new one
  • [ ] Tested with at least 2 integrations from scratch
  • [ ] Tested with Kafka and Polling event listeners
  • [ ] Tested deletion of entities that don't pass the selector

Integration testing checklist

  • [ ] Integration able to create all default resources from scratch
  • [ ] Resync able to create entities
  • [ ] Resync able to update entities
  • [ ] Resync able to detect and delete entities
  • [ ] Resync finishes successfully
  • [ ] If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the examples folder in the integration directory.
  • [ ] If resource kind is updated, run the integration with the example data and check if the expected result is achieved
  • [ ] If new resource kind is added or updated, validate that live-events for that resource are working as expected
  • [ ] Docs PR link here

Preflight checklist

  • [ ] Handled rate limiting
  • [ ] Handled pagination
  • [ ] Implemented the code in async
  • [ ] Support Multi account

Screenshots

Include screenshots from your environment showing how the resources of the integration will look.

API Documentation

Provide links to the API documentation used for this integration.

GitHub Pull Requests API:

Additional Notes

  • The pull request resource supports filtering by state (open, closed, all) via the selector configuration
  • Pull request webhooks provide real-time updates when PRs are opened, edited, closed, or reopened
  • Added comprehensive tests for both the exporter and webhook processor
  • Improved API flexibility by allowing separate repo_name and pr_number parameters in get_resource method

emekanwaoma avatar May 16 '25 08:05 emekanwaoma

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1635.d1ftd8v2gowp8w.amplifyapp.com

CI Feedback 🧐

(Feedback updated until commit https://github.com/port-labs/ocean/commit/4f314aa8c68423e4d2f58c2c1e24d7db4f011c9e)

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: build-integration (integrations/opsgenie/.port/spec.yaml, linux/arm64)

Failed stage: Build Docker Image [❌]

Failure summary:

The Docker build action failed due to multiple issues:
• Hash sum mismatch when fetching Debian
packages from https://d3h6m0qntaqq13.cloudfront.net/debian/dists/echohq/main/binary-all/Packages.gz
- expected SHA256 hash cdf6a464f8446362683b9c3c34f45c94ea150f31c65c6cffe427e0e4a0d18be8 but received
ee4515d5c6c3e6890ff8a1aa62b213ccd24947d5cb129c519f2a845e65af52f4
• The apt-get update command in
Dockerfile line 31-36 failed with exit code 100 due to package download failures
• Python 3.13 wheel
dependencies are unavailable during poetry installation (pip, setuptools, wheel wheels missing)

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

894:  #9 5.611   Hashes of expected file:
895:  #9 5.611    - Filesize:38927 [weak]
896:  #9 5.611    - SHA256:cdf6a464f8446362683b9c3c34f45c94ea150f31c65c6cffe427e0e4a0d18be8
897:  #9 5.611    - SHA1:0d02fba533ed7a5f51ed31279594a33d0b360069 [weak]
898:  #9 5.611    - MD5Sum:5cf9a211677e8329930c3e6b09f69f3d [weak]
899:  #9 5.611   Hashes of received file:
900:  #9 5.611    - SHA256:ee4515d5c6c3e6890ff8a1aa62b213ccd24947d5cb129c519f2a845e65af52f4
901:  #9 5.611    - SHA1:2226504e9d7c8765d061839ff011c428ac11f268 [weak]
902:  #9 5.612    - MD5Sum:5b816638f61ba7c92bb4e3edd5152483 [weak]
903:  #9 5.612    - Filesize:38927 [weak]
904:  #9 5.612   Last modification reported: Wed, 11 Jun 2025 13:09:08 +0000
905:  #9 5.612   Release file created at: Wed, 11 Jun 2025 12:55:46 +0000
906:  #9 5.749 Get:7 https://d3h6m0qntaqq13.cloudfront.net/debian echohq/main arm64 Packages [418 kB]
907:  #9 ...
908:  #11 [base 4/4] RUN poetry install --without dev --no-root --no-interaction --no-ansi --no-cache
909:  #11 8.172 fail
910:  #11 8.172 Traceback (most recent call last):
911:  #11 8.172   File "/usr/lib/python3/dist-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 82, in _get
912:  #11 8.172     result = get_wheel(
913:  #11 8.172              ^^^^^^^^^^
914:  #11 8.172   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/acquire.py", line 23, in get_wheel
915:  #11 8.172     wheel = from_bundle(distribution, version, for_py_version, search_dirs, app_data, do_periodic_update, env)
916:  #11 8.172             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
917:  #11 8.172   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
918:  #11 8.172     wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
919:  #11 8.172             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
920:  #11 8.172   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
921:  #11 8.172     wheel = get_embed_wheel(distribution, for_py_version)
922:  #11 8.172             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
923:  #11 8.172   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
924:  #11 8.172     raise Exception((
925:  #11 8.172 Exception: Wheel for pip for Python 3.13 is unavailable. apt install python3-pip-whl
926:  #11 8.176 fail
927:  #11 8.176 Traceback (most recent call last):
928:  #11 8.176   File "/usr/lib/python3/dist-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 82, in _get
929:  #11 8.176     result = get_wheel(
930:  #11 8.176              ^^^^^^^^^^
931:  #11 8.176   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/acquire.py", line 23, in get_wheel
932:  #11 8.176     wheel = from_bundle(distribution, version, for_py_version, search_dirs, app_data, do_periodic_update, env)
933:  #11 8.176             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
934:  #11 8.176   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
935:  #11 8.176     wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
936:  #11 8.176             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
937:  #11 8.176   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
938:  #11 8.176     wheel = get_embed_wheel(distribution, for_py_version)
939:  #11 8.176             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
940:  #11 8.176   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
941:  #11 8.176     raise Exception((
942:  #11 8.176 Exception: Wheel for setuptools for Python 3.13 is unavailable. apt install python3-setuptools-whl
943:  #11 8.180 fail
944:  #11 8.180 Traceback (most recent call last):
...

951:  #11 8.180   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
952:  #11 8.180     wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
953:  #11 8.180             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
954:  #11 8.180   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
955:  #11 8.180     wheel = get_embed_wheel(distribution, for_py_version)
956:  #11 8.180             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
957:  #11 8.180   File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
958:  #11 8.180     raise Exception((
959:  #11 8.180 Exception: Wheel for wheel for Python 3.13 is unavailable. apt install python3-wheel-whl
960:  #11 ...
961:  #9 [prod  3/10] RUN apt-get update     && apt-get install -y         ca-certificates         openssl         curl     && apt-get clean
962:  #9 17.22 Err:7 https://d3h6m0qntaqq13.cloudfront.net/debian echohq/main arm64 Packages
963:  #9 17.22   
964:  #9 17.36 Fetched 826 kB in 17s (49.7 kB/s)
965:  #9 17.36 Reading package lists...
966:  #9 27.51 E: Failed to fetch https://d3h6m0qntaqq13.cloudfront.net/debian/dists/echohq/main/binary-all/Packages.gz  Hash Sum mismatch
967:  #9 27.51    Hashes of expected file:
968:  #9 27.51     - Filesize:38927 [weak]
969:  #9 27.51     - SHA256:cdf6a464f8446362683b9c3c34f45c94ea150f31c65c6cffe427e0e4a0d18be8
970:  #9 27.51     - SHA1:0d02fba533ed7a5f51ed31279594a33d0b360069 [weak]
971:  #9 27.51     - MD5Sum:5cf9a211677e8329930c3e6b09f69f3d [weak]
972:  #9 27.51    Hashes of received file:
973:  #9 27.51     - SHA256:ee4515d5c6c3e6890ff8a1aa62b213ccd24947d5cb129c519f2a845e65af52f4
974:  #9 27.51     - SHA1:2226504e9d7c8765d061839ff011c428ac11f268 [weak]
975:  #9 27.51     - MD5Sum:5b816638f61ba7c92bb4e3edd5152483 [weak]
976:  #9 27.51     - Filesize:38927 [weak]
977:  #9 27.51    Last modification reported: Wed, 11 Jun 2025 13:09:08 +0000
978:  #9 27.51    Release file created at: Wed, 11 Jun 2025 12:55:46 +0000
979:  #9 27.51 E: Failed to fetch https://d3h6m0qntaqq13.cloudfront.net/debian/dists/echohq/main/binary-arm64/Packages.gz  
980:  #9 27.51 E: Some index files failed to download. They have been ignored, or old ones used instead.
981:  #9 ERROR: process "/bin/sh -c apt-get update     && apt-get install -y         ca-certificates         openssl         curl     && apt-get clean" did not complete successfully: exit code: 100
982:  #11 [base 4/4] RUN poetry install --without dev --no-root --no-interaction --no-ansi --no-cache
983:  #11 CANCELED
984:  ------
985:  > [prod  3/10] RUN apt-get update     && apt-get install -y         ca-certificates         openssl         curl     && apt-get clean:
986:  27.51     - MD5Sum:5cf9a211677e8329930c3e6b09f69f3d [weak]
987:  27.51    Hashes of received file:
988:  27.51     - SHA256:ee4515d5c6c3e6890ff8a1aa62b213ccd24947d5cb129c519f2a845e65af52f4
989:  27.51     - SHA1:2226504e9d7c8765d061839ff011c428ac11f268 [weak]
990:  27.51     - MD5Sum:5b816638f61ba7c92bb4e3edd5152483 [weak]
991:  27.51     - Filesize:38927 [weak]
992:  27.51    Last modification reported: Wed, 11 Jun 2025 13:09:08 +0000
993:  27.51    Release file created at: Wed, 11 Jun 2025 12:55:46 +0000
994:  27.51 E: Failed to fetch https://d3h6m0qntaqq13.cloudfront.net/debian/dists/echohq/main/binary-arm64/Packages.gz  
995:  27.51 E: Some index files failed to download. They have been ignored, or old ones used instead.
996:  ------
997:  WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
998:  Dockerfile:31
999:  --------------------
1000:  30 |     
1001:  31 | >>> RUN apt-get update \
1002:  32 | >>>     && apt-get install -y \
1003:  33 | >>>         ca-certificates \
1004:  34 | >>>         openssl \
1005:  35 | >>>         curl \
1006:  36 | >>>     && apt-get clean
1007:  37 |     
1008:  --------------------
1009:  ERROR: failed to solve: process "/bin/sh -c apt-get update     && apt-get install -y         ca-certificates         openssl         curl     && apt-get clean" did not complete successfully: exit code: 100
1010:  ##[group]Reference
1011:  builder-7d382613-1d0a-4013-9019-583f792e2bb3/builder-7d382613-1d0a-4013-9019-583f792e2bb30/wd79xn5rlgdd6s23niun7vnby
1012:  ##[endgroup]
1013:  ##[group]Check build summary support
1014:  Build summary supported!
1015:  ##[endgroup]
1016:  ##[error]buildx failed with: ERROR: failed to solve: process "/bin/sh -c apt-get update     && apt-get install -y         ca-certificates         openssl         curl     && apt-get clean" did not complete successfully: exit code: 100
1017:  Post job cleanup.
...

1037:  ##[endgroup]
1038:  Post job cleanup.
1039:  ##[group]Removing builder
1040:  [command]/usr/bin/docker buildx rm builder-7d382613-1d0a-4013-9019-583f792e2bb3
1041:  builder-7d382613-1d0a-4013-9019-583f792e2bb3 removed
1042:  ##[endgroup]
1043:  ##[group]Cleaning up certificates
1044:  ##[endgroup]
1045:  ##[group]Post cache
1046:  State not set
1047:  ##[endgroup]
1048:  Post job cleanup.
1049:  ##[group]Post cache
1050:  Caching docker.io--tonistiigi--binfmt-latest-linux-x64 to GitHub Actions cache
1051:  [command]/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/ocean/ocean --files-from manifest.txt --use-compress-program zstdmt
1052:  Failed to save: Unable to reserve cache with key docker.io--tonistiigi--binfmt-latest-linux-x64, another job may be creating this cache.
1053:  ##[endgroup]

qodo-code-review[bot] avatar Jun 04 '25 09:06 qodo-code-review[bot]

re-arrange test to be on par with implementation structure

mk-armah avatar Jun 05 '25 14:06 mk-armah

Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/15584100162/artifacts/3305003518

Code Coverage Total Percentage: 80.45%

github-actions[bot] avatar Jun 11 '25 12:06 github-actions[bot]

Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/15584221210/artifacts/3305054679

Code Coverage Total Percentage: 81.25%

github-actions[bot] avatar Jun 11 '25 12:06 github-actions[bot]