Skip to content

Commit

Permalink
drone: test the example script
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Aug 7, 2019
1 parent 665a60f commit f800030
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
25 changes: 25 additions & 0 deletions drone/.drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 [],
};
Expand Down
60 changes: 60 additions & 0 deletions drone/.drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions examples/python/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f800030

Please sign in to comment.