Skip to content

Commit

Permalink
Merge pull request #568 from Synthetixio/github-rate-limit-fix
Browse files Browse the repository at this point in the history
fix: GitHub rate limiting
  • Loading branch information
drptbl authored Oct 30, 2022
2 parents 9d2f147 + 37f34fd commit be6a2f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ following features:
- [playwright debugger](https://playwright.dev/docs/debug)
- slow down tests

You may encounter 403 errors (on shared IPs & CI) related to rate limiting while
fetching metamask releases from GitHub REST API. This should never happen at
all, but it's good to mention. To prevent it from happening, you can create new
private access token on GitHub (without any additional access) and specify
`GH_USERNAME` & `GH_PAT` environmental variables.

## 🐳 Using with Docker

Dreaming about "headless" mode? Here comes a rescue 🚑!
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ services:
bash -c 'echo -n "======> local noVNC URL:
http://localhost:8080/vnc.html?autoconnect=true " && npx wait-on
http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e:anvil'
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn
test:e2e:anvil'
networks:
- x11

Expand Down Expand Up @@ -69,7 +70,7 @@ services:
foundry:
container_name: foundry
image: synthetixio/foundry:016121eafdfff448414894d0ca5a50b1d72b62eb-base
command: [ 'anvil --fork-url ${ANVIL_FORK_URL}' ]
command: ['anvil --fork-url ${ANVIL_FORK_URL}']
ports:
- '8545:8545'
networks:
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ services:
bash -c 'echo -n "======> local noVNC URL:
http://localhost:8080/vnc.html?autoconnect=true " && npx wait-on
http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e:anvil'
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn
test:e2e:anvil'
networks:
- x11

Expand Down Expand Up @@ -64,7 +65,7 @@ services:
foundry:
container_name: foundry
image: synthetixio/foundry:016121eafdfff448414894d0ca5a50b1d72b62eb-base
command: [ 'anvil --fork-url ${ANVIL_FORK_URL}' ]
command: ['anvil --fork-url ${ANVIL_FORK_URL}']
ports:
- '8545:8545'
networks:
Expand Down
19 changes: 16 additions & 3 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,25 @@ module.exports = {
let filename;
let downloadUrl;
let tagName;
let response;

try {
const response = await axios.get(
'https://api.github.com/repos/metamask/metamask-extension/releases',
);
if (version === 'latest' || !version) {
if (process.env.GH_USERNAME && process.env.GH_PAT) {
response = await axios.get(
'https://api.github.com/repos/metamask/metamask-extension/releases',
{
auth: {
username: process.env.GH_USERNAME,
password: process.env.GH_PAT,
},
},
);
} else {
response = await axios.get(
'https://api.github.com/repos/metamask/metamask-extension/releases',
);
}
filename = response.data[0].assets[0].name;
downloadUrl = response.data[0].assets[0].browser_download_url;
tagName = response.data[0].tag_name;
Expand Down

0 comments on commit be6a2f0

Please sign in to comment.