Skip to content

Commit

Permalink
Update snap for Condor compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianH committed Jan 20, 2025
1 parent 93278c4 commit 4a1f266
Show file tree
Hide file tree
Showing 49 changed files with 9,308 additions and 6,695 deletions.
15 changes: 4 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
module.exports = {
root: true,

parserOptions: {
sourceType: 'module',
},
env: {
jest: true,
},

extends: ['@metamask/eslint-config'],

overrides: [
{
files: ['**/*.js'],
files: ['*.js'],
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ['**/*.{ts,tsx}'],
files: ['*.ts', '*.tsx'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
},
},

{
files: ['**/*.test.ts', '**/*.test.js'],
files: ['*.test.ts', '*.test.js'],
extends: ['@metamask/eslint-config-jest'],
rules: {
'@typescript-eslint/no-shadow': [
Expand All @@ -39,11 +34,9 @@ module.exports = {
'!.prettierrc.js',
'**/!.eslintrc.js',
'**/dist*/',
'**/docs*/',
'**/*__GENERATED__*',
'**/build',
'**/public',
'**/.cache',
'**/truffle',
],
};
21 changes: 11 additions & 10 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ jobs:
name: Publish release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
fetch-depth: 0

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
cache: 'yarn'

- run: yarn install --immutable
- run: yarn build
env:
REFERER: ${{ secrets.REFERER }}

- name: NPM config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
run: npm config set //registry.npmjs.org/:_authToken "$NPM_TOKEN"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand All @@ -54,4 +55,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPE_ARG: ${{ fromJSON('{"auto":"", "patch":"--patch", "minor":"--minor", "major":"--major", "beta":"--preRelease=beta --npm.tag=next", "alpha":"--preRelease=alpha --npm.tag=next"}')[github.event.inputs.type] }}
DRY_ARG: ${{ github.event.inputs.dry == 'true' && '--dry-run' || '' }}
run: yarn run release --ci --no-git.requireUpstream --verbose $TYPE_ARG $DRY_ARG
run: yarn run release --ci --no-git.requireUpstream --verbose "$TYPE_ARG" "$DRY_ARG"
129 changes: 129 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --immutable

build:
name: Build
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build
env:
REFERER: ${{ secrets.REFERER }}
- name: Cache snap build
uses: actions/cache@v3
with:
path: ./packages/snap/dist
key: snap-${{ runner.os }}-${{ github.sha }}
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
lint:
name: Lint
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
e2e-test:
name: End-to-end Test
runs-on: ubuntu-latest
needs:
- prepare
- build
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Restore snap build cache
uses: actions/cache@v3
with:
path: ./packages/snap/dist
key: snap-${{ runner.os }}-${{ github.sha }}
- run: yarn install --immutable
- name: Run e2e tests
run: yarn workspace snap run test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
publish-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- run: yarn install --immutable

- name: Build helper doc
run: cd packages/lib && yarn docs

- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: packages/lib/docs
62 changes: 0 additions & 62 deletions .github/workflows/build-test.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Main

on:
push:
branches: [main]
pull_request:

jobs:
check-workflows:
name: Check workflows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download actionlint
id: download-actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
shell: bash
- name: Check workflow files
run: ${{ steps.download-actionlint.outputs.executable }} -color
shell: bash

build-lint-test:
name: Build, lint, and test
uses: ./.github/workflows/build-lint-test.yml

all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- check-workflows
- build-lint-test
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"

all-jobs-pass:
name: All jobs pass
if: ${{ always() }}
runs-on: ubuntu-latest
needs: all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi
43 changes: 43 additions & 0 deletions .github/workflows/security-code-scanner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'MetaMask Security Code Scanner'

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
run-security-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: MetaMask Security Code Scanner
uses: MetaMask/Security-Code-Scanner@main
with:
repo: ${{ github.repository }}
paths_ignored: |
.storybook/
'**/__snapshots__/'
'**/*.snap'
'**/*.stories.js'
'**/*.stories.tsx'
'**/*.test.browser.ts*'
'**/*.test.js*'
'**/*.test.ts*'
'**/fixtures/'
'**/jest.config.js'
'**/jest.environment.js'
'**/mocks/'
'**/test*/'
docs/
e2e/
merged-packages/
node_modules
storybook/
test*/
rules_excluded: example
project_metrics_token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
slack_webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ node_modules/
.yarn/install-state.gz
.pnp.*

packages/snap/.yalc/

packages/snap/yalc.lock

.idea/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
lts/*
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-allow-scripts",
factory: function (require) {
var plugin=(()=>{var l=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var u=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},f=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of a(o))!c.call(t,i)&&i!==e&&l(t,i,{get:()=>o[i],enumerable:!(r=s(o,i))||r.enumerable});return t};var m=t=>f(l({},"__esModule",{value:!0}),t);var g={};u(g,{default:()=>d});var n=p("@yarnpkg/shell"),x={hooks:{afterAllInstalled:async()=>{let t=await(0,n.execute)("yarn run allow-scripts");t!==0&&process.exit(t)}}},d=x;return m(g);})();
return plugin;
}
};
Loading

0 comments on commit 4a1f266

Please sign in to comment.