Browse Source

build(py2): Drop Python 2 support in CI (#22889)

We also switch away from using the `virtualenv` package to create virtual environments
and instead use the module `venv` (`python -m virtualenv .venv` vs `python -m venv .venv`)
Armen Zambrano G 4 years ago
parent
commit
aad39594c3

+ 1 - 8
.github/actions/setup-sentry/action.yml

@@ -1,10 +1,6 @@
 name: 'Sentry Setup'
 description: 'Sets up a Sentry test environment'
 inputs:
-  python:
-    description: 'python version (2 or 3)'
-    required: false
-    default: '3'
   snuba:
     description: 'Is snuba required?'
     required: false
@@ -34,7 +30,6 @@ runs:
     - name: Setup default environment variables
       shell: bash
       env:
-        PYTHON_VERSION: ${{ inputs.python }}
         NEED_KAFKA: ${{ inputs.kafka }}
         MATRIX_INSTANCE: ${{ matrix.instance }}
         MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
@@ -44,8 +39,6 @@ runs:
         echo "SENTRY_LIGHT_BUILD=1" >> $GITHUB_ENV
         echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
 
-        [ "$PYTHON_VERSION" = "2" ] && echo "SENTRY_PYTHON2=1" >> $GITHUB_ENV || true
-
         ### node configuration ###
         echo "NODE_ENV=development" >> $GITHUB_ENV
         echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
@@ -92,7 +85,7 @@ runs:
       shell: bash
       run: |
         python setup.py install_egg_info
-        pip install wheel # GitHub Actions does not have `wheel` installed by default (unlike Travis)
+        pip install wheel # GitHub Actions does not have `wheel` installed by default
         pip install -U -e ".[dev]"
 
         # pytest plugin used for better pytest failure annotations

+ 0 - 113
.github/workflows/acceptance-py3.6.yml

@@ -1,113 +0,0 @@
-name: acceptance [py3.6]
-on:
-  push:
-    branches:
-      - master
-      - releases/**
-  pull_request:
-
-jobs:
-  py3-acceptance:
-    name: python3.6 acceptance
-    runs-on: ubuntu-16.04
-    timeout-minutes: 20
-    strategy:
-      matrix:
-        instance: [0, 1, 2]
-
-    env:
-      MIGRATIONS_TEST_MIGRATE: 1
-      TEST_GROUP_STRATEGY: roundrobin
-
-    steps:
-      - uses: actions/checkout@v2
-
-      - uses: volta-cli/action@v1
-
-      # If we make these jobs "required" to merge on GH, then on every PR, GitHub automatically
-      # creates a status check in the "pending" state. This means that the workflow needs to run
-      # for every PR in order to update the status checks.
-      #
-      # In order to optimize CI usage, we want the tests to only run when python files change,
-      # since frontend changes should have no effect on these test suites. We cannot use GH workflow
-      # path filters because entire workflow would be skipped vs skipping individual jobs which
-      # would still allow this status check to pass.
-      - name: Check for python file changes
-        uses: getsentry/paths-filter@v2
-        id: changes
-        with:
-          token: ${{ github.token }}
-          filters: .github/file-filters.yml
-      # XXX: If taking snapshots with this, be sure to remove above and the following `if` conditions!
-
-      - name: Set python version output
-        id: python-version
-        if: steps.changes.outputs.backend == 'true'
-        run: |
-          echo "::set-output name=python-version::$(grep "3.6" .python-version)"
-
-      # Until GH composite actions can use `uses`, we need to setup python here
-      - uses: actions/setup-python@v2
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          python-version: ${{ steps.python-version.outputs.python-version }}
-
-      - name: Setup pip
-        uses: ./.github/actions/setup-pip
-        id: pip
-        if: steps.changes.outputs.backend == 'true'
-
-      - name: pip cache
-        uses: actions/cache@v2
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          path: ${{ steps.pip.outputs.pip-cache-dir }}
-          key: ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}-${{ hashFiles('**/requirements-*.txt') }}
-          restore-keys: |
-            ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}
-
-      - name: Setup sentry python env
-        uses: ./.github/actions/setup-sentry
-        id: setup
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          snuba: true
-
-      - name: yarn cache
-        uses: actions/cache@v2
-        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          path: ${{ steps.setup.outputs.yarn-cache-dir }}
-          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
-          restore-keys: |
-            ${{ runner.os }}-yarn-
-
-      - name: Install Javascript Dependencies
-        if: steps.changes.outputs.backend == 'true'
-        run: |
-          yarn install --frozen-lockfile
-
-      - name: webpack
-        if: steps.changes.outputs.backend == 'true'
-        env:
-          SENTRY_INSTRUMENTATION: 1
-          SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
-        run: |
-          yarn webpack --display errors-only
-
-      - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
-        if: steps.changes.outputs.backend == 'true'
-        run: |
-          mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
-          mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
-          mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
-          make run-acceptance
-        env:
-          PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
-          USE_SNUBA: 1
-
-      - name: Handle artifacts
-        uses: ./.github/actions/artifacts
-
-      # TODO(joshuarli): snapshots, visual-diff needs py3-acceptance.

+ 14 - 7
.github/workflows/acceptance.yml

@@ -71,8 +71,7 @@ jobs:
         uses: ./.github/actions/artifacts
 
   acceptance:
-    # TODO(joshuarli): Convert to py3 with snapshots. See other TODO as well.
-    name: python2.7 acceptance
+    name: acceptance
     runs-on: ubuntu-16.04
     timeout-minutes: 20
     strategy:
@@ -89,10 +88,15 @@ jobs:
 
       - uses: volta-cli/action@v1
 
+      - name: Set python version output
+        id: python-version
+        run: |
+          echo "::set-output name=python-version::$(cat .python-version)"
+
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2
         with:
-          python-version: 2.7.17
+          python-version: ${{ steps.python-version.outputs.python-version }}
 
       - name: Setup pip
         uses: ./.github/actions/setup-pip
@@ -102,18 +106,18 @@ jobs:
         uses: actions/cache@v2
         with:
           path: ${{ steps.pip.outputs.pip-cache-dir }}
-          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
+          key: ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}-${{ hashFiles('**/requirements-*.txt') }}
           restore-keys: |
             ${{ runner.os }}-pip-
 
-      - name: Setup sentry env
+      - name: Setup sentry python env
         uses: ./.github/actions/setup-sentry
         id: setup
         with:
-          python: 2
           snuba: true
 
-      - uses: actions/cache@v2
+      - name: yarn cache
+        uses: actions/cache@v2
         id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
         with:
           path: ${{ steps.setup.outputs.yarn-cache-dir }}
@@ -150,3 +154,6 @@ jobs:
         with:
           save-only: true
           snapshot-path: .artifacts/visual-snapshots
+
+      - name: Handle artifacts
+        uses: ./.github/actions/artifacts

+ 1 - 1
.github/workflows/api-docs-test.yml

@@ -30,7 +30,7 @@ jobs:
         id: python-version
         if: steps.changes.outputs.api_docs == 'true'
         run: |
-          echo "::set-output name=python-version::$(grep "3.6" .python-version)"
+          echo "::set-output name=python-version::$(cat .python-version)"
 
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2

+ 1 - 1
.github/workflows/backend-lint.yml

@@ -42,7 +42,7 @@ jobs:
         id: python-version
         if: steps.changes.outputs.backend == 'true'
         run: |
-          echo "::set-output name=python-version::$(grep "3.6" .python-version)"
+          echo "::set-output name=python-version::$(cat .python-version)"
 
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2

+ 0 - 72
.github/workflows/backend-test-py2.7.yml

@@ -1,72 +0,0 @@
-name: backend
-on:
-  push:
-    branches:
-      - master
-      - releases/**
-  pull_request:
-
-jobs:
-  test:
-    name: backend test
-    runs-on: ubuntu-16.04
-    timeout-minutes: 20
-    strategy:
-      matrix:
-        instance: [0, 1]
-
-    env:
-      MIGRATIONS_TEST_MIGRATE: 1
-
-    steps:
-      - uses: actions/checkout@v2
-
-      # If we make these jobs "required" to merge on GH, then on every PR, GitHub automatically
-      # creates a status check in the "pending" state. This means that the workflow needs to run
-      # for every PR in order to update the status checks.
-      #
-      # In order to optimize CI usage, we want the tests to only run when python files change,
-      # since frontend changes should have no effect on these test suites. We cannot use GH workflow
-      # path filters because entire workflow would be skipped vs skipping individual jobs which
-      # would still allow this status check to pass.
-      - name: Check for python file changes
-        uses: getsentry/paths-filter@v2
-        id: changes
-        with:
-          token: ${{ github.token }}
-          filters: .github/file-filters.yml
-
-      # Until GH composite actions can use `uses`, we need to setup python here
-      - uses: actions/setup-python@v2
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          python-version: 2.7.17
-
-      - name: Setup pip
-        uses: ./.github/actions/setup-pip
-        id: pip
-        if: steps.changes.outputs.backend == 'true'
-
-      - name: pip cache
-        uses: actions/cache@v2
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          path: ${{ steps.pip.outputs.pip-cache-dir }}
-          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
-          restore-keys: |
-            ${{ runner.os }}-pip-
-
-      - name: Setup sentry env
-        uses: ./.github/actions/setup-sentry
-        id: setup
-        if: steps.changes.outputs.backend == 'true'
-        with:
-          python: 2
-          snuba: true
-
-      - name: Run backend test [py2.7] (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-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.
-          unset USE_SNUBA
-          make test-python-ci

+ 4 - 4
.github/workflows/backend-test-py3.6.yml → .github/workflows/backend-test.yml

@@ -1,4 +1,4 @@
-name: backend [py3.6]
+name: backend
 on:
   push:
     branches:
@@ -8,7 +8,7 @@ on:
 
 jobs:
   test:
-    name: backend test py3.6
+    name: backend test
     runs-on: ubuntu-16.04
     timeout-minutes: 30
     strategy:
@@ -40,7 +40,7 @@ jobs:
         id: python-version
         if: steps.changes.outputs.backend == 'true'
         run: |
-          echo "::set-output name=python-version::$(grep "3.6" .python-version)"
+          echo "::set-output name=python-version::$(cat .python-version)"
 
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2
@@ -69,7 +69,7 @@ jobs:
         with:
           snuba: true
 
-      - name: Run backend test [py3.6] (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
+      - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-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.

+ 6 - 3
.github/workflows/check-if-migration-is-required.yml

@@ -14,10 +14,15 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
+      - name: Set python version output
+        id: python-version
+        run: |
+          echo "::set-output name=python-version::$(cat .python-version)"
+
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2
         with:
-          python-version: 2.7.17
+          python-version: ${{ steps.python-version.outputs.python-version }}
 
       - name: Setup pip
         uses: ./.github/actions/setup-pip
@@ -34,8 +39,6 @@ jobs:
       - name: Setup sentry env
         uses: ./.github/actions/setup-sentry
         id: setup
-        with:
-          python: 2
 
       - name: Check if a migration is required
         env:

+ 6 - 3
.github/workflows/command-line-test.yml

@@ -21,11 +21,16 @@ jobs:
           token: ${{ github.token }}
           filters: .github/file-filters.yml
 
+      - name: Set python version output
+        id: python-version
+        run: |
+          echo "::set-output name=python-version::$(cat .python-version)"
+
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2
         if: steps.changes.outputs.backend == 'true'
         with:
-          python-version: 2.7.17
+          python-version: ${{ steps.python-version.outputs.python-version }}
 
       - name: Setup pip
         uses: ./.github/actions/setup-pip
@@ -45,8 +50,6 @@ jobs:
         uses: ./.github/actions/setup-sentry
         id: setup
         if: steps.changes.outputs.backend == 'true'
-        with:
-          python: 2
 
       - name: Run test
         if: steps.changes.outputs.backend == 'true'

+ 6 - 3
.github/workflows/migrations.yml

@@ -16,10 +16,15 @@ jobs:
         with:
           ref: master
 
+      - name: Set python version output
+        id: python-version
+        run: |
+          echo "::set-output name=python-version::$(cat .python-version)"
+
       # Until GH composite actions can use `uses`, we need to setup python here
       - uses: actions/setup-python@v2
         with:
-          python-version: 2.7.17
+          python-version: ${{ steps.python-version.outputs.python-version }}
 
       - name: Setup pip
         uses: ./.github/actions/setup-pip
@@ -36,8 +41,6 @@ jobs:
       - name: Setup sentry env
         uses: ./.github/actions/setup-sentry
         id: setup
-        with:
-          python: 2
 
       - name: Apply migrations
         run: |

Some files were not shown because too many files changed in this diff