Skip to content

Commit

Permalink
Merge pull request #839 from Synthetixio/dev
Browse files Browse the repository at this point in the history
promote dev to master
  • Loading branch information
r3kt-eth authored Aug 17, 2023
2 parents 2bcf318 + fe02c5d commit 6e68840
Show file tree
Hide file tree
Showing 18 changed files with 418 additions and 268 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@0ba4244466797eb048eb91a6cd43d5c03ca8bd05
uses: github/codeql-action/init@a09933a12a80f87b87005513f0abb1494c27a716
with:
queries: security-and-quality
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0ba4244466797eb048eb91a6cd43d5c03ca8bd05
uses: github/codeql-action/analyze@a09933a12a80f87b87005513f0abb1494c27a716
4 changes: 2 additions & 2 deletions .github/workflows/e2e_cypress-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # [email protected]

- name: Setup node
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # pin@v3.7.0
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
with:
node-version: 18.16

Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
DISPLAY: :0.0

- name: Run e2e tests (cypress-action)
uses: cypress-io/github-action@d69252d52b9a31bad4f418f05ba2bc83687a02eb # [email protected].3
uses: cypress-io/github-action@248bde77443c376edc45906ede03a1aba9da0462 # [email protected].4
with:
start: pnpm start:server
command: pnpm test:e2e:ci:cypress-action
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # [email protected]

- name: Setup node
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # pin@v3.7.0
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
with:
node-version: 18.16

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_headful.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # [email protected]

- name: Setup node
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # pin@v3.7.0
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
with:
node-version: 18.16

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
.turbo
.pnpm-store
.DS_Store
.idea

downloads
lint-results.sarif
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ FROM --platform=linux/amd64 synthetixio/docker-e2e:18.16-ubuntu as base
RUN mkdir /app
WORKDIR /app

RUN apt update && apt install -y nginx

COPY nginx.conf /etc/nginx/sites-available/default

COPY package.json ./
COPY pnpm-lock.yaml ./

Expand Down
15 changes: 15 additions & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ let walletAddress;
let switchBackToCypressWindow;

const metamask = {
async resetState() {
log('Resetting state of metamask');
extensionId = undefined;
extensionVersion = undefined;
extensionHomeUrl = undefined;
extensionSettingsUrl = undefined;
extensionAdvancedSettingsUrl = undefined;
extensionExperimentalSettingsUrl = undefined;
extensionAddNetworkUrl = undefined;
extensionNewAccountUrl = undefined;
extensionImportAccountUrl = undefined;
extensionImportTokenUrl = undefined;
walletAddress = undefined;
switchBackToCypressWindow = undefined;
},
extensionId: () => {
return extensionId;
},
Expand Down
12 changes: 12 additions & 0 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ let retries = 0;
let extensionsData = {};

module.exports = {
async resetState() {
log('Resetting state of playwright');
expectInstance = undefined;
browser = undefined;
mainWindow = undefined;
metamaskWindow = undefined;
metamaskNotificationWindow = undefined;
metamaskPopupWindow = undefined;
activeTabName = undefined;
retries = 0;
extensionsData = {};
},
getExpectInstance() {
return expectInstance;
},
Expand Down
13 changes: 13 additions & 0 deletions commands/synpress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const log = require('debug')('synpress:synpress');
const playwright = require('./playwright');
const metamask = require('./metamask');
const helpers = require('../helpers');

module.exports = {
async resetState() {
log('Resetting state of synpress');
await playwright.resetState();
await metamask.resetState();
await helpers.resetState();
},
};
16 changes: 15 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- ./docker/videos:/app/tests/e2e/videos
- ./docker/screenshots:/app/tests/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && pnpm test:e2e:ci:anvil'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && pnpm test:e2e:ci:anvil'
networks:
- x11

Expand Down Expand Up @@ -113,5 +113,19 @@ services:
networks:
- x11

foundry-metamask-test-dapp:
profiles:
- foundry
container_name: foundry-metamask-test-dapp
image: synthetixio/foundry:457bb48776c3b14de232d9dda620ba9188dc40ac-base
# Port and chain id as required by the MetaMask Test Dapp
command: [ 'anvil --no-cors --port 8546 --chain-id 1338' ]
environment:
- ANVIL_IP_ADDR=0.0.0.0
ports:
- '8546:8546'
networks:
- x11

networks:
x11:
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- ./docker/videos:/app/tests/e2e/videos
- ./docker/screenshots:/app/tests/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && pnpm test:e2e:anvil'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && pnpm test:e2e:anvil'
networks:
- x11

Expand Down Expand Up @@ -84,5 +84,19 @@ services:
networks:
- x11

foundry-metamask-test-dapp:
profiles:
- foundry
container_name: foundry-metamask-test-dapp
image: synthetixio/foundry:457bb48776c3b14de232d9dda620ba9188dc40ac-base
# Port and chain id as required by the MetaMask Test Dapp
command: [ 'anvil --no-cors --port 8546 --chain-id 1338' ]
environment:
- ANVIL_IP_ADDR=0.0.0.0
ports:
- '8546:8546'
networks:
- x11

networks:
x11:
10 changes: 7 additions & 3 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ let currentNetwork = chains.mainnet;
let addedNetworks = [chains.mainnet, chains.goerli, chains.sepolia];

module.exports = {
async resetState() {
log('Resetting state of helpers');
currentNetwork = chains.mainnet;
addedNetworks = [chains.mainnet, chains.goerli, chains.sepolia];
},
// set currently active network
async setNetwork(network) {
log(`Setting network to ${JSON.stringify(network)}`);
Expand Down Expand Up @@ -233,9 +238,8 @@ module.exports = {

await module.exports.createDirIfNotExist(downloadsDirectory);
const metamaskDirectory = path.join(downloadsDirectory, release.tagName);
const metamaskDirectoryExists = await module.exports.checkDirOrFileExist(
metamaskDirectory,
);
const metamaskDirectoryExists =
await module.exports.checkDirOrFileExist(metamaskDirectory);
const metamaskManifestFilePath = path.join(
downloadsDirectory,
release.tagName,
Expand Down
25 changes: 25 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 8545;
server_name localhost;

location / {
proxy_pass http://foundry:8545;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 8546;
server_name localhost;

location / {
proxy_pass http://foundry-metamask-test-dapp:8546;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
},
"dependencies": {
"@cypress/code-coverage": "^3.11.0",
"@cypress/webpack-dev-server": "^3.5.1",
"@cypress/webpack-dev-server": "^3.5.2",
"@drptbl/gremlins.js": "^2.2.1",
"@foundry-rs/easy-foundryup": "^0.1.3",
"@playwright/test": "^1.36.2",
"@playwright/test": "^1.37.0",
"@testing-library/cypress": "^9.0.0",
"@testing-library/react": "^14.0.0",
"@types/testing-library__cypress": "^5.0.9",
Expand All @@ -69,41 +69,41 @@
"babel-plugin-transform-react-styled-components-qa": "^2.1.0",
"bytes32": "^0.0.3",
"commander": "^11.0.0",
"cypress": "^12.17.3",
"cypress-wait-until": "^2.0.0",
"cypress": "^12.17.4",
"cypress-wait-until": "^2.0.1",
"debug": "^4.3.4",
"dotenv": "^16.3.1",
"dotenv-parse-variables": "^2.0.0",
"download": "^8.0.0",
"ethers": "^6.6.7",
"ethers": "^6.7.1",
"etherscan-api": "^10.3.0",
"find-config": "^1.0.0",
"get-port": "^7.0.0",
"node-fetch": "^2.6.1",
"underscore": "^1.13.6",
"viem": "^1.5.0",
"viem": "^1.6.0",
"wait-on": "^7.0.1"
},
"devDependencies": {
"@metamask/test-dapp": "^7.0.1",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-turbo": "^1.10.12",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-cypress": "^2.14.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^4.1.0",
"eslint-plugin-testing-library": "^5.11.0",
"eslint-plugin-testing-library": "^6.0.0",
"eslint-plugin-ui-testing": "^2.0.1",
"eslint-plugin-unicorn": "^48.0.1",
"npm-check-updates": "^16.10.17",
"prettier": "^3.0.0",
"release-it": "^16.1.3",
"npm-check-updates": "^16.12.2",
"prettier": "^3.0.2",
"release-it": "^16.1.5",
"serve": "^14.2.0",
"start-server-and-test": "^2.0.0",
"turbo": "^1.10.12"
Expand Down
5 changes: 2 additions & 3 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ module.exports = (on, config) => {
return activated;
},
activateImprovedTokenAllowanceInMetamask: async skipSetup => {
const activated = await metamask.activateImprovedTokenAllowance(
skipSetup,
);
const activated =
await metamask.activateImprovedTokenAllowance(skipSetup);
return activated;
},
resetMetamaskAccount: async () => {
Expand Down
Loading

0 comments on commit 6e68840

Please sign in to comment.