Integration Test #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Test | |
| on: | |
| push: | |
| paths-ignore: | |
| - 'README.md' | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| schedule: | |
| # "At 00:00 on Sunday." | |
| - cron: "0 0 * * 0" | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| name: Run Integration Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3' | |
| working-directory: demo/lambdas/ruby | |
| - name: Install lstk | |
| run: | | |
| npm install -g @localstack/lstk aws-cdk | |
| lstk setup aws | |
| - name: Install CDK dependencies | |
| run: cd cdk && npm ci | |
| - name: Bundle Ruby Lambda gems | |
| working-directory: demo/lambdas/ruby | |
| run: | | |
| bundle config set --local path vendor/bundle | |
| bundle install | |
| - name: Install Node.js Lambda dependencies | |
| run: cd demo/lambdas/nodejs && npm install --omit=dev | |
| - name: Start LocalStack | |
| env: | |
| LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | |
| run: | | |
| docker pull localstack/localstack-pro:latest | |
| LOCALSTACK_LS_LOG=trace lstk start | |
| - name: Bootstrap CDK | |
| working-directory: cdk | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_DEFAULT_REGION: us-east-1 | |
| run: lstk cdk bootstrap | |
| - name: Deploy CDK stack | |
| working-directory: cdk | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_DEFAULT_REGION: us-east-1 | |
| run: lstk cdk deploy LocalstackDemoStack --require-approval never | |
| - name: Upload frontend to S3 | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_DEFAULT_REGION: us-east-1 | |
| AWS_ENDPOINT_URL: http://localhost.localstack.cloud:4566 | |
| run: lstk aws s3 sync demo/web/ s3://archive-bucket/ | |
| - name: Run end-to-end test | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_DEFAULT_REGION: us-east-1 | |
| AWS_ENDPOINT_URL: http://localhost.localstack.cloud:4566 | |
| run: | | |
| echo "Discovering REST API ID..." | |
| apiId=$(lstk aws apigateway get-rest-apis --output json \ | |
| | jq -r '.items[] | select(.name=="localstack-demo") | .id') | |
| echo "API ID: $apiId" | |
| echo "Sending new request..." | |
| reqID=$(curl -sf -d '{}' \ | |
| "http://localhost:4566/_aws/execute-api/$apiId/local/requests" \ | |
| | jq -r .requestID) | |
| echo "Request ID: $reqID" | |
| echo "Polling for QUEUED -> PROCESSING -> FINISHED..." | |
| for i in $(seq 1 25); do | |
| cur=$(curl -sf \ | |
| "http://localhost:4566/_aws/execute-api/$apiId/local/requests" \ | |
| | jq -r "[.result[] | select(.requestID==\"$reqID\") | .status] | sort | last") | |
| echo " attempt $i: $cur" | |
| [ "$cur" = "FINISHED" ] && break | |
| sleep 3 | |
| done | |
| echo "Verifying S3 result file..." | |
| lstk aws s3 cp "s3://archive-bucket/$reqID/result.txt" - | grep -q "Archive result" \ | |
| && echo "✅ End-to-end test passed!" \ | |
| || (echo "❌ S3 result not found" && exit 1) | |
| - name: LocalStack logs (on failure) | |
| if: failure() | |
| run: lstk logs |