diff --git a/.circleci/config.yml b/.circleci/config.yml index 46e2166e..2920bc7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,94 +1,182 @@ -version: 2 +version: 2.1 + +orbs: + win: circleci/windows@1.0.0 + workflows: - version: 2 test: jobs: - - test-2.7 - - test-3.3 - - test-3.4 - - test-3.5 - - test-3.6 - - test-3.7 -test-template: &test-template - steps: - - checkout - - run: - name: install requirements - command: | - sudo pip install --upgrade pip virtualenv; - sudo pip install -r test-requirements.txt; - if [[ "$CIRCLE_JOB" != "test-3.3" ]]; then - sudo pip install -r test-filesource-optional-requirements.txt; - fi; - if [[ "$CIRCLE_JOB" != "test-3.3" ]] && [[ "$CIRCLE_JOB" != "test-3.4" ]]; then - sudo pip install -r consul-requirements.txt; - fi; - sudo python setup.py install; - pip freeze - - run: - name: run tests - command: | - mkdir test-reports; - if [[ "$CIRCLE_JOB" == "test-2.7" ]]; then - pytest -s --cov=ldclient --junitxml=test-reports/junit.xml testing; - sh -c '[ -n "${CODECLIMATE_REPO_TOKEN+1}" ] && codeclimate-test-reporter || echo "No CODECLIMATE_REPO_TOKEN value is set; not publishing coverage report"'; - else - pytest -s --junitxml=test-reports/junit.xml testing; - fi - - run: - name: test packaging/install - # Note, virtualenv isn't supported on Python 3.3 and this test requires virtualenv. But we - # never build our published package on 3.3 anyway. - command: | - if [[ "$CIRCLE_JOB" != "test-3.3" ]]; then - sudo rm -rf dist *.egg-info; - ./test-packaging/test-packaging.sh; - fi - - store_test_results: - path: test-reports - - store_artifacts: - path: test-reports + - test-linux: + name: Python 2.7 + docker-image: circleci/python:2.7-jessie + test-with-codeclimate: true # we only need to run CodeClimate in one job + - test-linux: + name: Python 3.3 + docker-image: circleci/python:3.3-jessie + consul-supported: false # Consul isn't supported in 3.3 + filesource-supported: false # FileDataSource isn't supported in 3.3 + test-packaging: false # packaging test requires virtualenv, which isn't supported in 3.3 + - test-linux: + name: Python 3.4 + docker-image: circleci/python:3.4-jessie + consul-supported: false # Consul isn't supported in 3.4 + - test-linux: + name: Python 3.5 + docker-image: circleci/python:3.5-jessie + - test-linux: + name: Python 3.6 + docker-image: circleci/python:3.6-jessie + - test-linux: + name: Python 3.7 + docker-image: circleci/python:3.7-stretch + - test-linux: + name: Python 3.8 + docker-image: circleci/python:3.8-buster + - test-windows: + name: Windows Py2.7 + py3: false + - test-windows: + name: Windows Py3.3 + py3: true jobs: - test-2.7: - <<: *test-template + test-linux: + parameters: + docker-image: + type: string + consul-supported: + type: boolean + default: true + filesource-supported: + type: boolean + default: true + test-packaging: + type: boolean + default: true + test-with-codeclimate: + type: boolean + default: false docker: - - image: circleci/python:2.7-jessie - - image: redis - - image: amazon/dynamodb-local - - image: consul - test-3.3: - <<: *test-template - docker: - - image: circleci/python:3.3-jessie - - image: redis - - image: amazon/dynamodb-local - # python-consul doesn't support Python 3.3 - test-3.4: - <<: *test-template - docker: - - image: circleci/python:3.4-jessie - - image: redis - - image: amazon/dynamodb-local - # python-consul doesn't support Python 3.4 - test-3.5: - <<: *test-template - docker: - - image: circleci/python:3.5-jessie - - image: redis - - image: amazon/dynamodb-local - - image: consul - test-3.6: - <<: *test-template - docker: - - image: circleci/python:3.6-jessie - - image: redis - - image: amazon/dynamodb-local - - image: consul - test-3.7: - <<: *test-template - docker: - - image: circleci/python:3.7-stretch + - image: <> - image: redis - image: amazon/dynamodb-local - image: consul + steps: + - checkout + - run: + name: install requirements + command: | + sudo pip install --upgrade pip virtualenv; + sudo pip install -r test-requirements.txt; + if [[ "<>" == "true" ]]; then + sudo pip install -r test-filesource-optional-requirements.txt; + fi; + if [[ "<>" == "true" ]]; then + sudo pip install -r consul-requirements.txt; + fi; + sudo python setup.py install; + pip freeze + - when: + condition: <> + steps: + - run: + name: run tests (with CodeClimate) + command: | + mkdir test-reports + pytest -s --cov=ldclient --junitxml=test-reports/junit.xml testing -W error::SyntaxWarning + sh -c '[ -n "${CODECLIMATE_REPO_TOKEN+1}" ] && codeclimate-test-reporter || echo "No CODECLIMATE_REPO_TOKEN value is set; not publishing coverage report"' + - unless: + condition: <> + steps: + - run: + name: run tests + command: | + mkdir test-reports + pytest -s --junitxml=test-reports/junit.xml testing -W error::SyntaxWarning + - when: + condition: <> + steps: + - run: + name: test packaging/install + command: | + sudo rm -rf dist *.egg-info + ./test-packaging/test-packaging.sh + - store_test_results: + path: test-reports + - store_artifacts: + path: test-reports + + test-windows: + executor: + name: win/vs2019 + shell: powershell.exe + parameters: + py3: + type: boolean + steps: + - checkout + - when: + condition: <> + steps: + - run: + name: install Python 3 + command: choco install python --no-progress + - unless: + condition: <> + steps: + - run: + name: install Python 2.7 + command: | + $ProgressPreference = "SilentlyContinue" # prevents console errors from CircleCI host + iwr -outf python-2.7.16.amd64.msi https://www.python.org/ftp/python/2.7.16/python-2.7.16.amd64.msi + Start-Process msiexec.exe -Wait -ArgumentList '/I python-2.7.16.amd64.msi /quiet' + - run: + name: set up DynamoDB + command: | + $ProgressPreference = "SilentlyContinue" + iwr -outf dynamo.zip https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip + mkdir dynamo + Expand-Archive -Path dynamo.zip -DestinationPath dynamo + cd dynamo + javaw -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar + background: true + - run: + name: set up Consul + command: | + $ProgressPreference = "SilentlyContinue" + iwr -outf consul.zip https://releases.hashicorp.com/consul/1.4.2/consul_1.4.2_windows_amd64.zip + mkdir consul + Expand-Archive -Path consul.zip -DestinationPath consul + cd consul + sc.exe create "Consul" binPath="$(Get-Location)/consul.exe agent -dev" + sc.exe start "Consul" + - run: + name: start Redis + command: | + $ProgressPreference = "SilentlyContinue" + iwr -outf redis.zip https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip + mkdir redis + Expand-Archive -Path redis.zip -DestinationPath redis + cd redis + ./redis-server --service-install + ./redis-server --service-start + Start-Sleep -s 5 + ./redis-cli ping + - run: + name: install requirements + command: | + $env:Path += ";C:\Python27\;C:\Python27\Scripts\" # has no effect if 2.7 isn't installed + python --version + pip install -r test-requirements.txt + pip install -r consul-requirements.txt + python setup.py install + - run: + name: run tests (2.7) + command: | + mkdir test-reports + $env:Path += ";C:\Python27\;C:\Python27\Scripts\" # has no effect if 2.7 isn't installed + python -m pytest -s --junitxml=test-reports/junit.xml testing; + - store_test_results: + path: test-reports + - store_artifacts: + path: test-reports diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index af1f3342..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,84 +0,0 @@ -jobs: - - job: build - pool: - vmImage: 'vs2017-win2016' - steps: - - task: PowerShell@2 - displayName: 'Setup Dynamo' - inputs: - targetType: inline - workingDirectory: $(System.DefaultWorkingDirectory) - script: | - iwr -outf dynamo.zip https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip - mkdir dynamo - Expand-Archive -Path dynamo.zip -DestinationPath dynamo - cd dynamo - javaw -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar - - task: PowerShell@2 - displayName: 'Setup Consul' - inputs: - targetType: inline - workingDirectory: $(System.DefaultWorkingDirectory) - script: | - iwr -outf consul.zip https://releases.hashicorp.com/consul/1.4.2/consul_1.4.2_windows_amd64.zip - mkdir consul - Expand-Archive -Path consul.zip -DestinationPath consul - cd consul - sc.exe create "Consul" binPath="$(System.DefaultWorkingDirectory)/consul/consul.exe agent -dev" - sc.exe start "Consul" - - task: PowerShell@2 - displayName: 'Setup Redis' - inputs: - targetType: inline - workingDirectory: $(System.DefaultWorkingDirectory) - script: | - iwr -outf redis.zip https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip - mkdir redis - Expand-Archive -Path redis.zip -DestinationPath redis - cd redis - ./redis-server --service-install - ./redis-server --service-start - - task: UsePythonVersion@0 - inputs: - versionSpec: '2.7' - addToPath: true - - task: PowerShell@2 - displayName: 'Setup SDK and Test 2.7' - inputs: - targetType: inline - workingDirectory: $(System.DefaultWorkingDirectory) - script: | - python --version - pip install -r test-requirements.txt - pip install -r consul-requirements.txt - python setup.py install - mkdir test-reports27 - python -m pytest -s --junitxml=test-reports27/junit.xml testing; - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.7' - addToPath: true - - task: PowerShell@2 - displayName: 'Setup SDK and Test 3.7' - inputs: - targetType: inline - workingDirectory: $(System.DefaultWorkingDirectory) - script: | - python --version - pip install -r test-requirements.txt - pip install -r consul-requirements.txt - python setup.py install - mkdir test-reports37 - python -m pytest -s --junitxml=test-reports37/junit.xml testing; - - task: CopyFiles@2 - inputs: - targetFolder: $(Build.ArtifactStagingDirectory)/test-reports27 - sourceFolder: $(System.DefaultWorkingDirectory)/test-reports27 - - task: CopyFiles@2 - inputs: - targetFolder: $(Build.ArtifactStagingDirectory)/test-reports37 - sourceFolder: $(System.DefaultWorkingDirectory)/test-reports37 - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: reports diff --git a/requirements.txt b/requirements.txt index 2e3cba6f..f941d6ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ backoff>=1.4.3 certifi>=2018.4.16 -expiringdict>=1.1.4 +expiringdict>=1.1.4,<1.2.0 six>=1.10.0 pyRFC3339>=1.0 semver>=2.7.9 diff --git a/testing/__init__.py b/testing/__init__.py index d2b1b498..0602017d 100644 --- a/testing/__init__.py +++ b/testing/__init__.py @@ -1,3 +1,6 @@ +import logging import os +logging.basicConfig(level=logging.WARN) + sdk_key = os.environ.get('LD_SDK_KEY') diff --git a/testing/test_init.py b/testing/test_init.py index 16d67b6c..ca13c130 100644 --- a/testing/test_init.py +++ b/testing/test_init.py @@ -3,7 +3,6 @@ import ldclient from ldclient import Config -logging.basicConfig(level=logging.DEBUG) mylogger = logging.getLogger()