remove old code && add gh actions

pull/5042/head
yann300 6 months ago committed by Aniket
parent 8c6411887c
commit 5155adb760
  1. 7
      apps/remix-ide/src/app/plugins/templates-selection/templates-selection-plugin.tsx
  2. 12
      apps/remix-ide/src/app/plugins/templates-selection/templates.ts
  3. 29
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  4. 35
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx
  5. 2
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  6. 24
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  7. 20
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  8. 73
      libs/remix-ui/workspace/src/lib/utils/constants.ts
  9. 3
      libs/remix-ws-templates/src/index.ts
  10. 6
      libs/remix-ws-templates/src/script-templates/run-js-test-action/index.ts
  11. 26
      libs/remix-ws-templates/src/script-templates/run-js-test-action/run-js-test.yml
  12. 6
      libs/remix-ws-templates/src/script-templates/slither-action/index.ts
  13. 15
      libs/remix-ws-templates/src/script-templates/slither-action/run-slither-action.yml
  14. 6
      libs/remix-ws-templates/src/script-templates/solidity-test-action/index.ts
  15. 25
      libs/remix-ws-templates/src/script-templates/solidity-test-action/run-solidity-unittesting.yml

@ -145,7 +145,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
return <RemixUIGridSection
plugin={this}
title={template.name}
hScrollable= {true}
hScrollable= {false}
>
{template.items.map(item => {
return <RemixUIGridCell
@ -155,7 +155,10 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
<div>
{item.displayName}
{JSON.stringify(item.opts)}
<div><button data-id={`create-${item.value}${item.opts ? JSON.stringify(item.opts) : ''}`} onClick={async () => createWorkspace(item)} className="btn btn-secondary" >Create a new workspace</button><button data-id={`add-${item.value}`} onClick={async () => addToCurrentWorkspace(item)} className="btn btn-primary" >Add to current workspace</button></div>
<div>
{!template.IsArtefact && <button data-id={`create-${item.value}${item.opts ? JSON.stringify(item.opts) : ''}`} onClick={async () => createWorkspace(item)} className="btn btn-secondary" >Create a new workspace</button>}
<button data-id={`add-${item.value}`} onClick={async () => addToCurrentWorkspace(item)} className="btn btn-primary" >Add to current workspace</button>
</div>
</div>
</RemixUIGridCell>
})}

@ -252,7 +252,17 @@ export const templates = (intl) => {
name: "Contract Verification",
items: [
{ value: "etherscanScripts", displayName: intl.formatMessage({ id: 'filePanel.addscriptetherscan' }) },
]
],
},
{
name: 'Github Actions',
items: [
{ value: "runJsTestAction", displayName: intl.formatMessage({ id: 'filePanel.tssoltestghaction' }) },
{ value: "runSolidityUnittestingAction", displayName: intl.formatMessage({ id: 'filePanel.tssoltestghaction' }) },
{ value: "runSlitherAction", displayName: intl.formatMessage({ id: 'filePanel.slitherghaction' }) }
],
IsArtefact: true
}
]
}

@ -38,7 +38,7 @@ import { addSlash, checkSlash, checkSpecialChars } from '@remix-ui/helper'
import { FileTree, JSONStandardInput, WorkspaceTemplate } from '../types'
import { QueryParams } from '@remix-project/remix-lib'
import * as templateWithContent from '@remix-project/remix-ws-templates'
import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } from '../utils/constants'
import { ROOT_PATH } from '../utils/constants'
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB'
import { getUncommittedFiles } from '../utils/gitStatusFilter'
@ -880,33 +880,6 @@ export const createNewBranch = async (branch: string) => {
return promise
}
export const createSolidityGithubAction = async () => {
const path = '.github/workflows/run-solidity-unittesting.yml'
await plugin.call('fileManager', 'writeFile', path, solTestYml)
plugin.call('fileManager', 'open', path)
}
export const createTsSolGithubAction = async () => {
const path = '.github/workflows/run-js-test.yml'
await plugin.call('fileManager', 'writeFile', path, tsSolTestYml)
plugin.call('fileManager', 'open', path)
}
export const createSlitherGithubAction = async () => {
const path = '.github/workflows/run-slither-action.yml'
await plugin.call('fileManager', 'writeFile', path, slitherYml)
plugin.call('fileManager', 'open', path)
}
export const createHelperScripts = async (script: string) => {
if (!templates[script]) return
await templates[script](plugin)
plugin.call('notification', 'toast', `'${script}' added to the workspace.`)
}
export const updateGitSubmodules = async () => {
dispatch(cloneRepositoryRequest())
const config = plugin.registry.get('config').api

@ -16,10 +16,6 @@ export interface HamburgerMenuProps {
downloadWorkspaces: () => void
restoreBackup: () => void
hideIconsMenu: (showMenu: boolean) => void
addGithubAction: () => void
addTsSolTestGithubAction: () => void
addSlitherGithubAction: () => void
addHelperScripts: (script: string) => void
showIconsMenu: boolean
hideWorkspaceOptions: boolean
hideLocalhostOptions: boolean
@ -132,37 +128,6 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
}}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<Dropdown.Divider className="border mt-0 mb-0 remixui_menuhr" style={{ pointerEvents: 'none' }} />
<HamburgerMenuItem
kind="solghaction"
fa="fa-kit fa-solidity-mono"
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="tssoltestghaction"
fa="fab fa-js"
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addTsSolTestGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="slitherghaction"
fa="far fa-shield"
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addSlitherGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
</>
)
}

@ -54,5 +54,5 @@ export const FileSystemContext = createContext<{
dispatchGetElectronRecentFolders: () => Promise<void>
dispatchRemoveRecentFolder: (path: string) => Promise<void>
dispatchUpdateGitSubmodules: () => Promise<void>
}>(null)
}>(null)

@ -44,10 +44,6 @@ import {
switchBranch,
createNewBranch,
checkoutRemoteBranch,
createSolidityGithubAction,
createTsSolGithubAction,
createSlitherGithubAction,
createHelperScripts,
openElectronFolder,
getElectronRecentFolders,
removeRecentElectronFolder,
@ -234,22 +230,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await checkoutRemoteBranch(branch)
}
const dispatchCreateSolidityGithubAction = async () => {
await createSolidityGithubAction()
}
const dispatchCreateTsSolGithubAction = async () => {
await createTsSolGithubAction()
}
const dispatchCreateSlitherGithubAction = async () => {
await createSlitherGithubAction()
}
const dispatchCreateHelperScripts = async (script: string) => {
await createHelperScripts(script)
}
const dispatchOpenElectronFolder = async (path: string) => {
await openElectronFolder(path)
}
@ -387,10 +367,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchSwitchToBranch,
dispatchCreateNewBranch,
dispatchCheckoutRemoteBranch,
dispatchCreateSolidityGithubAction,
dispatchCreateTsSolGithubAction,
dispatchCreateSlitherGithubAction,
dispatchCreateHelperScripts,
dispatchOpenElectronFolder,
dispatchGetElectronRecentFolders,
dispatchRemoveRecentFolder,

@ -374,22 +374,6 @@ export function Workspace() {
)
}
const addGithubAction = () => {
global.dispatchCreateSolidityGithubAction()
}
const addTsSolTestGithubAction = () => {
global.dispatchCreateTsSolGithubAction()
}
const addSlitherGithubAction = () => {
global.dispatchCreateSlitherGithubAction()
}
const addHelperScripts = (script: string) => {
global.dispatchCreateHelperScripts(script)
}
const downloadWorkspaces = async () => {
try {
await global.dispatchHandleDownloadFiles()
@ -896,10 +880,6 @@ export function Workspace() {
downloadWorkspaces={downloadWorkspaces}
restoreBackup={restoreBackup}
hideIconsMenu={hideIconsMenu}
addGithubAction={addGithubAction}
addSlitherGithubAction={addSlitherGithubAction}
addHelperScripts={addHelperScripts}
addTsSolTestGithubAction={addTsSolTestGithubAction}
showIconsMenu={showIconsMenu}
hideWorkspaceOptions={currentWorkspace === LOCALHOST}
hideLocalhostOptions={currentWorkspace === NO_WORKSPACE}

@ -1,78 +1,5 @@
import { TemplateType } from '../types'
export const ROOT_PATH = '/'
export const solTestYml = `
name: Running Solidity Unit Tests
on: [push]
jobs:
run_sol_contracts_job:
runs-on: ubuntu-latest
name: A job to run solidity unit tests on github actions CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Environment Setup
uses: actions/setup-node@v3
with:
node-version: 20.0.0
- name: Run SUT Action
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests'
compiler-version: '0.8.15'
// evm-version: 'paris'
// optimize: true
// optimizer-runs: 200
// node-url: 'https://mainnet.infura.io/v3/08b2a484451e4635a28b3d8234f24332'
// block-number: 'latest'
// hard-fork: 'merge'
`
export const tsSolTestYml = `
name: Running Mocha Chai Solidity Unit Tests
on: [push]
jobs:
run_sample_test_job:
runs-on: ubuntu-latest
name: A job to run mocha and chai tests for solidity on github actions CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Environment Setup
uses: actions/setup-node@v3
with:
node-version: 20.0.0
- name: Run Mocha Chai Unit Test Action
uses: EthereumRemix/ts-sol-test@v1.3.1
with:
test-path: 'tests'
contract-path: 'contracts'
compiler-version: '0.8.7'
// evm-version: 'paris'
// optimize: true
// optimizer-runs: 200
// node-url: 'https://mainnet.infura.io/v3/08b2a484451e4635a28b3d8234f24332'
// block-number: 'latest'
// hard-fork: 'merge'
`
export const slitherYml = `
name: Slither Analysis
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- uses: crytic/slither-action@v0.2.0
with:
target: 'contracts'
slither-args: '--solc-remaps "@openzeppelin/contracts=./node_modules/@openzeppelin/contracts hardhat=./node_modules/hardhat"'
fail-on: 'low'
solc-version: '0.8.2'
`
export const TEMPLATE_NAMES = {
'remixDefault': 'Basic',

@ -14,4 +14,7 @@ export { contractDeployerScripts } from './script-templates/contract-deployer'
export { etherscanScripts } from './script-templates/etherscan'
export { sindriScripts } from './script-templates/sindri'
export { contractCreate2Factory } from './script-templates/create2-solidity-factory'
export { runSolidityUnittestingAction } from './script-templates/solidity-test-action'
export { runSlitherAction } from './script-templates/slither-action'
export { runJsTestAction } from './script-templates/run-js-test-action'

@ -0,0 +1,6 @@
export const runJsTestAction = async (opts, plugin) => {
await plugin.call('fileManager', 'writeFile',
'.github/workflows/run-js-test.yml' ,
// @ts-ignore
(await import('!!raw-loader!./run-js-test.yml')).default)
}

@ -0,0 +1,26 @@
name: Running Mocha Chai Solidity Unit Tests
on: [push]
jobs:
run_sample_test_job:
runs-on: ubuntu-latest
name: A job to run mocha and chai tests for solidity on github actions CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Environment Setup
uses: actions/setup-node@v3
with:
node-version: 20.0.0
- name: Run Mocha Chai Unit Test Action
uses: EthereumRemix/ts-sol-test@v1.3.1
with:
test-path: 'tests'
contract-path: 'contracts'
compiler-version: '0.8.7'
// evm-version: 'paris'
// optimize: true
// optimizer-runs: 200
// node-url: 'https://mainnet.infura.io/v3/08b2a484451e4635a28b3d8234f24332'
// block-number: 'latest'
// hard-fork: 'merge'

@ -0,0 +1,6 @@
export const runSlitherAction = async (opts, plugin) => {
await plugin.call('fileManager', 'writeFile',
'.github/workflows/run-slither-action.yml' ,
// @ts-ignore
(await import('!!raw-loader!./run-slither-action.yml')).default)
}

@ -0,0 +1,15 @@
name: Slither Analysis
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- uses: crytic/slither-action@v0.2.0
with:
target: 'contracts'
slither-args: '--solc-remaps "@openzeppelin/contracts=./node_modules/@openzeppelin/contracts hardhat=./node_modules/hardhat"'
fail-on: 'low'
solc-version: '0.8.2'

@ -0,0 +1,6 @@
export const runSolidityUnittestingAction = async (opts, plugin) => {
await plugin.call('fileManager', 'writeFile',
'.github/workflows/run-solidity-unittesting.yml' ,
// @ts-ignore
(await import('!!raw-loader!./run-solidity-unittesting.yml')).default)
}

@ -0,0 +1,25 @@
name: Running Solidity Unit Tests
on: [push]
jobs:
run_sol_contracts_job:
runs-on: ubuntu-latest
name: A job to run solidity unit tests on github actions CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Environment Setup
uses: actions/setup-node@v3
with:
node-version: 20.0.0
- name: Run SUT Action
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests'
compiler-version: '0.8.15'
// evm-version: 'paris'
// optimize: true
// optimizer-runs: 200
// node-url: 'https://mainnet.infura.io/v3/08b2a484451e4635a28b3d8234f24332'
// block-number: 'latest'
// hard-fork: 'merge'
Loading…
Cancel
Save