|
1 |
| -name: API Gateway integration tests with Pytest |
| 1 | +--- |
| 2 | +name: API Gateway integration tests |
2 | 3 |
|
3 | 4 | on:
|
4 | 5 | push:
|
|
10 | 11 | permissions:
|
11 | 12 | contents: read
|
12 | 13 |
|
13 |
| -env: |
14 |
| - GATEWAY_CHECKOUT_DIR: "gateway" |
15 |
| - S3_ENDPOINT: "https://s3.fr-par.scw.cloud" |
16 |
| - S3_REGION: "fr-par" |
17 |
| - |
18 |
| -defaults: |
19 |
| - run: |
20 |
| - shell: bash |
21 |
| - |
22 | 14 | jobs:
|
23 |
| - test-deployed-gateway: |
| 15 | + setup-gateway: |
24 | 16 | runs-on: self-hosted
|
25 |
| - container: python:3.11-bullseye |
| 17 | + container: python:3.11-bookworm |
26 | 18 | steps:
|
27 | 19 | - uses: actions/checkout@v3
|
28 | 20 |
|
29 |
| - - uses: ./.github/actions/setup-poetry |
30 |
| - |
31 |
| - - uses: actions/checkout@v3 |
| 21 | + - uses: scaleway/action-scw@v0.0.1 |
32 | 22 | with:
|
33 |
| - repository: scaleway/serverless-gateway |
34 |
| - path: ${{ env.GATEWAY_CHECKOUT_DIR }} |
35 |
| - |
36 |
| - - name: Install CLI and create config file |
37 |
| - uses: scaleway/action-scw@v0.0.1 |
38 |
| - with: |
39 |
| - version: v2.14.0 |
40 | 23 | access-key: ${{ secrets.SCW_ACCESS_KEY }}
|
41 | 24 | secret-key: ${{ secrets.SCW_SECRET_KEY }}
|
42 |
| - default-project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} |
43 |
| - default-organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} |
44 |
| - save-config: true |
| 25 | + project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} |
| 26 | + organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} |
45 | 27 |
|
46 |
| - - name: Install jq |
47 |
| - run: apt-get update && apt-get install -y jq |
| 28 | + - uses: ./.github/actions/setup-poetry |
48 | 29 |
|
49 |
| - - name: Create Gateway namespace |
50 |
| - working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }} |
| 30 | + - name: Create gateway database |
51 | 31 | run: |
|
52 |
| - make create-namespace |
53 |
| - until [ $(make check-namespace -s) == ready ]; do sleep 10; done |
| 32 | + poetry run scwgw create-db |
| 33 | + poetry run scwgw await-db |
54 | 34 |
|
55 |
| - - name: Create Gateway container |
56 |
| - working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }} |
57 |
| - # We need to truncate gateway.env as it will override our env vars |
| 35 | + - name: Create gateway namespace |
58 | 36 | run: |
|
59 |
| - truncate -s 0 gateway.env |
60 |
| - make create-container |
61 |
| - make deploy-container |
62 |
| - until [ $(make check-container -s) == ready ]; do sleep 10; done |
63 |
| - env: |
64 |
| - SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} |
65 |
| - SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} |
66 |
| - S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }} |
67 |
| - |
68 |
| - - name: Install s3cmd |
69 |
| - run: pip install s3cmd |
70 |
| - |
71 |
| - - name: Create S3 bucket |
72 |
| - working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }} |
| 37 | + poetry run scwgw create-namespace |
| 38 | + poetry run scwgw await-namespace |
| 39 | +
|
| 40 | + - name: Create gateway container |
73 | 41 | run: |
|
74 |
| - make set-up-s3-cli |
75 |
| - make create-s3-bucket |
76 |
| - env: |
77 |
| - S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }} |
| 42 | + poetry run scwgw create-containers |
| 43 | + poetry run scwgw await-containers |
| 44 | +
|
| 45 | + run-tests: |
| 46 | + needs: |
| 47 | + - setup-gateway |
| 48 | + runs-on: self-hosted |
| 49 | + container: python:3.11-bookworm |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v3 |
| 52 | + |
| 53 | + - uses: ./.github/actions/setup-cli |
| 54 | + with: |
| 55 | + access-key: ${{ secrets.SCW_ACCESS_KEY }} |
| 56 | + secret-key: ${{ secrets.SCW_SECRET_KEY }} |
| 57 | + project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} |
| 58 | + organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} |
| 59 | + |
| 60 | + - uses: ./.github/actions/setup-poetry |
78 | 61 |
|
79 | 62 | - name: Run integration tests
|
80 | 63 | run: |
|
81 |
| - pushd $GATEWAY_CHECKOUT_DIR |
82 |
| - export GATEWAY_HOST=$(make gateway-host -s) |
83 |
| - popd |
84 |
| - poetry run pytest tests/integrations/gateway -n $(nproc --all) |
85 |
| - env: |
86 |
| - SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} |
87 |
| - SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} |
88 |
| - GATEWAY_S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }} |
89 |
| - |
90 |
| - - name: Delete S3 bucket |
91 |
| - working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }} |
92 |
| - run: make delete-bucket |
93 |
| - env: |
94 |
| - S3_BUCKET_NAME: ${{ secrets.GATEWAY_S3_BUCKET_NAME }} |
95 |
| - if: always() |
96 |
| - |
97 |
| - - name: Delete Gateway namespace and container |
98 |
| - working-directory: ${{ env.GATEWAY_CHECKOUT_DIR }} |
99 |
| - run: make delete-namespace |
100 |
| - if: always() |
| 64 | + poetry run scwgw remote-config |
| 65 | + poetry run pytest integrations/gateway -n $(nproc --all) |
| 66 | +
|
| 67 | + teardown-gateway: |
| 68 | + runs-on: self-hosted |
| 69 | + container: python:3.11-bookworm |
| 70 | + needs: |
| 71 | + - run-tests |
| 72 | + |
| 73 | + # Tolerate errors if no resources found to clean up |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v3 |
| 78 | + |
| 79 | + - uses: ./.github/actions/setup-cli |
| 80 | + with: |
| 81 | + access-key: ${{ secrets.SCW_ACCESS_KEY }} |
| 82 | + secret-key: ${{ secrets.SCW_SECRET_KEY }} |
| 83 | + project-id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} |
| 84 | + organization-id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} |
| 85 | + |
| 86 | + - uses: ./.github/actions/setup-poetry |
| 87 | + |
| 88 | + - name: Delete namespace |
| 89 | + run: poetry run scwgw delete-namespace |
| 90 | + |
| 91 | + - name: Delete database |
| 92 | + run: poetry run scwgw delete-db |
0 commit comments