-
Notifications
You must be signed in to change notification settings - Fork 1.1k
67 lines (61 loc) · 2.26 KB
/
synthetics.yml
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
name: Preview Synthetics
on:
pull_request:
types: [opened, synchronize]
branches:
- master
workflow_dispatch: # allows manual trigger
# Stop the current running job if a new push is made to the PR
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
synthetic_testing:
if: github.ref != 'refs/heads/guacbot/translation-pipeline'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ github.ref }}
path: repo
sparse-checkout: |
.
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${{ github.event.pull_request.head.ref }})" >>$GITHUB_OUTPUT
id: extract_branch
- name: Check preview status
id: check-status
run: |
URL="https://docs-staging.datadoghq.com/${{steps.extract_branch.outputs.branch}}"
SUCCESS_CODES=("200" "302" "304")
for i in {1..30}
do
status=$(curl -o /dev/null -s -w "%{http_code}\n" $URL)
if [[ " ${SUCCESS_CODES[@]} " =~ " ${status} " ]]; then
echo "Preview site has been deployed"
break
else
echo "Waiting for preview site to return 200 || 302 || 304..."
echo "Currently returning ${status}"
sleep 30
fi
if [[ $i -eq 30 && ! (" ${SUCCESS_CODES[@]} " =~ " ${status} ") ]]; then
echo "Preview site returned ${status} for 15 minutes, there may be an issue with the preview site build"
exit 1
fi
done
- name: Run Datadog Synthetic tests
uses: DataDog/[email protected]
env:
CI_COMMIT_REF_NAME: ${{steps.extract_branch.outputs.branch}}
with:
api_key: ${{secrets.DD_API_KEY}}
app_key: ${{secrets.DD_APP_KEY}}
config_path: 'repo/datadog-ci.preview.json'
# Override the WEBSITE variable to point to the preview site whereever referenced in the synthetics test
variables: 'WEBSITE=https://docs-staging.datadoghq.com/${{env.CI_COMMIT_REF_NAME}}/'