|
| 1 | +name: Test Released Cloud Pods |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # “At 00:00 on Saturday.” |
| 6 | + - cron: "0 0 * * 6" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + get-releases: |
| 14 | + name: Retrieve Released Cloud Pods |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 18 | + steps: |
| 19 | + - id: set-matrix |
| 20 | + env: |
| 21 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + run: | |
| 23 | + output=$(gh api repos/$GITHUB_REPOSITORY/releases | jq -r '[.[] | select(.tag_name|startswith("v")|not) | .tag_name]') |
| 24 | + output=$(echo $output | tr '\n' ' ') |
| 25 | + echo "matrix=$output" >> $GITHUB_OUTPUT |
| 26 | + |
| 27 | + test-pod-release: |
| 28 | + needs: get-releases |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + tag: ${{ fromJson(needs.get-releases.outputs.matrix) }} |
| 34 | + steps: |
| 35 | + # checkout to run the tests later on |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v3 |
| 38 | + |
| 39 | + - name: Retrieve Pod |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + run: | |
| 43 | + # TODO the download url seems to follow the pattern $GITHUB_REPOSITORY/releases/download/{TAG}/{ASSET_NAME} |
| 44 | + # alternatively we can query the asset-id, and browser_download_url, but it seems like an overhead |
| 45 | + # asset_id=$(gh api repos/$GITHUB_REPOSITORY/releases/tags/latest | jq -r '.assets[]' | jq --arg DB $DB -c 'select(.name=="release-pod-\( $DB ).zip") | .id) |
| 46 | + # download_url=$(gh api repos/$GITHUB_REPOSITORY/releases/assets/$asset_id | jq -r ".browser_download_url") |
| 47 | + download_url="https://github.com/$GITHUB_REPOSITORY/releases/download/${{ matrix.tag }}/release-pod.zip" |
| 48 | + curl -L $download_url --output release-pod.zip |
| 49 | + ls -la |
| 50 | +
|
| 51 | + - name: Setup Python |
| 52 | + uses: actions/setup-python@v4 |
| 53 | + with: |
| 54 | + python-version: '3.9' |
| 55 | + |
| 56 | + - name: Start LocalStack |
| 57 | + env: |
| 58 | + DEBUG: 1 |
| 59 | + POD_LOAD_CLI_TIMEOUT: 300 |
| 60 | + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} |
| 61 | + run: | |
| 62 | + pip install localstack awscli-local[ver1] |
| 63 | + docker pull localstack/localstack-pro:${{ matrix.tag }} |
| 64 | + # Start LocalStack in the background |
| 65 | + localstack start -d |
| 66 | + # Wait 30 seconds for the LocalStack container to become ready before timing out |
| 67 | + echo "Waiting for LocalStack startup..." |
| 68 | + localstack wait -t 30 |
| 69 | + echo "Startup complete" |
| 70 | +
|
| 71 | + - name: Inject Pod |
| 72 | + run: | |
| 73 | + localstack pod load file://release-pod.zip |
| 74 | +
|
| 75 | + - name: Run Tests |
| 76 | + env: |
| 77 | + AWS_DEFAULT_REGION: us-east-1 |
| 78 | + AWS_REGION: us-east-1 |
| 79 | + AWS_ACCESS_KEY_ID: test |
| 80 | + AWS_SECRET_ACCESS_KEY: test |
| 81 | + run: | |
| 82 | + pip install -r requirements-dev.txt |
| 83 | + pytest tests |
| 84 | +
|
| 85 | + - name: Show Logs |
| 86 | + if: failure() |
| 87 | + run: | |
| 88 | + localstack logs |
| 89 | +
|
| 90 | + - name: Send a Slack notification |
| 91 | + if: failure() || github.event_name != 'pull_request' |
| 92 | + uses: ravsamhq/notify-slack-action@v2 |
| 93 | + with: |
| 94 | + status: ${{ job.status }} |
| 95 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + notification_title: "{workflow} has {status_message}" |
| 97 | + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" |
| 98 | + footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>" |
| 99 | + notify_when: "failure" |
| 100 | + env: |
| 101 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 102 | + |
| 103 | + - name: Prevent Workflows from getting Stale |
| 104 | + if: always() |
| 105 | + uses: gautamkrishnar/keepalive-workflow@v1 |
| 106 | + with: |
| 107 | + # this message should prevent automatic triggering of workflows |
| 108 | + # see https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs |
| 109 | + commit_message: "[skip ci] Automated commit by Keepalive Workflow to keep the repository active" |
0 commit comments