|
| 1 | +name: Create and Test Cloud Pods |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # At 00:00 on Saturday. |
| 6 | + - cron: "0 0 * * 6" |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + actions: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + create-cloud-pod: |
| 18 | + name: Create Cloud Pods |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout Code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup Nodejs |
| 25 | + uses: actions/setup-node@v3 |
| 26 | + with: |
| 27 | + node-version: 22 |
| 28 | + cache: 'npm' |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + make install |
| 33 | +
|
| 34 | + - name: Start LocalStack |
| 35 | + uses: LocalStack/setup-localstack@main |
| 36 | + with: |
| 37 | + image-tag: 'latest' |
| 38 | + use-pro: 'true' |
| 39 | + configuration: LS_LOG=trace |
| 40 | + install-awslocal: 'true' |
| 41 | + env: |
| 42 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 43 | + |
| 44 | + - name: Deploy the application |
| 45 | + env: |
| 46 | + AWS_ACCESS_KEY_ID: test |
| 47 | + AWS_SECRET_ACCESS_KEY: test |
| 48 | + AWS_DEFAULT_REGION: us-east-1 |
| 49 | + run: | |
| 50 | + make build |
| 51 | + make bootstrap |
| 52 | + make deploy |
| 53 | +
|
| 54 | + - name: Create Cloud Pod |
| 55 | + env: |
| 56 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 57 | + run: | |
| 58 | + message="Cloud Pod created: sample-cdk-rds on $(date) with workflow run id: ${{ github.run_id }}" |
| 59 | + localstack pod save sample-cdk-rds --message "$message" |
| 60 | +
|
| 61 | + - name: Show LocalStack Logs |
| 62 | + if: always() |
| 63 | + run: | |
| 64 | + localstack logs |
| 65 | +
|
| 66 | + test-cloud-pod: |
| 67 | + name: Test Cloud Pod |
| 68 | + needs: create-cloud-pod |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - name: Checkout Code |
| 72 | + uses: actions/checkout@v4 |
| 73 | + |
| 74 | + - name: Setup Nodejs |
| 75 | + uses: actions/setup-node@v3 |
| 76 | + with: |
| 77 | + node-version: 22 |
| 78 | + cache: 'npm' |
| 79 | + |
| 80 | + - name: Start LocalStack |
| 81 | + uses: LocalStack/setup-localstack@main |
| 82 | + with: |
| 83 | + use-pro: 'true' |
| 84 | + install-awslocal: 'true' |
| 85 | + env: |
| 86 | + DEBUG: 1 |
| 87 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 88 | + |
| 89 | + - name: Load Cloud Pod |
| 90 | + env: |
| 91 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 92 | + run: | |
| 93 | + localstack pod load sample-cdk-rds |
| 94 | +
|
| 95 | + - name: Install dependencies |
| 96 | + run: | |
| 97 | + npm install |
| 98 | +
|
| 99 | + - name: Run Integration Tests |
| 100 | + run: | |
| 101 | + npm test |
| 102 | +
|
| 103 | + - name: Show LocalStack Logs |
| 104 | + if: always() |
| 105 | + run: | |
| 106 | + localstack logs |
| 107 | +
|
| 108 | + - name: Send a Slack notification |
| 109 | + if: failure() || github.event_name != 'pull_request' |
| 110 | + uses: ravsamhq/notify-slack-action@v2 |
| 111 | + with: |
| 112 | + status: ${{ job.status }} |
| 113 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + notification_title: "{workflow} has {status_message}" |
| 115 | + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" |
| 116 | + footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>" |
| 117 | + notify_when: "failure" |
| 118 | + env: |
| 119 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 120 | + |
| 121 | + - name: Generate a Diagnostic Report |
| 122 | + if: failure() |
| 123 | + run: | |
| 124 | + curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz |
| 125 | +
|
| 126 | + - name: Upload the Diagnostic Report |
| 127 | + if: failure() |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + with: |
| 130 | + name: diagnose.json.gz |
| 131 | + path: ./diagnose.json.gz |
0 commit comments