From 053db49d2a601e4cff870add9360e7f3a9ffb747 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 14:46:10 -0700 Subject: [PATCH 01/36] move query-valid-python-version to lib, add sanity check for SENTRY_PYTHON_VERSION mismatch --- scripts/ensure-venv.sh | 22 +--------------------- scripts/lib.sh | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/scripts/ensure-venv.sh b/scripts/ensure-venv.sh index 95dd859bd70575..ad0b3afebd41fb 100755 --- a/scripts/ensure-venv.sh +++ b/scripts/ensure-venv.sh @@ -12,8 +12,6 @@ if [[ "$SENTRY_NO_VIRTUALENV_CREATION" == "1" ]]; then exit 0 fi -venv_name=".venv" - die() { cat <&1 | awk '{print $2}') + if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then + cat <&1 | awk '{print $2}') minor=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\1/') patch=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\2/') @@ -62,13 +85,25 @@ query-valid-python-version() { # For Apple M1, we only allow 3.8 and at least patch version 10 if query-apple-m1; then if [ "$minor" -ne 8 ] || [ "$patch" -lt 10 ]; then + cat <= 3.8.10 < 3.9. +Either run "rm -rf ${venv_name} && direnv allow" to +OR set SENTRY_PYTHON_VERSION=${python_version} to an `.env` file to bypass this check." +EOF return 1 fi - # For everything else, we only allow 3.6 - elif [ "$minor" -ne 6 ]; then + elif [ "$minor" -ne 6 ] && [ "$minor" -ne 8 ]; then + cat < Date: Mon, 4 Oct 2021 14:47:08 -0700 Subject: [PATCH 02/36] remove sanity check since SENTRY_PYTHON_VERSION is only set if direnv succeeds; chicken egg --- scripts/lib.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index d7fd891fca478c..e43f4793723752 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -58,18 +58,6 @@ get-pyenv-version() { query-valid-python-version() { if [[ -n "$SENTRY_PYTHON_VERSION" ]]; then - python_version=$(python3 -V 2>&1 | awk '{print $2}') - if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then - cat < Date: Mon, 4 Oct 2021 14:55:41 -0700 Subject: [PATCH 03/36] Revert "remove sanity check since SENTRY_PYTHON_VERSION is only set if direnv succeeds; chicken egg" This reverts commit d69ad1e990f2bb42c6e57e54bdd820a5ba2484ec. --- scripts/lib.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/lib.sh b/scripts/lib.sh index e43f4793723752..d7fd891fca478c 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -58,6 +58,18 @@ get-pyenv-version() { query-valid-python-version() { if [[ -n "$SENTRY_PYTHON_VERSION" ]]; then + python_version=$(python3 -V 2>&1 | awk '{print $2}') + if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then + cat < Date: Mon, 4 Oct 2021 15:13:24 -0700 Subject: [PATCH 04/36] fix: let SENTRY_PYTHON_VERSION override get-pyenv-version --- scripts/lib.sh | 13 +++++++++---- scripts/pyenv_setup.sh | 11 ++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index d7fd891fca478c..65930b467355db 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -48,10 +48,15 @@ query-apple-m1() { } get-pyenv-version() { + if [[ -n "$SENTRY_PYTHON_VERSION" ]]; then + echo "${SENTRY_PYTHON_VERSION}" + return 0 + fi + local PYENV_VERSION PYENV_VERSION=3.6.13 if query-apple-m1; then - PYENV_VERSION=3.8.11 + PYENV_VERSION=3.8.12 fi echo "${PYENV_VERSION}" } @@ -62,7 +67,7 @@ query-valid-python-version() { if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then cat <= 3.8.10 < 3.9. Either run "rm -rf ${venv_name} && direnv allow" to OR set SENTRY_PYTHON_VERSION=${python_version} to an `.env` file to bypass this check." @@ -97,7 +102,7 @@ EOF elif [ "$minor" -ne 6 ] && [ "$minor" -ne 8 ]; then cat < Date: Mon, 4 Oct 2021 15:21:50 -0700 Subject: [PATCH 05/36] fix --- scripts/pyenv_setup.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/pyenv_setup.sh b/scripts/pyenv_setup.sh index 801eb56be093b0..ddf00f333f974e 100755 --- a/scripts/pyenv_setup.sh +++ b/scripts/pyenv_setup.sh @@ -96,13 +96,11 @@ install_pyenv() { if query-apple-m1; then pyenv install --skip-existing "${PYENV_VERSION}" - elif query-big-sur; then + elif query-big-sur && [ "${PYENV_VERSION}" = 3.6.10 ]; then # TODO(joshuarli): Can be removed when 3.6 is removed. - if [ "${PYENV_VERSION}" = 3.6.10 ]; then - curl -sSL https://github.com/python/cpython/commit/8ea6353.patch | \ - cat | \ - pyenv install --skip-existing --patch "${PYENV_VERSION}" - fi + curl -sSL https://github.com/python/cpython/commit/8ea6353.patch | \ + cat | \ + pyenv install --skip-existing --patch "${PYENV_VERSION}" else pyenv install --skip-existing "${PYENV_VERSION}" fi From d335fcfa1c9f3eec7698a4d29e6cf598e0b04c54 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 15:25:39 -0700 Subject: [PATCH 06/36] evan you happy now? --- scripts/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 65930b467355db..56e8bac120ba05 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -66,7 +66,7 @@ query-valid-python-version() { python_version=$(python3 -V 2>&1 | awk '{print $2}') if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then cat < Date: Mon, 4 Oct 2021 15:27:21 -0700 Subject: [PATCH 07/36] fix, lol --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ab3af633705e02..d770e16e2a00a6 100755 --- a/setup.py +++ b/setup.py @@ -7,11 +7,11 @@ if python_version < (3, 6): sys.exit(f"Error: Sentry requires at least Python 3.6 ({python_version})") -if python_version > (3, 6): +if python_version not in ((3, 6), (3, 8)): import logging logger = logging.getLogger() - logger.warning(f"A Python version different than 3.6 is being used ({python_version})") + logger.warning(f"A Python version different than 3.6 or 3.8 is being used ({python_version})") from distutils.command.build import build as BuildCommand From 9c3ecf130a52c6f1c2ed07d3e602ef8c1a6898eb Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 15:28:18 -0700 Subject: [PATCH 08/36] [skip ci] evan pls --- scripts/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 56e8bac120ba05..e276435b780e50 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -70,7 +70,7 @@ ${red}${bold} ERROR: You have explicitly set a non-recommended Python version (${SENTRY_PYTHON_VERSION}), but it doesn't match the value of python's version: ${python_version} You should create a new ${SENTRY_PYTHON_VERSION} virtualenv by running "rm -rf ${venv_name} && direnv allow". - ${reset} +${reset} EOF return 1 fi From e7277f31217b2e159b3d2d6daea1202e61f444fd Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 15:35:43 -0700 Subject: [PATCH 09/36] few small ci updates --- .github/file-filters.yml | 1 - .github/workflows/python-deps.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 1aaad19a23d3a8..0b3489a369a85c 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -43,7 +43,6 @@ backend_dependencies: &backend_dependencies backend_build_changes: &backend_build_changes - 'Makefile' - '.pre-commit-config.yaml' - - '.python-version' - '.github/workflows/!(js-*)' - '.github/actions/setup-sentry/action.yml' diff --git a/.github/workflows/python-deps.yml b/.github/workflows/python-deps.yml index 0a0e62667bb1bd..41d8689b9356e1 100644 --- a/.github/workflows/python-deps.yml +++ b/.github/workflows/python-deps.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [macos-11.0, ubuntu-20.04] - python-version: [3.6.13, 3.8.11] + python-version: [3.6.13, 3.8.12] fail-fast: false env: PIP_DISABLE_PIP_VERSION_CHECK: on From 633b824ce58b81a7f0d82247f0eeee2a58a0233e Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 15:38:36 -0700 Subject: [PATCH 10/36] go away unboundlocal --- scripts/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index e276435b780e50..ecea3a7cfa8df2 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -48,7 +48,7 @@ query-apple-m1() { } get-pyenv-version() { - if [[ -n "$SENTRY_PYTHON_VERSION" ]]; then + if [[ -n "${SENTRY_PYTHON_VERSION:-}" ]]; then echo "${SENTRY_PYTHON_VERSION}" return 0 fi @@ -62,7 +62,7 @@ get-pyenv-version() { } query-valid-python-version() { - if [[ -n "$SENTRY_PYTHON_VERSION" ]]; then + if [[ -n "${SENTRY_PYTHON_VERSION:-}" ]]; then python_version=$(python3 -V 2>&1 | awk '{print $2}') if [ "$python_version" != "$SENTRY_PYTHON_VERSION" ]; then cat < Date: Mon, 4 Oct 2021 15:45:05 -0700 Subject: [PATCH 11/36] is this going to be 2x2 instances? --- .github/workflows/backend-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index 22216af71d1fa5..075aed595b4cc2 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -13,6 +13,7 @@ jobs: timeout-minutes: 30 strategy: matrix: + python-version: [3.6.13, 3.8.12] instance: [0, 1] env: @@ -41,11 +42,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry if: steps.changes.outputs.backend == 'true' id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true From d7a4765b1d84969a5123190e89f3d6a3d5634d18 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 20:35:43 -0700 Subject: [PATCH 12/36] fix: can't use psycopg-binary 2.9.x in 3.8 with Django 2.2 --- requirements-base.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements-base.txt b/requirements-base.txt index 57869024b34940..044ae9938c258b 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -35,9 +35,7 @@ Pillow==8.2.0; python_version == '3.6' Pillow==8.3.1; python_version > '3.6' progressbar2==3.32.0 python-rapidjson==1.4 -psycopg2-binary==2.8.6; python_version == '3.6' -# For development only: This version removes needing to setting flags for Apple's M1 chipset -psycopg2-binary==2.9.1; python_version > '3.6' +psycopg2-binary==2.8.6 PyJWT==2.1.0 python-dateutil==2.8.1 python-memcached==1.59 From e563d44b10e2497c6ea168e64d07347946d6c59a Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 23:14:32 -0700 Subject: [PATCH 13/36] Revert "fix: can't use psycopg-binary 2.9.x in 3.8 with Django 2.2" This reverts commit d7a4765b1d84969a5123190e89f3d6a3d5634d18. --- requirements-base.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-base.txt b/requirements-base.txt index 044ae9938c258b..57869024b34940 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -35,7 +35,9 @@ Pillow==8.2.0; python_version == '3.6' Pillow==8.3.1; python_version > '3.6' progressbar2==3.32.0 python-rapidjson==1.4 -psycopg2-binary==2.8.6 +psycopg2-binary==2.8.6; python_version == '3.6' +# For development only: This version removes needing to setting flags for Apple's M1 chipset +psycopg2-binary==2.9.1; python_version > '3.6' PyJWT==2.1.0 python-dateutil==2.8.1 python-memcached==1.59 From f4ca150f241f4c75a6d7f943c2d481d6daac42a8 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 23:18:06 -0700 Subject: [PATCH 14/36] change to explicitly test only 3.6.13 for now, also adopt https://github.com/getsentry/sentry/pull/29042 --- .github/workflows/backend-test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index 075aed595b4cc2..c635a2b90324a8 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -10,11 +10,12 @@ jobs: test: name: backend test runs-on: ubuntu-20.04 - timeout-minutes: 30 + timeout-minutes: 20 strategy: matrix: - python-version: [3.6.13, 3.8.12] - instance: [0, 1] + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] + instance: [0, 1, 2] env: MIGRATIONS_TEST_MIGRATE: 1 From 391964b1511dd1d3ca338a4f117a196709021950 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 4 Oct 2021 23:33:52 -0700 Subject: [PATCH 15/36] python-version 3.6.13 matrix everywhere --- .github/workflows/acceptance.yml | 11 ++++++++--- .github/workflows/api-docs-test.yml | 10 +++++++--- .github/workflows/backend-lint.yml | 8 ++++++-- .github/workflows/backend-typing.yml | 9 +++++++-- .github/workflows/check-if-migration-is-required.yml | 7 ++++++- .github/workflows/command-line-test.yml | 7 ++++++- .github/workflows/development-environment.yml | 6 +++++- .github/workflows/migrations.yml | 7 ++++++- .github/workflows/plugins-test.yml | 7 ++++++- .github/workflows/relay-integration-test.yml | 8 ++++++-- .github/workflows/snuba-integration-test.yml | 6 ++++-- .github/workflows/symbolicator-integration-test.yml | 7 ++++++- 12 files changed, 73 insertions(+), 20 deletions(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 61023b26d6164c..cd9b72084d9b46 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -147,7 +147,8 @@ jobs: strategy: matrix: instance: [0, 1, 2, 3] - + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] env: VISUAL_SNAPSHOT_ENABLE: 1 TEST_GROUP_STRATEGY: roundrobin @@ -156,10 +157,11 @@ jobs: - name: Checkout sentry uses: actions/checkout@v2 - - name: Setup sentry python env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true @@ -207,6 +209,8 @@ jobs: timeout-minutes: 30 strategy: matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] instance: [0] env: VISUAL_SNAPSHOT_ENABLE: 1 @@ -218,10 +222,11 @@ jobs: # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891 fetch-depth: '2' - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} chartcuterie: true diff --git a/.github/workflows/api-docs-test.yml b/.github/workflows/api-docs-test.yml index c4ed8298ba4347..99213b90af07e6 100644 --- a/.github/workflows/api-docs-test.yml +++ b/.github/workflows/api-docs-test.yml @@ -1,11 +1,10 @@ name: api docs - on: push: branches: - master - pull_request: + # TODO(joshuarli): Confirm it passes on 3.8.12. branches: - master @@ -13,6 +12,10 @@ jobs: test: name: api docs test runs-on: ubuntu-20.04 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 @@ -26,11 +29,12 @@ jobs: - uses: volta-cli/action@v1 if: steps.changes.outputs.api_docs == 'true' - - name: Setup sentry python env + - name: Setup sentry python env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup if: steps.changes.outputs.api_docs == 'true' with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true diff --git a/.github/workflows/backend-lint.yml b/.github/workflows/backend-lint.yml index 13d9d5caea7fc5..ed0fdd77250588 100644 --- a/.github/workflows/backend-lint.yml +++ b/.github/workflows/backend-lint.yml @@ -10,7 +10,10 @@ jobs: name: backend lint runs-on: ubuntu-20.04 timeout-minutes: 10 - + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 @@ -37,10 +40,11 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup python + - name: Setup Python ${{ matrix.python-version }} uses: ./.github/actions/setup-python if: steps.changes.outputs.backend == 'true' with: + python-version: ${{ matrix.python-version }} # Note this uses a different cache key than other backend-based workflows because this workflows dependencies are different cache-files-hash: ${{ hashFiles('requirements-pre-commit.txt') }} diff --git a/.github/workflows/backend-typing.yml b/.github/workflows/backend-typing.yml index 8596072c24e617..377146428e9d12 100644 --- a/.github/workflows/backend-typing.yml +++ b/.github/workflows/backend-typing.yml @@ -10,7 +10,10 @@ jobs: name: backend typing runs-on: ubuntu-20.04 timeout-minutes: 12 - + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 @@ -29,9 +32,11 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup pip + - name: Setup Python ${{ matrix.python-version }} uses: ./.github/actions/setup-python if: steps.changes.outputs.backend == 'true' + with: + python-version: ${{ matrix.python-version }} # Since we don't call the setup-sentry action we need to install libxmlsec1-dev - name: Setup backend typing diff --git a/.github/workflows/check-if-migration-is-required.yml b/.github/workflows/check-if-migration-is-required.yml index 569103c360081c..1a1463e9c9a718 100644 --- a/.github/workflows/check-if-migration-is-required.yml +++ b/.github/workflows/check-if-migration-is-required.yml @@ -23,6 +23,10 @@ jobs: main: name: check migration runs-on: ubuntu-20.04 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] needs: [should-check] if: needs.should-check.outputs.changed == 'true' @@ -30,10 +34,11 @@ jobs: - name: Checkout sentry uses: actions/checkout@v2 - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} - name: Migration & lockfile checks diff --git a/.github/workflows/command-line-test.yml b/.github/workflows/command-line-test.yml index 0aab7d8a2fe4c7..886c2546138c20 100644 --- a/.github/workflows/command-line-test.yml +++ b/.github/workflows/command-line-test.yml @@ -10,6 +10,10 @@ jobs: name: cli test runs-on: ubuntu-20.04 timeout-minutes: 10 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 @@ -20,11 +24,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup if: steps.changes.outputs.backend == 'true' with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} - name: Run test diff --git a/.github/workflows/development-environment.yml b/.github/workflows/development-environment.yml index a1856120921660..0a53c8e40d6097 100644 --- a/.github/workflows/development-environment.yml +++ b/.github/workflows/development-environment.yml @@ -21,6 +21,8 @@ jobs: # Using Ubuntu 18 until I figure out this error: # -> ImportError: libffi.so.6: cannot open shared object file: No such file or directory os: [macos-11.0, ubuntu-18.04] + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] fail-fast: false env: PIP_DISABLE_PIP_VERSION_CHECK: on @@ -51,8 +53,10 @@ jobs: run: | make prerequisites - - name: Setup Python + - name: Setup Python ${{ matrix.python-version }} uses: ./.github/actions/setup-python + with: + python-version: ${{ matrix.python-version }} - name: Cache (pyenv) uses: actions/cache@v2 diff --git a/.github/workflows/migrations.yml b/.github/workflows/migrations.yml index c6d7bdb0b36998..3529b873d545fd 100644 --- a/.github/workflows/migrations.yml +++ b/.github/workflows/migrations.yml @@ -39,6 +39,10 @@ jobs: name: Generate SQL runs-on: ubuntu-20.04 timeout-minutes: 8 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] needs: did-migration-change if: ${{ needs.did-migration-change.outputs.added == 'true' }} @@ -48,10 +52,11 @@ jobs: with: ref: master - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} - name: Apply migrations diff --git a/.github/workflows/plugins-test.yml b/.github/workflows/plugins-test.yml index 02ca823ceb384b..bf48169ff8d299 100644 --- a/.github/workflows/plugins-test.yml +++ b/.github/workflows/plugins-test.yml @@ -11,6 +11,10 @@ jobs: name: plugins test runs-on: ubuntu-20.04 timeout-minutes: 10 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 @@ -21,11 +25,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup if: steps.changes.outputs.plugins == 'true' with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true diff --git a/.github/workflows/relay-integration-test.yml b/.github/workflows/relay-integration-test.yml index 2b12a260cb36d1..db3510b51ce44d 100644 --- a/.github/workflows/relay-integration-test.yml +++ b/.github/workflows/relay-integration-test.yml @@ -11,9 +11,12 @@ jobs: name: relay test runs-on: ubuntu-20.04 timeout-minutes: 10 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 - with: # Avoid codecov error message related to SHA resolution: # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891 @@ -26,11 +29,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup if: steps.changes.outputs.backend == 'true' with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true kafka: true diff --git a/.github/workflows/snuba-integration-test.yml b/.github/workflows/snuba-integration-test.yml index 53990eb4303aff..39dac2ba4ae36e 100644 --- a/.github/workflows/snuba-integration-test.yml +++ b/.github/workflows/snuba-integration-test.yml @@ -14,7 +14,8 @@ jobs: strategy: matrix: instance: [0, 1] - + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] env: USE_SNUBA: 1 MIGRATIONS_TEST_MIGRATE: 1 @@ -43,11 +44,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry if: steps.changes.outputs.backend == 'true' id: setup with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true kafka: true diff --git a/.github/workflows/symbolicator-integration-test.yml b/.github/workflows/symbolicator-integration-test.yml index 4c32ad9450c8b4..beefef8f4b652d 100644 --- a/.github/workflows/symbolicator-integration-test.yml +++ b/.github/workflows/symbolicator-integration-test.yml @@ -11,6 +11,10 @@ jobs: name: symbolicator test runs-on: ubuntu-20.04 timeout-minutes: 10 + strategy: + matrix: + # TODO(joshuarli): Add 3.8.12. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 with: @@ -25,11 +29,12 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - - name: Setup sentry env + - name: Setup sentry env (python ${{ matrix.python-version }}) uses: ./.github/actions/setup-sentry id: setup if: steps.changes.outputs.backend == 'true' with: + python-version: ${{ matrix.python-version }} pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true kafka: true From 08b218841a0cf1f5bb1e8ab0e7178193edc484b2 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 6 Oct 2021 12:32:34 -0700 Subject: [PATCH 16/36] add 3.8 --- .github/workflows/acceptance.yml | 6 ++---- .github/workflows/api-docs-test.yml | 3 +-- .github/workflows/backend-lint.yml | 3 +-- .github/workflows/backend-test.yml | 3 +-- .github/workflows/backend-typing.yml | 3 +-- .github/workflows/check-if-migration-is-required.yml | 3 +-- .github/workflows/command-line-test.yml | 3 +-- .github/workflows/development-environment.yml | 3 +-- .github/workflows/migrations.yml | 3 +-- .github/workflows/plugins-test.yml | 3 +-- .github/workflows/relay-integration-test.yml | 3 +-- .github/workflows/snuba-integration-test.yml | 3 +-- .github/workflows/symbolicator-integration-test.yml | 3 +-- 13 files changed, 14 insertions(+), 28 deletions(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index cd9b72084d9b46..6638e6e40c0263 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -147,8 +147,7 @@ jobs: strategy: matrix: instance: [0, 1, 2, 3] - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] env: VISUAL_SNAPSHOT_ENABLE: 1 TEST_GROUP_STRATEGY: roundrobin @@ -209,8 +208,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] instance: [0] env: VISUAL_SNAPSHOT_ENABLE: 1 diff --git a/.github/workflows/api-docs-test.yml b/.github/workflows/api-docs-test.yml index 99213b90af07e6..a2941fa6dfd29a 100644 --- a/.github/workflows/api-docs-test.yml +++ b/.github/workflows/api-docs-test.yml @@ -14,8 +14,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/backend-lint.yml b/.github/workflows/backend-lint.yml index ed0fdd77250588..7cb744af8ecda2 100644 --- a/.github/workflows/backend-lint.yml +++ b/.github/workflows/backend-lint.yml @@ -12,8 +12,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index c635a2b90324a8..22be64ffbecf9c 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -13,8 +13,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] instance: [0, 1, 2] env: diff --git a/.github/workflows/backend-typing.yml b/.github/workflows/backend-typing.yml index 377146428e9d12..51497d7d2af110 100644 --- a/.github/workflows/backend-typing.yml +++ b/.github/workflows/backend-typing.yml @@ -12,8 +12,7 @@ jobs: timeout-minutes: 12 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/check-if-migration-is-required.yml b/.github/workflows/check-if-migration-is-required.yml index 1a1463e9c9a718..4cb8b141db85dc 100644 --- a/.github/workflows/check-if-migration-is-required.yml +++ b/.github/workflows/check-if-migration-is-required.yml @@ -25,8 +25,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] needs: [should-check] if: needs.should-check.outputs.changed == 'true' diff --git a/.github/workflows/command-line-test.yml b/.github/workflows/command-line-test.yml index 886c2546138c20..979fecabfcd92f 100644 --- a/.github/workflows/command-line-test.yml +++ b/.github/workflows/command-line-test.yml @@ -12,8 +12,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/development-environment.yml b/.github/workflows/development-environment.yml index 0a53c8e40d6097..c7b7934fa7325b 100644 --- a/.github/workflows/development-environment.yml +++ b/.github/workflows/development-environment.yml @@ -21,8 +21,7 @@ jobs: # Using Ubuntu 18 until I figure out this error: # -> ImportError: libffi.so.6: cannot open shared object file: No such file or directory os: [macos-11.0, ubuntu-18.04] - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] fail-fast: false env: PIP_DISABLE_PIP_VERSION_CHECK: on diff --git a/.github/workflows/migrations.yml b/.github/workflows/migrations.yml index 3529b873d545fd..8485c4dab662fe 100644 --- a/.github/workflows/migrations.yml +++ b/.github/workflows/migrations.yml @@ -41,8 +41,7 @@ jobs: timeout-minutes: 8 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] needs: did-migration-change if: ${{ needs.did-migration-change.outputs.added == 'true' }} diff --git a/.github/workflows/plugins-test.yml b/.github/workflows/plugins-test.yml index bf48169ff8d299..fbd59c7441231a 100644 --- a/.github/workflows/plugins-test.yml +++ b/.github/workflows/plugins-test.yml @@ -13,8 +13,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/relay-integration-test.yml b/.github/workflows/relay-integration-test.yml index db3510b51ce44d..fe0895fbfc0139 100644 --- a/.github/workflows/relay-integration-test.yml +++ b/.github/workflows/relay-integration-test.yml @@ -13,8 +13,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/snuba-integration-test.yml b/.github/workflows/snuba-integration-test.yml index 39dac2ba4ae36e..7ee890e11df8aa 100644 --- a/.github/workflows/snuba-integration-test.yml +++ b/.github/workflows/snuba-integration-test.yml @@ -14,8 +14,7 @@ jobs: strategy: matrix: instance: [0, 1] - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] env: USE_SNUBA: 1 MIGRATIONS_TEST_MIGRATE: 1 diff --git a/.github/workflows/symbolicator-integration-test.yml b/.github/workflows/symbolicator-integration-test.yml index beefef8f4b652d..d52b5cd75267e3 100644 --- a/.github/workflows/symbolicator-integration-test.yml +++ b/.github/workflows/symbolicator-integration-test.yml @@ -13,8 +13,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - # TODO(joshuarli): Add 3.8.12. - python-version: [3.6.13] + python-version: [3.6.13, 3.8.12] steps: - uses: actions/checkout@v2 with: From eb8fa09bb2bdc19eb0778c360693c101ad0c715d Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 6 Oct 2021 12:35:39 -0700 Subject: [PATCH 17/36] make check titles consistent by making python version come first --- .github/workflows/acceptance.yml | 2 +- .github/workflows/snuba-integration-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 6638e6e40c0263..b437f56f0be075 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -146,8 +146,8 @@ jobs: timeout-minutes: 20 strategy: matrix: - instance: [0, 1, 2, 3] python-version: [3.6.13, 3.8.12] + instance: [0, 1, 2, 3] env: VISUAL_SNAPSHOT_ENABLE: 1 TEST_GROUP_STRATEGY: roundrobin diff --git a/.github/workflows/snuba-integration-test.yml b/.github/workflows/snuba-integration-test.yml index 096648dba3a587..c8c91894239cc4 100644 --- a/.github/workflows/snuba-integration-test.yml +++ b/.github/workflows/snuba-integration-test.yml @@ -13,8 +13,8 @@ jobs: timeout-minutes: 30 strategy: matrix: - instance: [0, 1] python-version: [3.6.13, 3.8.12] + instance: [0, 1] env: USE_SNUBA: 1 MIGRATIONS_TEST_MIGRATE: 1 From 28bb46faa56f822ea42fceea9175ef446e7899f2 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Fri, 8 Oct 2021 10:42:47 -0700 Subject: [PATCH 18/36] fix mypy --- src/sentry/utils/jwt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sentry/utils/jwt.py b/src/sentry/utils/jwt.py index dd2501e7a3a1fe..02c381fe02423c 100644 --- a/src/sentry/utils/jwt.py +++ b/src/sentry/utils/jwt.py @@ -137,6 +137,7 @@ def rsa_key_from_jwk(jwk: str) -> str: # The return type is verified in our own tests, this is fine. return key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption()).decode("UTF-8") # type: ignore elif isinstance(key, RSAPublicKey): - return key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode("UTF-8") + # The return type is verified in our own tests, this is fine. + return key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode("UTF-8") # type: ignore else: raise ValueError("Unknown RSA JWK key") From cf689e381d64b0e1b8dcfaa13efda3d8b3cb9a7e Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 14 Oct 2021 14:07:34 -0700 Subject: [PATCH 19/36] is dual visual snapshotting as easy as this --- src/sentry/utils/pytest/selenium.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/utils/pytest/selenium.py b/src/sentry/utils/pytest/selenium.py index b1de997f6e4954..2d470e96a4336c 100644 --- a/src/sentry/utils/pytest/selenium.py +++ b/src/sentry/utils/pytest/selenium.py @@ -320,7 +320,7 @@ def snapshot(self, name, mobile_only=False): if not os.path.exists(snapshot_dir): os.makedirs(snapshot_dir) - filename = slugify(name) + filename = slugify(f"{name}-py{sys.version_info[:3]}") # XXX: Unfortunately order matters here else snapshots in CI will be a tiny bit different. # Otherwise we could do mobile_viewport first and early return if mobile_only. From 2aae39702856f70ec0edb0256ef6de9767f227bf Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 14 Oct 2021 15:30:34 -0700 Subject: [PATCH 20/36] Revert "is dual visual snapshotting as easy as this" This reverts commit cf689e381d64b0e1b8dcfaa13efda3d8b3cb9a7e. --- src/sentry/utils/pytest/selenium.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/utils/pytest/selenium.py b/src/sentry/utils/pytest/selenium.py index 2d470e96a4336c..b1de997f6e4954 100644 --- a/src/sentry/utils/pytest/selenium.py +++ b/src/sentry/utils/pytest/selenium.py @@ -320,7 +320,7 @@ def snapshot(self, name, mobile_only=False): if not os.path.exists(snapshot_dir): os.makedirs(snapshot_dir) - filename = slugify(f"{name}-py{sys.version_info[:3]}") + filename = slugify(name) # XXX: Unfortunately order matters here else snapshots in CI will be a tiny bit different. # Otherwise we could do mobile_viewport first and early return if mobile_only. From bdc874a245af0767fd45fec63034e849bb1753c6 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 14 Oct 2021 15:36:38 -0700 Subject: [PATCH 21/36] only visual snapshot on 3.6 --- src/sentry/utils/pytest/selenium.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sentry/utils/pytest/selenium.py b/src/sentry/utils/pytest/selenium.py index b1de997f6e4954..7f6b4315a323db 100644 --- a/src/sentry/utils/pytest/selenium.py +++ b/src/sentry/utils/pytest/selenium.py @@ -304,7 +304,8 @@ def snapshot(self, name, mobile_only=False): """ # TODO(dcramer): ideally this would take the executing test package # into account for duplicate names - if os.environ.get("VISUAL_SNAPSHOT_ENABLE") != "1": + # TODO(josh): Change to 3.8 when it's deployed. Much easier to disable here than in GHA yml. + if os.environ.get("VISUAL_SNAPSHOT_ENABLE") != "1" or sys.version_info[:2] != (3, 6): return self self.wait_for_images_loaded() From 198b29caf10c76db727f0339eb7c187fe1dcccea Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 11:51:52 -0700 Subject: [PATCH 22/36] set warn_unused_ignores=False and get mypy to actually use config file --- Makefile | 2 +- mypy.ini | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4975119f607935..576c654fb2e8ba 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ test-snuba: backend-typing: @echo "--> Running Python typing checks" - mypy --strict --warn-unreachable --config-file mypy.ini + mypy --warn-unreachable --config-file mypy.ini @echo "" test-symbolicator: diff --git a/mypy.ini b/mypy.ini index 15f62c55140ad8..c895ce6e0ff356 100644 --- a/mypy.ini +++ b/mypy.ini @@ -79,10 +79,12 @@ check_untyped_defs=True disallow_untyped_decorators=True no_implicit_optional=True warn_redundant_casts=True -warn_unused_ignores=True warn_return_any=True no_implicit_reexport=True +; XXX(joshuarli): Toggle this when we're on Python 3.8. +warn_unused_ignores=False + ; Set this to skip until more of the codebase is typed follow_imports = skip From 5c9eacd0a124208cb8e5a34c51ee5af6949444b0 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 12:05:38 -0700 Subject: [PATCH 23/36] no idea why its being deselected --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 576c654fb2e8ba..048db921fe6653 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ test-symbolicator: test-chartcuterie: @echo "--> Running chartcuterie tests" - pytest tests/chartcuterie -vv --cov . --cov-report="xml:.artifacts/chartcuterie.coverage.xml" --junit-xml=".artifacts/chartcuterie.junit.xml" + pytest tests/chartcuterie/test_chart_renderer.py::TestChartRenderer::test_debug_renders -vv --cov . --cov-report="xml:.artifacts/chartcuterie.coverage.xml" --junit-xml=".artifacts/chartcuterie.junit.xml" @echo "" test-acceptance: node-version-check From 6ac87f6ef841be61775cf9b955bf6cad7b4f924f Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 13:30:15 -0700 Subject: [PATCH 24/36] Revert "no idea why its being deselected" This reverts commit 5c9eacd0a124208cb8e5a34c51ee5af6949444b0. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 048db921fe6653..576c654fb2e8ba 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ test-symbolicator: test-chartcuterie: @echo "--> Running chartcuterie tests" - pytest tests/chartcuterie/test_chart_renderer.py::TestChartRenderer::test_debug_renders -vv --cov . --cov-report="xml:.artifacts/chartcuterie.coverage.xml" --junit-xml=".artifacts/chartcuterie.junit.xml" + pytest tests/chartcuterie -vv --cov . --cov-report="xml:.artifacts/chartcuterie.coverage.xml" --junit-xml=".artifacts/chartcuterie.junit.xml" @echo "" test-acceptance: node-version-check From 369fce33035f5bcdc5c411a44eaac3b2ff42b8fb Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 13:42:13 -0700 Subject: [PATCH 25/36] debug --- src/sentry/utils/pytest/sentry.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sentry/utils/pytest/sentry.py b/src/sentry/utils/pytest/sentry.py index 527dc82fa8ca90..ad231bb47cbff2 100644 --- a/src/sentry/utils/pytest/sentry.py +++ b/src/sentry/utils/pytest/sentry.py @@ -309,12 +309,24 @@ def pytest_collection_modifyitems(config, items): # Split tests in different groups group_num = item_to_group % total_groups + print( # noqa + item.location, + grouping_strategy, + current_group, + total_groups, + item_to_group, + total_groups, + group_num, + ) if group_num == current_group: keep.append(item) else: discard.append(item) + print("keep:", keep) # noqa + print("discard:", discard) # noqa + # This only needs to be done if there are items to be de-selected if len(discard) > 0: items[:] = keep From 58cc93c1e71c8fd9cfe71c19bfcd671082d291c7 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 16:26:26 -0700 Subject: [PATCH 26/36] hacky fix --- .github/workflows/acceptance.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index b437f56f0be075..cd838bf4a230ab 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -211,6 +211,7 @@ jobs: python-version: [3.6.13, 3.8.12] instance: [0] env: + TEST_GROUP_STRATEGY: roundrobin VISUAL_SNAPSHOT_ENABLE: 1 steps: From dda38ab98817705f2cb2c1e5d78a1705822605a5 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 17:11:39 -0700 Subject: [PATCH 27/36] hardcode MATRIX_INSTANCE_TOTAL --- .github/actions/setup-sentry/action.yml | 15 ++++++++++++++- .github/workflows/acceptance.yml | 15 ++++++++++++--- .github/workflows/backend-test.yml | 5 ++++- .github/workflows/snuba-integration-test.yml | 5 ++++- src/sentry/utils/pytest/sentry.py | 12 ------------ 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.github/actions/setup-sentry/action.yml b/.github/actions/setup-sentry/action.yml index 350edb43c6706d..2cf26f6eeef859 100644 --- a/.github/actions/setup-sentry/action.yml +++ b/.github/actions/setup-sentry/action.yml @@ -54,6 +54,9 @@ outputs: matrix-instance-number: description: "The matrix instance number (starting at 1)" value: ${{ steps.config.outputs.matrix-instance-number }} + matrix-instance-total: + description: "Reexport of MATRIX_INSTANCE_TOTAL." + value: ${{ steps.config.outputs.matrix-instance-total }} runs: using: "composite" @@ -63,7 +66,10 @@ runs: env: NEED_KAFKA: ${{ inputs.kafka }} MATRIX_INSTANCE: ${{ matrix.instance }} - MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }} + # XXX: We should be using something like len(strategy.matrix.instance) (not possible atm) + # If you have other things like python-version: [foo, bar, baz] then the sharding logic + # isn't right because job-total will be 3x larger and you'd never run 2/3 of the tests. + # MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }} run: | # Only set `MIGRATIONS_TEST_MIGRATE` if it is not already set (or if it's an empty string) if [ -z $MIGRATIONS_TEST_MIGRATE ]; then @@ -81,11 +87,17 @@ runs: ### pytest-sentry configuration ### echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV + # this handles pytest test sharding if [ "$MATRIX_INSTANCE" ]; then + if [ "$MATRIX_INSTANCE_TOTAL" ] then; + echo "MATRIX_INSTANCE_TOTAL is required." + exit 1 + fi echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV fi + # This records failures on master to sentry in order to detect flakey tests, as it's # expected that people have failing tests on their PRs [ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true @@ -124,6 +136,7 @@ runs: run: | echo "::set-output name=yarn-cache-dir::$(yarn cache dir)" echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))" + echo "::set-output name=matrix-instance-total::$(($MATRIX_INSTANCE_TOTAL))" echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance" - name: Install python dependencies diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index cd838bf4a230ab..87bc76da519780 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -20,9 +20,12 @@ jobs: timeout-minutes: 20 strategy: matrix: + # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. instance: [0, 1] env: + # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + MATRIX_INSTANCE_TOTAL: 2 VISUAL_HTML_ENABLE: 1 steps: - uses: actions/checkout@v2 @@ -55,7 +58,7 @@ jobs: env: GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }} - CI_NODE_TOTAL: ${{ strategy.job-total }} + CI_NODE_TOTAL: ${{ steps.setup.outputs.matrix-instance-total }} CI_NODE_INDEX: ${{ matrix.instance }} run: | JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit @@ -147,8 +150,11 @@ jobs: strategy: matrix: python-version: [3.6.13, 3.8.12] + # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. instance: [0, 1, 2, 3] env: + # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + MATRIX_INSTANCE_TOTAL: 4 VISUAL_SNAPSHOT_ENABLE: 1 TEST_GROUP_STRATEGY: roundrobin @@ -181,7 +187,7 @@ jobs: run: | tar xf dist.tar.gz - - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }}) + - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) if: always() run: | mkdir -p ${{ steps.setup.outputs.acceptance-dir }} @@ -209,8 +215,11 @@ jobs: strategy: matrix: python-version: [3.6.13, 3.8.12] + # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. instance: [0] env: + # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + MATRIX_INSTANCE_TOTAL: 1 TEST_GROUP_STRATEGY: roundrobin VISUAL_SNAPSHOT_ENABLE: 1 @@ -243,7 +252,7 @@ jobs: run: | make build-chartcuterie-config - - name: Run chartcuterie tests (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }}) + - name: Run chartcuterie tests (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) run: | mkdir -p ${{ steps.setup.outputs.acceptance-dir }} make test-chartcuterie diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index 22be64ffbecf9c..d66822a2ece4fe 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -14,9 +14,12 @@ jobs: strategy: matrix: python-version: [3.6.13, 3.8.12] + # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. instance: [0, 1, 2] env: + # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + MATRIX_INSTANCE_TOTAL: 3 MIGRATIONS_TEST_MIGRATE: 1 steps: @@ -51,7 +54,7 @@ jobs: pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }} snuba: true - - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }}) + - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) if: steps.changes.outputs.backend == 'true' run: | # Note: `USE_SNUBA` is not used for backend tests because there are a few failing tests with Snuba enabled. diff --git a/.github/workflows/snuba-integration-test.yml b/.github/workflows/snuba-integration-test.yml index c8c91894239cc4..11d46fe1f157d8 100644 --- a/.github/workflows/snuba-integration-test.yml +++ b/.github/workflows/snuba-integration-test.yml @@ -14,8 +14,11 @@ jobs: strategy: matrix: python-version: [3.6.13, 3.8.12] + # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. instance: [0, 1] env: + # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + MATRIX_INSTANCE_TOTAL: 2 USE_SNUBA: 1 MIGRATIONS_TEST_MIGRATE: 1 USE_INDEXER: 1 @@ -53,7 +56,7 @@ jobs: snuba: true kafka: true - - name: Run snuba test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }}) + - name: Run snuba test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) if: steps.changes.outputs.backend == 'true' run: | make test-snuba diff --git a/src/sentry/utils/pytest/sentry.py b/src/sentry/utils/pytest/sentry.py index ad231bb47cbff2..527dc82fa8ca90 100644 --- a/src/sentry/utils/pytest/sentry.py +++ b/src/sentry/utils/pytest/sentry.py @@ -309,24 +309,12 @@ def pytest_collection_modifyitems(config, items): # Split tests in different groups group_num = item_to_group % total_groups - print( # noqa - item.location, - grouping_strategy, - current_group, - total_groups, - item_to_group, - total_groups, - group_num, - ) if group_num == current_group: keep.append(item) else: discard.append(item) - print("keep:", keep) # noqa - print("discard:", discard) # noqa - # This only needs to be done if there are items to be de-selected if len(discard) > 0: items[:] = keep From fe43c29f67ffcdde5f2cb9474e26cc3847ec9dfb Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 17:17:49 -0700 Subject: [PATCH 28/36] LOL --- .github/actions/setup-sentry/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-sentry/action.yml b/.github/actions/setup-sentry/action.yml index 2cf26f6eeef859..f7feed0112b6aa 100644 --- a/.github/actions/setup-sentry/action.yml +++ b/.github/actions/setup-sentry/action.yml @@ -90,7 +90,7 @@ runs: # this handles pytest test sharding if [ "$MATRIX_INSTANCE" ]; then - if [ "$MATRIX_INSTANCE_TOTAL" ] then; + if [ "$MATRIX_INSTANCE_TOTAL" ]; then echo "MATRIX_INSTANCE_TOTAL is required." exit 1 fi From f5014071df68950d4fa17f04b4477e29d825c179 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 17:26:01 -0700 Subject: [PATCH 29/36] lol 2 --- .github/actions/setup-sentry/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-sentry/action.yml b/.github/actions/setup-sentry/action.yml index f7feed0112b6aa..1281d16d36e470 100644 --- a/.github/actions/setup-sentry/action.yml +++ b/.github/actions/setup-sentry/action.yml @@ -90,7 +90,7 @@ runs: # this handles pytest test sharding if [ "$MATRIX_INSTANCE" ]; then - if [ "$MATRIX_INSTANCE_TOTAL" ]; then + if ! [ "$MATRIX_INSTANCE_TOTAL" ]; then echo "MATRIX_INSTANCE_TOTAL is required." exit 1 fi From f99d5830de30b1eb76a3ed8874e6ac1b445df660 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 18 Oct 2021 18:15:58 -0700 Subject: [PATCH 30/36] fix frontend tests --- .github/workflows/acceptance.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 87bc76da519780..e927707d4db3b0 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -25,6 +25,8 @@ jobs: env: # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + # XXX: Normally, sentry-setup reexports this as steps.setup.outputs.matrix-instance-total. + # But we need to also hardcode this in CI_NODE_TOTAL. MATRIX_INSTANCE_TOTAL: 2 VISUAL_HTML_ENABLE: 1 steps: @@ -58,7 +60,8 @@ jobs: env: GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }} - CI_NODE_TOTAL: ${{ steps.setup.outputs.matrix-instance-total }} + # XXX: CI_NODE_TOTAL must be equal to MATRIX_INSTANCE_TOTAL. + CI_NODE_TOTAL: 2 CI_NODE_INDEX: ${{ matrix.instance }} run: | JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit From d4238d7843ba55b6b4aaa60a031b0b0e9883b530 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 19 Oct 2021 09:17:28 -0700 Subject: [PATCH 31/36] MATRIX_INSTANCE_TOTAL isn't needed for this --- .github/workflows/acceptance.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index e927707d4db3b0..b825f601d63e94 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -20,14 +20,10 @@ jobs: timeout-minutes: 20 strategy: matrix: - # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL. + # XXX: When updating this, make sure you also update CI_NODE_TOTAL. instance: [0, 1] env: - # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance. - # XXX: Normally, sentry-setup reexports this as steps.setup.outputs.matrix-instance-total. - # But we need to also hardcode this in CI_NODE_TOTAL. - MATRIX_INSTANCE_TOTAL: 2 VISUAL_HTML_ENABLE: 1 steps: - uses: actions/checkout@v2 @@ -60,7 +56,9 @@ jobs: env: GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }} - # XXX: CI_NODE_TOTAL must be equal to MATRIX_INSTANCE_TOTAL. + # XXX: CI_NODE_TOTAL must be hardcoded to the length of strategy.matrix.instance. + # Otherwise, if there are other things in the matrix, using strategy.job-total + # wouldn't be correct. CI_NODE_TOTAL: 2 CI_NODE_INDEX: ${{ matrix.instance }} run: | From 483ab2e17804bdef17e8e3e8c81f3dcdc2553e4d Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 19 Oct 2021 09:22:45 -0700 Subject: [PATCH 32/36] dont run mypy on 3.8 --- .github/workflows/backend-typing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend-typing.yml b/.github/workflows/backend-typing.yml index 51497d7d2af110..bbd1379967bf45 100644 --- a/.github/workflows/backend-typing.yml +++ b/.github/workflows/backend-typing.yml @@ -12,7 +12,8 @@ jobs: timeout-minutes: 12 strategy: matrix: - python-version: [3.6.13, 3.8.12] + # TODO(joshuarli): Switch to 3.8.12 when we switch over to Python 3.8. + python-version: [3.6.13] steps: - uses: actions/checkout@v2 From 07c9b0ad76be4fa77f699f3ce3585a5fef35dea1 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 19 Oct 2021 10:13:19 -0700 Subject: [PATCH 33/36] Revert "fix mypy" This reverts commit 28bb46faa56f822ea42fceea9175ef446e7899f2. --- src/sentry/utils/jwt.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sentry/utils/jwt.py b/src/sentry/utils/jwt.py index 02c381fe02423c..dd2501e7a3a1fe 100644 --- a/src/sentry/utils/jwt.py +++ b/src/sentry/utils/jwt.py @@ -137,7 +137,6 @@ def rsa_key_from_jwk(jwk: str) -> str: # The return type is verified in our own tests, this is fine. return key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption()).decode("UTF-8") # type: ignore elif isinstance(key, RSAPublicKey): - # The return type is verified in our own tests, this is fine. - return key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode("UTF-8") # type: ignore + return key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode("UTF-8") else: raise ValueError("Unknown RSA JWK key") From b9099314dbf56c4d028ff5c47795ae98cd187a1c Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 19 Oct 2021 10:13:51 -0700 Subject: [PATCH 34/36] revert mypy changes --- Makefile | 2 +- mypy.ini | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 576c654fb2e8ba..4975119f607935 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ test-snuba: backend-typing: @echo "--> Running Python typing checks" - mypy --warn-unreachable --config-file mypy.ini + mypy --strict --warn-unreachable --config-file mypy.ini @echo "" test-symbolicator: diff --git a/mypy.ini b/mypy.ini index c895ce6e0ff356..4be3d96230e010 100644 --- a/mypy.ini +++ b/mypy.ini @@ -78,13 +78,11 @@ disallow_incomplete_defs=True check_untyped_defs=True disallow_untyped_decorators=True no_implicit_optional=True +warn_unused_ignores=True warn_redundant_casts=True warn_return_any=True no_implicit_reexport=True -; XXX(joshuarli): Toggle this when we're on Python 3.8. -warn_unused_ignores=False - ; Set this to skip until more of the codebase is typed follow_imports = skip From 1a94b1e1af00ea230de96d0491d39273e0175975 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 19 Oct 2021 16:55:19 -0700 Subject: [PATCH 35/36] lol --- .github/workflows/python-deps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-deps.yml b/.github/workflows/python-deps.yml index 41d8689b9356e1..dd6d2ffc4e2abe 100644 --- a/.github/workflows/python-deps.yml +++ b/.github/workflows/python-deps.yml @@ -45,6 +45,8 @@ jobs: run: | python -m venv .venv source .venv/bin/activate + # Force compilation of xmlsec wheel from source. + pip install --no-cache-dir --no-binary :all: 'xmlsec==1.3.12' make install-py-dev # This exercises the requirements-pre-commit.txt file make setup-git From 07b70d251aa0c19a72cd9a4f3440d05be77d9913 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 20 Oct 2021 11:43:40 -0700 Subject: [PATCH 36/36] Revert "lol" This reverts commit 1a94b1e1af00ea230de96d0491d39273e0175975. --- .github/workflows/python-deps.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/python-deps.yml b/.github/workflows/python-deps.yml index dd6d2ffc4e2abe..41d8689b9356e1 100644 --- a/.github/workflows/python-deps.yml +++ b/.github/workflows/python-deps.yml @@ -45,8 +45,6 @@ jobs: run: | python -m venv .venv source .venv/bin/activate - # Force compilation of xmlsec wheel from source. - pip install --no-cache-dir --no-binary :all: 'xmlsec==1.3.12' make install-py-dev # This exercises the requirements-pre-commit.txt file make setup-git