Skip to content

Commit 24e5134

Browse files
authored
chore: Onboard Papertrail (#3389)
1 parent 177092e commit 24e5134

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

build/ci/evergreen.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exec_timeout_secs: 4200
2+
stepback: true
3+
command_type: system
4+
pre_error_fails_task: true
5+
include:
6+
- filename: build/ci/papertrail.yml
7+
8+
tasks:
9+
- name: no_op
10+
commands:
11+
- command: shell.exec
12+
params:
13+
script: |
14+
echo "This is a no-op task, does nothing."
15+
16+
17+
18+
buildvariants:
19+
- name: no_op
20+
display_name: no_op
21+
run_on:
22+
- ubuntu2404-small
23+
tasks:
24+
- name: no_op

build/ci/papertrail.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
variables:
2+
- &go_linux_version
3+
go_base_path: ""
4+
- &go_env
5+
XDG_CONFIG_HOME: ${go_base_path}${workdir}
6+
GO111MODULE: "on"
7+
GOROOT: ${go_root}
8+
GOPATH: ${go_base_path}${workdir}
9+
ADD_PATH: "${go_bin}:${go_base_path}${workdir}/bin:${go_base_path}${workdir}/src/github.com/mongodb/terraform-provider-mongodbatlas/bin"
10+
- &go_options
11+
add_to_path:
12+
- ${go_bin}
13+
- ${go_base_path}${workdir}/bin
14+
- ${go_base_path}${workdir}/src/github.com/mongodb/terraform-provider-mongodbatlas/bin
15+
include_expansions_in_env:
16+
- go_base_path
17+
- workdir
18+
working_dir: src/github.com/mongodb/terraform-provider-mongodbatlas
19+
env:
20+
<<: *go_env
21+
22+
functions:
23+
"install gh cli":
24+
- command: shell.exec
25+
params:
26+
working_dir: ""
27+
script: |
28+
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
29+
sudo dnf install -y gh
30+
31+
"trace release artifacts":
32+
- command: shell.exec
33+
params:
34+
working_dir: /tmp
35+
script: |
36+
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
37+
sudo dnf install -y gh
38+
39+
- command: git.get_project
40+
params:
41+
directory: src/github.com/mongodb/terraform-provider-mongodbatlas
42+
43+
- command: shell.exec
44+
params:
45+
working_dir: "src/github.com/mongodb/terraform-provider-mongodbatlas"
46+
shell: bash
47+
script: |
48+
export GH_TOKEN="${github_token}"
49+
50+
release_tag=$(gh release list --limit 1 --json tagName | jq -r '.[0].tagName')
51+
echo "DEBUG: extracted release_tag: $release_tag"
52+
53+
version="$(echo "$release_tag" | cut -c2-)"
54+
echo "Tracing artifacts for version: $version"
55+
56+
if [[ -z "$release_tag" || "$release_tag" == "null" ]]; then
57+
echo "ERROR: Failed to extract valid release tag"
58+
exit 1
59+
fi
60+
61+
echo "Waiting 20 minutes before checking for release artifacts..."
62+
sleep 1200
63+
64+
echo "Checking for terraform-provider .zip artifacts in GitHub release..."
65+
66+
max_attempts=5
67+
attempt=1
68+
artifact_found=false
69+
70+
while [ $attempt -le $max_attempts ]; do
71+
echo "Attempt $attempt: checking for artifacts..."
72+
gh release view "${release_tag}" --json assets --jq '.assets[].name' | grep -q 'terraform-provider-mongodbatlas.*\.zip'
73+
if [ $? -eq 0 ]; then
74+
echo "Artifacts found. Proceeding to download..."
75+
artifact_found=true
76+
break
77+
fi
78+
79+
echo "Artifacts not available yet. Sleeping for 2 minutes before retry..."
80+
sleep 120
81+
attempt=$((attempt + 1))
82+
done
83+
84+
if [ "$artifact_found" != true ]; then
85+
echo "ERROR: No terraform-provider .zip artifacts found after waiting. Exiting..."
86+
gh release view "${release_tag}" --json assets --jq '.assets[].name'
87+
exit 1
88+
fi
89+
90+
mkdir -p release_artifacts
91+
gh release download "${release_tag}" -p "terraform-provider-mongodbatlas*.zip" -D ./release_artifacts/
92+
93+
echo "Downloaded artifacts:"
94+
ls -la release_artifacts/
95+
96+
echo "Removing any source code archives..."
97+
rm -f release_artifacts/Source* release_artifacts/source* 2>/dev/null || true
98+
99+
echo "Final artifacts to trace:"
100+
ls -la release_artifacts/
101+
102+
artifact_count=$(ls -1 release_artifacts/*.zip 2>/dev/null | wc -l)
103+
if [ $artifact_count -eq 0 ]; then
104+
echo "ERROR: No terraform-provider .zip artifacts found for release ${release_tag}"
105+
echo "Available files in release:"
106+
gh release view "${release_tag}" --json assets --jq '.assets[].name'
107+
exit 1
108+
fi
109+
110+
echo "Found $artifact_count terraform-provider artifacts to trace"
111+
112+
cat <<EOT >trace-expansions.yml
113+
release_version: "$version"
114+
EOT
115+
116+
117+
- command: expansions.update
118+
params:
119+
file: src/github.com/mongodb/terraform-provider-mongodbatlas/trace-expansions.yml
120+
121+
- command: papertrail.trace
122+
params:
123+
key_id: ${papertrail_key_id}
124+
secret_key: ${papertrail_secret_key}
125+
product: "terraform-provider-mongodbatlas"
126+
version: ${release_version}
127+
filenames:
128+
- "src/github.com/mongodb/terraform-provider-mongodbatlas/release_artifacts/*.zip"
129+
130+
131+
tasks:
132+
- name: trace_release_artifacts
133+
tags: ["release"]
134+
commands:
135+
- func: "trace release artifacts"
136+
137+
138+
buildvariants:
139+
- name: papertrail_github_release
140+
display_name: "Papertrail - GitHub Release Artifacts"
141+
git_tag_only: true
142+
tags: ["release"]
143+
run_on:
144+
- rhel90-small
145+
expansions:
146+
<<: *go_linux_version
147+
tasks:
148+
- name: trace_release_artifacts

0 commit comments

Comments
 (0)