Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into beroburny/speedup-init
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
  • Loading branch information
BeroBurny committed Jan 19, 2023
2 parents 0acc1be + bf8499d commit 61bc018
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 37 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/main-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Main Branch Beta Release"

on:
push:
branches:
- master

jobs:
release:
name: release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: yarn --prefer-offline --frozen-lockfile
- run: yarn build
- name: "Retrieving package version"
uses: martinbeentjes/npm-get-version-action@main
id: version
- name: "Retrieving commit hash"
id: commit
uses: pr-mpt/actions-commit-hash@v2
- run: yarn publish --access public --tag beta --new-version ${{steps.version.outputs.current-version}}-${{steps.commit.outputs.short}}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
69 changes: 40 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,41 @@ on:
- '**'

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: 'yarn'
- name: Install deps
run: yarn --prefer-offline --frozen-lockfile
- name: Build
run: yarn build
- name: Download metamask
run: yarn run download:metamask
- uses: actions/cache/save@v3
with:
path: .metamask
key: metamask-extension
lint:
needs: build
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: 'yarn'
- name: Install deps
run: yarn --prefer-offline --frozen-lockfile
- name: Lint
run: yarn run lint
tests:
needs: build
name: Tests
runs-on: ubuntu-latest
strategy:
Expand All @@ -24,10 +58,14 @@ jobs:
with:
node-version: "16"
cache: 'yarn'
- uses: actions/cache/restore@v3
with:
path: .metamask
key: metamask-extension
- name: Install
run: yarn --prefer-offline --frozen-lockfile
- name: Tests
run: 'yarn run test:${{matrix.automation}}:${{matrix.mm-version}} --timeout 50000'
run: 'yarn run test:${{matrix.automation}}:${{ matrix.mm-version }} --timeout 50000'
- uses: actions/upload-artifact@v3
if: always()
with:
Expand All @@ -36,7 +74,7 @@ jobs:
tests-user-data:
name: Tests UserData
runs-on: ubuntu-latest
needs: [tests]
needs: tests
strategy:
fail-fast: false
matrix:
Expand All @@ -51,33 +89,6 @@ jobs:
run: yarn --prefer-offline --frozen-lockfile
- name: Tests UserData
run: 'yarn run test:${{matrix.automation}}:userData --timeout 240000'
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: 'yarn'
- name: Install deps
run: yarn --prefer-offline --frozen-lockfile
- name: Lint
run: yarn run lint
build:
name: Build
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: 'yarn'
- name: Install deps
run: yarn --prefer-offline --frozen-lockfile
- name: Build
run: yarn build

maybe-release:
name: release
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"test:puppeteer:mm": "AUTOMATION=puppeteer yarn run test:mm",
"test:puppeteer:flask": "AUTOMATION=puppeteer yarn run test:flask",
"test:playwright:mm": "AUTOMATION=playwright yarn run test:mm",
"test:playwright:flask": "AUTOMATION=playwright yarn run test:flask"
"test:playwright:flask": "AUTOMATION=playwright yarn run test:flask",
"download:metamask": "node -r ts-node/register ./scripts/download_metamask.ts"
},
"repository": {
"type": "git",
Expand Down
11 changes: 11 additions & 0 deletions scripts/download_metamask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import downloader from "../src/setup/utils/metaMaskDownloader";
import {RECOMMENDED_METAMASK_VERSION} from "../src"

(async function() {
await downloader(RECOMMENDED_METAMASK_VERSION, {
flask: false,
});
await downloader(RECOMMENDED_METAMASK_VERSION, {
flask: true,
});
})()
15 changes: 10 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// re-export
export { getMetaMask, getMetaMaskWindow } from "./metamask";
export * from "./types";
export * from "./browser";
export * from "./page";
export * from "./element";
export * from "./setup";
export {
Dappeteer,
DappeteerLaunchOptions,
MetaMaskOptions,
TransactionOptions,
} from "./types";
export { DappeteerBrowser } from "./browser";
export { DappeteerPage } from "./page";
export { DappeteerElementHandle } from "./element";
export { bootstrap, initSnapEnv, launch, setupMetaMask } from "./setup";
export { DapeteerJestConfig } from "./jest/global";

// default constants
Expand Down
6 changes: 6 additions & 0 deletions src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { setupMetaMask } from "./setupMetaMask";
export * from "./launch";
export * from "./setupMetaMask";

/**
* Launches browser and installs required metamask version along with setting up initial account
*/
export const bootstrap = async ({
seed,
password,
Expand All @@ -32,6 +35,9 @@ export const bootstrap = async ({
};
};

/**
* Used to quickly bootstrap dappeteer testing environment with installed snap
*/
export const initSnapEnv = async (
opts: DappeteerLaunchOptions &
MetaMaskOptions &
Expand Down
8 changes: 7 additions & 1 deletion src/setup/utils/metaMaskDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import * as path from "path";

import StreamZip from "node-stream-zip";

const defaultDirectory = path.resolve(__dirname, "..", "..", "..", ".metamask");
export const defaultDirectory = path.resolve(
__dirname,
"..",
"..",
"..",
".metamask"
);

export type Path =
| string
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"declaration": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "dist"
"outDir": "dist",
"removeComments": false
},
"files": ["./node_modules/@metamask/snap-types/global.d.ts"],
"include": [
Expand Down

0 comments on commit 61bc018

Please sign in to comment.