Skip to content

Commit 58df07d

Browse files
authored
fix(ci): avoid rate-limiting #3380
Problem: github timeouts on various requests: Cloning into '/codebuild/output/src577833252/src/github.com/aws/aws-toolkit-vscode/node_modules/.zzz-awssdk2'... fatal: unable to access 'https://github.com/aws/aws-sdk-js.git/': Failed to connect to github.com port 443 after 130288 ms: Connection timed out Solution: use a github token for all "git" operations to avoid rate-limiting
1 parent c23bf21 commit 58df07d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

buildspec/linuxIntegrationTests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: 0.2
22

33
env:
44
variables:
5+
# Implicitly passed by the AWS automation pipeline:
6+
# VSCODE_TEST_VERSION
7+
# GITHUB_READONLY_TOKEN
58
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/'
69
AWS_TOOLKIT_TEST_NO_COLOR: '1'
710
NO_COVERAGE: 'true'
@@ -16,6 +19,7 @@ phases:
1619
java: latest
1720

1821
commands:
22+
- bash buildspec/setup-github-token.sh
1923
- '>/dev/null add-apt-repository universe'
2024
- '>/dev/null apt-get -qq install -y apt-transport-https'
2125
- '>/dev/null apt-get -qq update'
@@ -68,6 +72,10 @@ phases:
6872
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
6973
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
7074
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
75+
post_build:
76+
commands:
77+
# Destroy .netrc to avoid leaking $GITHUB_READONLY_TOKEN.
78+
- rm "$HOME/.netrc"
7179
reports:
7280
integ-test:
7381
files:

buildspec/setup-github-token.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/env bash
2+
3+
set -e
4+
5+
test -n "$GITHUB_READONLY_TOKEN" || { echo 'missing $GITHUB_READONLY_TOKEN'; exit 1; }
6+
7+
# Authenticate all "git" (and "curl --netrc") github calls, to avoid rate-limiting.
8+
# NOTE: the "login" value is arbitrary.
9+
printf "machine github.com login oauth password ${GITHUB_READONLY_TOKEN:-unknown}\n" >> "$HOME/.netrc"
10+
printf "machine api.github.com login oauth password ${GITHUB_READONLY_TOKEN:-unknown}\n" >> "$HOME/.netrc"
11+
printf "machine uploads.github.com login oauth password ${GITHUB_READONLY_TOKEN:-unknown}\n" >> "$HOME/.netrc"
12+
# Print ratelimit info.
13+
2>/dev/null curl --netrc -L -I https://api.github.com/ | grep x-ratelimit | sed 's/\(.*\)/ \1/'
14+
# Validate ratelimit.
15+
2>/dev/null curl --netrc -L -I https://api.github.com/ | >/dev/null grep 'x-ratelimit-limit: *[0-9][0-9][0-9][0-9]\+' || { echo 'invalid github token, or rate limit too low (expected 5000+)'; exit 1; }

0 commit comments

Comments
 (0)