From 9870fdb0ecff083810942a54187f5add83cbfab1 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 09:08:23 -0700 Subject: [PATCH 1/6] DO NOT MERGE: testing CI lint rules --- src/sentry/api/urls.py | 5 +++++ static/app/utils/api/knownSentryApiUrls.generated.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/sentry/api/urls.py b/src/sentry/api/urls.py index 5e152b9f46643b..d3b873c7d4be6e 100644 --- a/src/sentry/api/urls.py +++ b/src/sentry/api/urls.py @@ -1907,6 +1907,11 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]: OrganizationIntegrationIssuesEndpoint.as_view(), name="sentry-api-0-organization-integration-issues", ), + re_path( + r"^(?P[^/]+)/integrations/(?P[^/]+)/channel-validate/$", + OrganizationIntegrationMigrateOpsgenieEndpoint.as_view(), + name="sentry-api-0-organization-integration-channel-validate", + ), re_path( r"^(?P[^/]+)/integrations/(?P[^/]+)/migrate-opsgenie/$", OrganizationIntegrationMigrateOpsgenieEndpoint.as_view(), diff --git a/static/app/utils/api/knownSentryApiUrls.generated.ts b/static/app/utils/api/knownSentryApiUrls.generated.ts index 2cdab59151b9ef..2e6a675855b5f2 100644 --- a/static/app/utils/api/knownSentryApiUrls.generated.ts +++ b/static/app/utils/api/knownSentryApiUrls.generated.ts @@ -275,6 +275,7 @@ export type KnownSentryApiUrls = | '/organizations/$organizationIdOrSlug/flags/signing-secrets/' | '/organizations/$organizationIdOrSlug/flags/signing-secrets/$signingSecretId/' | '/organizations/$organizationIdOrSlug/fork/' + | '/organizations/$organizationIdOrSlug/forwarding/' | '/organizations/$organizationIdOrSlug/group-search-views/' | '/organizations/$organizationIdOrSlug/group-search-views/$viewId/' | '/organizations/$organizationIdOrSlug/group-search-views/$viewId/starred/' @@ -347,6 +348,8 @@ export type KnownSentryApiUrls = | '/organizations/$organizationIdOrSlug/integration-requests/' | '/organizations/$organizationIdOrSlug/integrations/' | '/organizations/$organizationIdOrSlug/integrations/$integrationId/' + | '/organizations/$organizationIdOrSlug/integrations/$integrationId/channel-validate/' + | '/organizations/$organizationIdOrSlug/integrations/$integrationId/channels/' | '/organizations/$organizationIdOrSlug/integrations/$integrationId/issues/' | '/organizations/$organizationIdOrSlug/integrations/$integrationId/migrate-opsgenie/' | '/organizations/$organizationIdOrSlug/integrations/$integrationId/repos/' @@ -360,6 +363,7 @@ export type KnownSentryApiUrls = | '/organizations/$organizationIdOrSlug/issues-count/' | '/organizations/$organizationIdOrSlug/issues-metrics/' | '/organizations/$organizationIdOrSlug/issues-stats/' + | '/organizations/$organizationIdOrSlug/issues-timeseries/' | '/organizations/$organizationIdOrSlug/issues/' | '/organizations/$organizationIdOrSlug/issues/$issueId/' | '/organizations/$organizationIdOrSlug/issues/$issueId/activities/' @@ -625,6 +629,7 @@ export type KnownSentryApiUrls = | '/projects/$organizationIdOrSlug/$projectIdOrSlug/performance/configure/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/plugins/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/plugins/$pluginId/' + | '/projects/$organizationIdOrSlug/$projectIdOrSlug/preprod-artifact/rerun-analysis/$headArtifactId/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/preprodartifacts/$headArtifactId/build-details/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/preprodartifacts/$headArtifactId/delete/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/preprodartifacts/$headArtifactId/install-details/' @@ -697,6 +702,7 @@ export type KnownSentryApiUrls = | '/projects/$organizationIdOrSlug/$projectIdOrSlug/user-stats/' | '/projects/$organizationIdOrSlug/$projectIdOrSlug/users/' | '/projects/$organizationIdOrSlug/pr-comments/$repoName/$prNumber/' + | '/projects/$organizationIdOrSlug/pull-requests/size-analysis/$artifactId/' | '/projects/$organizationIdOrSlug/pullrequest-details/$repoName/$prNumber/' | '/prompts-activity/' | '/publickeys/relocations/' From 0ce091f1b8e3f82e4a989d966f9f32ab0ea6bc0a Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 09:44:02 -0700 Subject: [PATCH 2/6] try to run setup-sentry first, or to run the script as a CI step, not part of pre-commit --- .github/file-filters.yml | 3 +++ .github/workflows/backend.yml | 18 ++++++++++++++++++ .github/workflows/pre-commit.yml | 4 ++++ tools/api_urls_to_typescript.py | 16 +++++++++++++--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 5a5bb5b1c8685f..a8cb857a3ade48 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -47,6 +47,9 @@ backend_build_changes: &backend_build_changes - 'Makefile' - 'pyproject.toml' +backend_api_urls: &backend_api_urls + - '**/.urls.py' + # `backend_src` filters on files that are backend changes excluding # changes to the tests/ directory and changes to typescript related config files. # If you want to filter on *all* backend files, use the `backend_all` filter. diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index be2eb92e04944a..50af42bd79ecaf 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -27,6 +27,7 @@ jobs: api_docs: ${{ steps.changes.outputs.api_docs }} backend: ${{ steps.changes.outputs.backend_all }} backend_dependencies: ${{ steps.changes.outputs.backend_dependencies }} + backend_api_urls: ${{ steps.changes.outputs.backend_api_urls }} backend_any_type: ${{ steps.changes.outputs.backend_any_type }} migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }} steps: @@ -245,6 +246,23 @@ jobs: github-token: ${{ steps.token.outputs.token }} message: ':snowflake: re-freeze requirements' + api-url-typescript: + if: needs.files-changed.outputs.backend_api_urls == 'true' + needs: files-changed + name: api url typescript generation + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Setup sentry env + uses: ./.github/actions/setup-sentry + id: setup + + - name: Generate API URL TypeScirpt enums + run: | + python3 -m tools.api_urls_to_typescript + migration: if: needs.files-changed.outputs.migration_lockfile == 'true' needs: files-changed diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 15f55f5d4850fe..f733283bf51bc1 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -92,6 +92,10 @@ jobs: run: | pre-commit install-hooks + - name: 'Setup sentry env' + uses: ./.github/actions/setup-sentry + id: setup + - name: Run pre-commit on PR commits run: | jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | diff --git a/tools/api_urls_to_typescript.py b/tools/api_urls_to_typescript.py index cb47ba39b707fc..83691cd04fc4fe 100644 --- a/tools/api_urls_to_typescript.py +++ b/tools/api_urls_to_typescript.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # flake8: noqa: S002 import re @@ -155,12 +156,16 @@ def replace_named_group(match: re.Match[str]) -> str: return route -if __name__ == "__main__": +def main() -> int: import sys - from sentry.runner import configure + try: + from sentry.runner import configure - configure() + configure() + except ImportError: + # unable to import sentry.runner, so we're not in a sentry project + return 0 from sentry.api.urls import urlpatterns @@ -185,3 +190,8 @@ def replace_named_group(match: re.Match[str]) -> str: "\n".join([f" | '{r}'" for r in route_patterns]) + ";\n", ] ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From 7205597519453283d9306086d065f923c3e92a1f Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 09:48:46 -0700 Subject: [PATCH 3/6] Remove specific CI step, we can rely on pre-commit if we setup the env properly --- .github/file-filters.yml | 3 --- .github/workflows/backend.yml | 18 ------------------ tools/api_urls_to_typescript.py | 8 ++------ 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index a8cb857a3ade48..5a5bb5b1c8685f 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -47,9 +47,6 @@ backend_build_changes: &backend_build_changes - 'Makefile' - 'pyproject.toml' -backend_api_urls: &backend_api_urls - - '**/.urls.py' - # `backend_src` filters on files that are backend changes excluding # changes to the tests/ directory and changes to typescript related config files. # If you want to filter on *all* backend files, use the `backend_all` filter. diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 50af42bd79ecaf..be2eb92e04944a 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -27,7 +27,6 @@ jobs: api_docs: ${{ steps.changes.outputs.api_docs }} backend: ${{ steps.changes.outputs.backend_all }} backend_dependencies: ${{ steps.changes.outputs.backend_dependencies }} - backend_api_urls: ${{ steps.changes.outputs.backend_api_urls }} backend_any_type: ${{ steps.changes.outputs.backend_any_type }} migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }} steps: @@ -246,23 +245,6 @@ jobs: github-token: ${{ steps.token.outputs.token }} message: ':snowflake: re-freeze requirements' - api-url-typescript: - if: needs.files-changed.outputs.backend_api_urls == 'true' - needs: files-changed - name: api url typescript generation - runs-on: ubuntu-24.04 - timeout-minutes: 10 - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - name: Setup sentry env - uses: ./.github/actions/setup-sentry - id: setup - - - name: Generate API URL TypeScirpt enums - run: | - python3 -m tools.api_urls_to_typescript - migration: if: needs.files-changed.outputs.migration_lockfile == 'true' needs: files-changed diff --git a/tools/api_urls_to_typescript.py b/tools/api_urls_to_typescript.py index 83691cd04fc4fe..2fbb67e0a08269 100644 --- a/tools/api_urls_to_typescript.py +++ b/tools/api_urls_to_typescript.py @@ -159,13 +159,9 @@ def replace_named_group(match: re.Match[str]) -> str: def main() -> int: import sys - try: - from sentry.runner import configure + from sentry.runner import configure - configure() - except ImportError: - # unable to import sentry.runner, so we're not in a sentry project - return 0 + configure() from sentry.api.urls import urlpatterns From 9c2a014e7dfb483cccaad65a1aa0708120b360fb Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 11:54:12 -0700 Subject: [PATCH 4/6] run as backend step, and try mode: backend-ci to see if its faster --- .github/file-filters.yml | 3 +++ .github/workflows/backend.yml | 20 ++++++++++++++++++++ .github/workflows/pre-commit.yml | 2 ++ 3 files changed, 25 insertions(+) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 5a5bb5b1c8685f..ed77c971ced78e 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -47,6 +47,9 @@ backend_build_changes: &backend_build_changes - 'Makefile' - 'pyproject.toml' +backend_api_urls: &backend_api_urls + - '**/urls.py' + # `backend_src` filters on files that are backend changes excluding # changes to the tests/ directory and changes to typescript related config files. # If you want to filter on *all* backend files, use the `backend_all` filter. diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index be2eb92e04944a..156879279bde0c 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -27,6 +27,7 @@ jobs: api_docs: ${{ steps.changes.outputs.api_docs }} backend: ${{ steps.changes.outputs.backend_all }} backend_dependencies: ${{ steps.changes.outputs.backend_dependencies }} + backend_api_urls: ${{ steps.changes.outputs.backend_api_urls }} backend_any_type: ${{ steps.changes.outputs.backend_any_type }} migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }} steps: @@ -245,6 +246,25 @@ jobs: github-token: ${{ steps.token.outputs.token }} message: ':snowflake: re-freeze requirements' + api-url-typescript: + if: needs.files-changed.outputs.backend_api_urls == 'true' + needs: files-changed + name: api url typescript generation + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Setup sentry env + uses: ./.github/actions/setup-sentry + id: setup + with: + mode: backend-ci + + - name: Generate API URL TypeScirpt enums + run: | + python3 -m tools.api_urls_to_typescript + migration: if: needs.files-changed.outputs.migration_lockfile == 'true' needs: files-changed diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f733283bf51bc1..c884e1ed685916 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -95,6 +95,8 @@ jobs: - name: 'Setup sentry env' uses: ./.github/actions/setup-sentry id: setup + with: + mode: backend-ci - name: Run pre-commit on PR commits run: | From d8e9b5b0dc64986263047015324e6352bb5af6a9 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 12:01:30 -0700 Subject: [PATCH 5/6] switch from pre-commit to a normal CI step --- .github/workflows/backend.yml | 18 +++++++++++++++++- .github/workflows/pre-commit.yml | 6 ------ .pre-commit-config.yaml | 6 ------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 156879279bde0c..bd082512a3458c 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -253,6 +253,14 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: + - # get a non-default github token so that any changes are verified by CI + if: env.SECRET_ACCESS == 'true' + uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3.0.0 + id: token + with: + app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }} + private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }} + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup sentry env @@ -261,10 +269,18 @@ jobs: with: mode: backend-ci - - name: Generate API URL TypeScirpt enums + - name: Sync API Urls to TypeScirpt run: | python3 -m tools.api_urls_to_typescript + - name: Apply any file changes + # note: this runs "always" or else it's skipped when pre-commit fails + if: env.SECRET_ACCESS == 'true' && startsWith(github.ref, 'refs/pull') && always() + uses: getsentry/action-github-commit@31f6706ca1a7b9ad6d22c1b07bf3a92eabb05632 # v2.0.0 + with: + github-token: ${{ steps.token.outputs.token }} + message: ':hammer_and_wrench: Sync API Urls to TypeScirpt' + migration: if: needs.files-changed.outputs.migration_lockfile == 'true' needs: files-changed diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c884e1ed685916..15f55f5d4850fe 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -92,12 +92,6 @@ jobs: run: | pre-commit install-hooks - - name: 'Setup sentry env' - uses: ./.github/actions/setup-sentry - id: setup - with: - mode: backend-ci - - name: Run pre-commit on PR commits run: | jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 08514004902478..04aac4c911b468 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -135,12 +135,6 @@ repos: stages: [pre-push] entry: bash -c 'if [ -n "${SENTRY_KNIP_PRE_PUSH:-}" ]; then exec ./node_modules/.bin/knip; fi' -- - - id: gen-ts-api-urls - name: gen-ts-api-urls - language: system - files: /urls\.py$ - entry: python3 -m tools.api_urls_to_typescript - - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: From 40b5a693376dde7c0e982553f36e0b34f5c3a02c Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 16 Oct 2025 12:41:23 -0700 Subject: [PATCH 6/6] cleanup test stuff --- src/sentry/api/urls.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sentry/api/urls.py b/src/sentry/api/urls.py index d3b873c7d4be6e..5e152b9f46643b 100644 --- a/src/sentry/api/urls.py +++ b/src/sentry/api/urls.py @@ -1907,11 +1907,6 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]: OrganizationIntegrationIssuesEndpoint.as_view(), name="sentry-api-0-organization-integration-issues", ), - re_path( - r"^(?P[^/]+)/integrations/(?P[^/]+)/channel-validate/$", - OrganizationIntegrationMigrateOpsgenieEndpoint.as_view(), - name="sentry-api-0-organization-integration-channel-validate", - ), re_path( r"^(?P[^/]+)/integrations/(?P[^/]+)/migrate-opsgenie/$", OrganizationIntegrationMigrateOpsgenieEndpoint.as_view(),