Skip to content

Commit

Permalink
remove old code && add gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed May 31, 2024
1 parent 096b485 commit 4121fa2
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 280 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
})}
Expand Down
12 changes: 11 additions & 1 deletion apps/remix-ide/src/app/plugins/templates-selection/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
106 changes: 13 additions & 93 deletions apps/remix-ide/src/assets/list.json

Large diffs are not rendered by default.

29 changes: 1 addition & 28 deletions libs/remix-ui/workspace/src/lib/actions/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -864,33 +864,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
Expand Down
35 changes: 0 additions & 35 deletions libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
</>
)
}
Expand Down
4 changes: 0 additions & 4 deletions libs/remix-ui/workspace/src/lib/contexts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export const FileSystemContext = createContext<{
dispatchSwitchToBranch: (branch: string) => Promise<void>,
dispatchCreateNewBranch: (branch: string) => Promise<void>,
dispatchCheckoutRemoteBranch: (branch: string, remote: string) => Promise<void>,
dispatchCreateSolidityGithubAction: () => Promise<void>,
dispatchCreateTsSolGithubAction: () => Promise<void>,
dispatchCreateSlitherGithubAction: () => Promise<void>
dispatchCreateHelperScripts: (script: string) => Promise<void>
dispatchOpenElectronFolder: (path: string) => Promise<void>
dispatchGetElectronRecentFolders: () => Promise<void>
dispatchRemoveRecentFolder: (path: string) => Promise<void>
Expand Down
24 changes: 0 additions & 24 deletions libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ import {
switchBranch,
createNewBranch,
checkoutRemoteBranch,
createSolidityGithubAction,
createTsSolGithubAction,
createSlitherGithubAction,
createHelperScripts,
openElectronFolder,
getElectronRecentFolders,
removeRecentElectronFolder,
Expand Down Expand Up @@ -221,22 +217,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await checkoutRemoteBranch(branch, remote)
}

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)
}
Expand Down Expand Up @@ -372,10 +352,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchSwitchToBranch,
dispatchCreateNewBranch,
dispatchCheckoutRemoteBranch,
dispatchCreateSolidityGithubAction,
dispatchCreateTsSolGithubAction,
dispatchCreateSlitherGithubAction,
dispatchCreateHelperScripts,
dispatchOpenElectronFolder,
dispatchGetElectronRecentFolders,
dispatchRemoveRecentFolder,
Expand Down
20 changes: 0 additions & 20 deletions libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,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()
Expand Down Expand Up @@ -757,10 +741,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}
Expand Down
73 changes: 0 additions & 73 deletions libs/remix-ui/workspace/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 3 additions & 0 deletions libs/remix-ws-templates/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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)
}
Loading

0 comments on commit 4121fa2

Please sign in to comment.