Skip to content

Commit

Permalink
fix: v2 deployment fixes (#143)
Browse files Browse the repository at this point in the history
* Add --project-id to Cloud Run deployment

* Add GCR release

* Fix API Cloud Scheduler

* Update release yaml

* Update github workflow
  • Loading branch information
Olivier Cervello authored Jun 2, 2021
1 parent 2d48d61 commit 1f03ee2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 25 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/cloudbuild.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/rc-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: rc-release-version
on:
push:
branches:
- release-v*.*.*-rc*
jobs:
release-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Verify version is a release candidate"
run: |
cat "setup.py" | grep "version = .*-rc*"
- uses: actions/setup-python@master
with:
python-version: '3.x'
architecture: 'x64'

- name: Run all tests
run: make
env:
MIN_VALID_EVENTS: "10"
GOOGLE_APPLICATION_CREDENTIALS: tests/unit/fixtures/fake_credentials.json

- name: Release PyPI package
run: make deploy
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
release-gcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: Build Docker container and publish on GCR
run: make cloudbuild
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
21 changes: 18 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
tags:
- v*.*.*
jobs:
release-version:
release-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
- uses: actions/checkout@v2
- uses: actions/setup-python@master
with:
python-version: '3.x'
architecture: 'x64'
Expand All @@ -25,3 +25,18 @@ jobs:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
release-gcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: Build Docker container and publish on GCR
run: make cloudbuild
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ cloudrun:
--args=api \
--args=--signature-type="${SIGNATURE_TYPE}" \
--min-instances 1 \
--allow-unauthenticated
--allow-unauthenticated \
--project=${CLOUDRUN_PROJECT_ID}
3 changes: 1 addition & 2 deletions slo_generator/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ def run_compute(request):
# Get SLO config
if API_SIGNATURE_TYPE == 'http':
timestamp = None
data = str(request.get_json())
data = str(request.data.decode('utf-8'))
LOGGER.info('Loading SLO config from Flask request')
elif API_SIGNATURE_TYPE == 'cloudevent':
timestamp = int(
datetime.strptime(request["time"], TIME_FORMAT).timestamp())
data = base64.b64decode(request.data).decode('utf-8')
LOGGER.info(f'Loading SLO config from Cloud Event "{request["id"]}"')

slo_config = load_config(data)

# Get slo-generator config
Expand Down

0 comments on commit 1f03ee2

Please sign in to comment.