Skip to content

feat: update to new serverless gateway #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 43 additions & 71 deletions .github/workflows/integration-gateway.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: API Gateway integration tests with Pytest
---
name: API Gateway integration tests

on:
push:
Expand All @@ -10,91 +11,62 @@ on:
permissions:
contents: read

env:
GATEWAY_CHECKOUT_DIR: "gateway"
S3_ENDPOINT: "https://s3.fr-par.scw.cloud"
S3_REGION: "fr-par"

defaults:
run:
shell: bash

jobs:
test-deployed-gateway:
setup-gateway:
runs-on: self-hosted
container: python:3.11-bullseye
container: python:3.11-bookworm
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-poetry

- uses: actions/checkout@v3
with:
repository: scaleway/serverless-gateway
path: ${{ env.GATEWAY_CHECKOUT_DIR }}

- name: Install CLI and create config file
uses: scaleway/action-scw@v0.0.1
with:
version: v2.14.0
access-key: ${{ secrets.SCW_ACCESS_KEY }}
secret-key: ${{ secrets.SCW_SECRET_KEY }}
default-project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
default-organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
save-config: true

- name: Install jq
run: apt-get update && apt-get install -y jq

- name: Create Gateway namespace
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
run: |
make create-namespace
until [ $(make check-namespace -s) == ready ]; do sleep 10; done

- name: Create Gateway container
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
# We need to truncate gateway.env as it will override our env vars
run: |
truncate -s 0 gateway.env
make create-container
make deploy-container
until [ $(make check-container -s) == ready ]; do sleep 10; done
- name: Deploy Serverless Gateway
run: poetry run scwgw deploy
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}

- name: Install s3cmd
run: pip install s3cmd
run-tests:
needs:
- setup-gateway
runs-on: self-hosted
container: python:3.11-bookworm
steps:
- uses: actions/checkout@v3

- name: Create S3 bucket
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
run: |
make set-up-s3-cli
make create-s3-bucket
env:
S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}
- uses: ./.github/actions/setup-poetry

- name: Run integration tests
working-directory: tests
run: |
pushd $GATEWAY_CHECKOUT_DIR
export GATEWAY_HOST=$(make gateway-host -s)
popd
poetry run pytest tests/integrations/gateway -n $(nproc --all)
poetry run scwgw remote-config
poetry run pytest integrations/gateway -n $(nproc --all)
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
GATEWAY_S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}

- name: Delete S3 bucket
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
run: make delete-bucket
env:
S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}
if: always()
teardown-gateway:
runs-on: self-hosted
container: python:3.11-bookworm
needs:
- run-tests

- name: Delete Gateway namespace and container
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
run: make delete-namespace
if: always()
# Tolerate errors if no resources found to clean up
continue-on-error: true

steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-poetry

- name: Delete Serverless Gateway
run: poetry run scwgw delete -y
env:
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/pytest-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
test:
runs-on: self-hosted
container: python:3.11-bullseye
container: python:3.11-bookworm
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
jobs:
test:
runs-on: self-hosted
container: python:3.11-bullseye
container: python:3.11-bookworm
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
jobs:
deploy:
runs-on: self-hosted
container: python:3.11-bullseye
container: python:3.11-bookworm
steps:
- uses: actions/checkout@v3

Expand Down
Loading