Skip to content

feat: add support for self hosted gateway #62

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 16 commits into from
Apr 6, 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
93 changes: 93 additions & 0 deletions .github/workflows/integration-gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: API Gateway integration tests with Pytest

on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read

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

jobs:
test-deployed-gateway:
runs-on: ubuntu-latest
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 Scaleway CLI
# Should point to GATEWAY_CHECKOUT_DIR but env is unusable here.
# See: https://docs.github.com/en/actions/learn-github-actions/contexts#env-context
uses: ./gateway/.github/actions/setup-scaleway-cli
with:
scw-version: "2.13.0"
scw-access-key: ${{ secrets.SCW_ACCESS_KEY }}
scw-secret-key: ${{ secrets.SCW_SECRET_KEY }}
scw-default-project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
scw-default-organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}

- 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
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}

- name: Install s3cmd
run: pip install s3cmd

- 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 }}

- name: Run integration tests
run: |
pushd $GATEWAY_CHECKOUT_DIR
export GATEWAY_HOST=$(make get-gateway-endpoint -s)
popd
poetry run pytest tests/integrations/gateway -n $(nproc --all)
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
GATEWAY_S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }}

- 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()

- name: Delete Gateway namespace and container
working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }}
run: make delete-namespace
if: always()
4 changes: 2 additions & 2 deletions .github/workflows/pytest-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
Expand All @@ -28,7 +28,7 @@ jobs:

- name: Test with pytest
working-directory: tests
run: poetry run pytest integrations -n $(nproc --all)
run: poetry run pytest integrations -n $(nproc --all) --ignore=integrations/gateway
env:
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
Expand Down
Loading