diff --git a/drone/.drone.jsonnet b/drone/.drone.jsonnet index f83be07222..ad3cbcd074 100644 --- a/drone/.drone.jsonnet +++ b/drone/.drone.jsonnet @@ -121,6 +121,29 @@ local sanity_check = { depends_on: ['build'], }; +local start_locally = { + name: 'start-locally', + image: 'alpine', + commands: ['./fake-gcs-server -backend memory -data $PWD/examples/data'], + detach: true, + depends_on: ['build'], +}; + +local test_python_script = { + name: 'test-python-example', + image: 'python:3', + pull: 'always', + commands: [ + 'pip install -r examples/python/requirements.txt', + 'python examples/python/python.py', + ], + environment: { + EXTERNAL_URL: 'https://start-locally:4443', + PUBLIC_HOST: 'start-locally:4443', + }, + depends_on: ['start-locally'], +}; + local test_ci_dockerfile = { name: 'test-ci-dockerfile', image: 'plugins/docker', @@ -148,6 +171,8 @@ local pipeline(go_version) = { lint, build(go_version), sanity_check, + start_locally, + test_python_script, test_ci_dockerfile, ] + if go_version == go_versions[0] then release_steps else [], }; diff --git a/drone/.drone.yml b/drone/.drone.yml index 9a5808f600..ad388669b2 100644 --- a/drone/.drone.yml +++ b/drone/.drone.yml @@ -51,6 +51,26 @@ steps: depends_on: - build +- name: start-locally + image: alpine + detach: true + commands: + - ./fake-gcs-server -backend memory -data $PWD/examples/data + depends_on: + - build + +- name: test-python-example + pull: always + image: python:3 + commands: + - pip install -r examples/python/requirements.txt + - python examples/python/python.py + environment: + EXTERNAL_URL: https://start-locally:4443 + PUBLIC_HOST: start-locally:4443 + depends_on: + - start-locally + - name: test-ci-dockerfile image: plugins/docker settings: @@ -195,6 +215,26 @@ steps: depends_on: - build +- name: start-locally + image: alpine + detach: true + commands: + - ./fake-gcs-server -backend memory -data $PWD/examples/data + depends_on: + - build + +- name: test-python-example + pull: always + image: python:3 + commands: + - pip install -r examples/python/requirements.txt + - python examples/python/python.py + environment: + EXTERNAL_URL: https://start-locally:4443 + PUBLIC_HOST: start-locally:4443 + depends_on: + - start-locally + - name: test-ci-dockerfile image: plugins/docker settings: @@ -260,6 +300,26 @@ steps: depends_on: - build +- name: start-locally + image: alpine + detach: true + commands: + - ./fake-gcs-server -backend memory -data $PWD/examples/data + depends_on: + - build + +- name: test-python-example + pull: always + image: python:3 + commands: + - pip install -r examples/python/requirements.txt + - python examples/python/python.py + environment: + EXTERNAL_URL: https://start-locally:4443 + PUBLIC_HOST: start-locally:4443 + depends_on: + - start-locally + - name: test-ci-dockerfile image: plugins/docker settings: diff --git a/examples/python/python.py b/examples/python/python.py index 665d683a9e..67de21361c 100644 --- a/examples/python/python.py +++ b/examples/python/python.py @@ -2,13 +2,15 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +import os + import requests import urllib3 from google.auth.credentials import AnonymousCredentials from google.cloud import storage -EXTERNAL_URL = "https://127.0.0.1:4443" -PUBLIC_HOST = "storage.gcs.127.0.0.1.nip.io:4443" +EXTERNAL_URL = os.getenv("EXTERNAL_URL", "https://127.0.0.1:4443") +PUBLIC_HOST = os.getenv("PUBLIC_HOST", "storage.gcs.127.0.0.1.nip.io:4443") storage._http.Connection.API_BASE_URL = ( EXTERNAL_URL