Repository navigation
162 lines (142 loc) · 5.1 KB
/
Copy pathtest.yml
File metadata and controls
162 lines (142 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Sample Tests
on:
push:
paths-ignore:
- '**.md'
branches:
- main
pull_request:
branches:
- main
schedule:
# “At 00:00 on Sunday.”
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
prepare-list:
name: Find testable samples
runs-on: ubuntu-latest
outputs:
scripts: ${{ steps.set-matrix.outputs.scripts }}
make: ${{ steps.set-matrix.outputs.make }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
# Samples with scripts/deploy.sh and scripts/test.sh.
# glue-etl-jobs is skipped for now: Glue tries an SSL connection to RDS first, and an
# aborted TLS handshake stops the LocalStack Postgres proxy for that cluster.
mapfile -t scripts < <(find . -path '*/scripts/test.sh' | xargs -n1 dirname | xargs -n1 dirname | sed 's|^\./||' | grep -v '^glue-etl-jobs/' | sort)
# Samples with a Makefile test-ci target
mapfile -t make < <(grep -l '^test-ci:' */Makefile | xargs -n1 dirname | sort)
echo "scripts=$(printf '%s\n' "${scripts[@]}" | jq -R . | jq -cs .)" >> "$GITHUB_OUTPUT"
echo "make=$(printf '%s\n' "${make[@]}" | jq -R . | jq -cs .)" >> "$GITHUB_OUTPUT"
script-samples:
name: Test ${{ matrix.directory }}
runs-on: ubuntu-latest
needs: prepare-list
strategy:
fail-fast: false
max-parallel: 8
matrix:
directory: ${{ fromJSON(needs.prepare-list.outputs.scripts) }}
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install tools
run: |
pip install awscli-local uv
npm install -g @localstack/lstk
# The runner ships AWS CLI v2, which treats blob parameters as base64 by default
aws configure set cli_binary_format raw-in-base64-out
- name: Start LocalStack
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
run: lstk start
- name: Deploy
timeout-minutes: 15
working-directory: ${{ matrix.directory }}
run: bash scripts/deploy.sh
- name: Test
timeout-minutes: 10
working-directory: ${{ matrix.directory }}
run: bash scripts/test.sh
- name: Show LocalStack logs
if: failure()
run: lstk logs
- name: Send a Slack notification
if: failure() || github.event_name != 'pull_request'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "Sample `${{ matrix.directory }}` ({workflow}) has {status_message}"
message_format: "{emoji} *${{ matrix.directory }}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
make-samples:
name: Test ${{ matrix.directory }}
runs-on: ubuntu-latest
needs: prepare-list
strategy:
fail-fast: false
max-parallel: 8
matrix:
directory: ${{ fromJSON(needs.prepare-list.outputs.make) }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: '1.14.9'
terraform_wrapper: false
- name: Install tools
run: |
pip install localstack awscli-local[ver1] aws-sam-cli-local virtualenv
npm install -g @localstack/lstk
- name: Run make test-ci
timeout-minutes: 30
working-directory: ${{ matrix.directory }}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
run: make test-ci
- name: Upload LocalStack logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.directory }}
path: ${{ matrix.directory }}/logs.txt
if-no-files-found: ignore
- name: Send a Slack notification
if: failure() || github.event_name != 'pull_request'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "Sample `${{ matrix.directory }}` ({workflow}) has {status_message}"
message_format: "{emoji} *${{ matrix.directory }}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}