Github helper actions

pull/3299/head
ioedeveloper 2 years ago committed by Aniket
parent a5ccf09893
commit 792324db10
  1. 8
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  2. 36
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  3. 4
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  4. 14
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  5. 120
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  6. 47
      libs/remix-ui/workspace/src/lib/utils/constants.ts

@ -15,8 +15,12 @@
"filePanel.workspace.restore": "Restore Workspace Backup",
"filePanel.workspace.clone": "Clone Git Repository",
"filePanel.workspace.enterGitUrl": "Enter git repository url",
"filePanel.workspace.solghaction": "Add the Solidity GitHub Action file. Push to a repository to start running it in the GitHub CI.",
"filePanel.solghaction": "Add Solidity GitHub Action",
"filePanel.workspace.solghaction": "Adds a preset yml file to run solidity unit tests on github actions CI.",
"filePanel.solghaction": "Add Solidity Test Workflow",
"filePanel.workspace.tssoltestghaction": "Adds a preset yml file to run mocha and chai tests for solidity on github actions CI",
"filePanel.tssoltestghaction": "Add Mocha Chai Test Workflow",
"filePanel.workspace.slitherghaction": "Adds a preset yml file to run slither analysis on github actions CI",
"filePanel.slitherghaction": "Add Slither Workflow",
"filePanel.newFile": "New File",
"filePanel.newFolder": "New Folder",
"filePanel.rename": "Rename",

@ -7,7 +7,7 @@ import { addSlash, checkSlash, checkSpecialChars } from '@remix-ui/helper'
import { JSONStandardInput, WorkspaceTemplate } from '../types'
import { QueryParams } from '@remix-project/remix-lib'
import * as templateWithContent from '@remix-project/remix-ws-templates'
import { ROOT_PATH } from '../utils/constants'
import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } 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'
@ -612,25 +612,23 @@ export const createNewBranch = async (branch: string) => {
}
export const createSolidityGithubAction = async () => {
const actionYml = `
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: Run SUT Action
uses: EthereumRemix/sol-test@v1
with:
test-path: 'tests'
compiler-version: '0.8.15'
`
const path = '.github/workflows/run-solidity-unittesting.yml'
await plugin.call('fileManager', 'writeFile', path , actionYml)
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)
}

@ -37,7 +37,9 @@ export const FileSystemContext = createContext<{
dispatchSwitchToBranch: (branch: string) => Promise<void>,
dispatchCreateNewBranch: (branch: string) => Promise<void>,
dispatchCheckoutRemoteBranch: (branch: string, remote: string) => Promise<void>,
dispatchCreateSolidityGithubAction: () => Promise<void>
dispatchCreateSolidityGithubAction: () => Promise<void>,
dispatchCreateTsSolGithubAction: () => Promise<void>,
dispatchCreateSlitherGithubAction: () => Promise<void>
}>(null)

@ -8,7 +8,7 @@ import { browserReducer, browserInitialState } from '../reducers/workspace'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder,
deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace,
fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip, cloneRepository, moveFile, moveFolder,
showAllBranches, switchBranch, createNewBranch, checkoutRemoteBranch, createSolidityGithubAction
showAllBranches, switchBranch, createNewBranch, checkoutRemoteBranch, createSolidityGithubAction, createTsSolGithubAction, createSlitherGithubAction
} from '../actions'
import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -159,6 +159,14 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await createSolidityGithubAction()
}
const dispatchCreateTsSolGithubAction = async () => {
await createTsSolGithubAction()
}
const dispatchCreateSlitherGithubAction = async () => {
await createSlitherGithubAction()
}
useEffect(() => {
dispatchInitWorkspace()
}, [])
@ -268,7 +276,9 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchSwitchToBranch,
dispatchCreateNewBranch,
dispatchCheckoutRemoteBranch,
dispatchCreateSolidityGithubAction
dispatchCreateSolidityGithubAction,
dispatchCreateTsSolGithubAction,
dispatchCreateSlitherGithubAction
}
return (
<FileSystemContext.Provider value={value}>

@ -103,6 +103,14 @@ export function Workspace () {
global.dispatchCreateSolidityGithubAction()
}
const addTsSolTestGithubAction = () => {
global.dispatchCreateTsSolGithubAction()
}
const addSlitherGithubAction = () => {
global.dispatchCreateSlitherGithubAction()
}
const downloadWorkspaces = async () => {
try {
await global.dispatchHandleDownloadFiles()
@ -560,18 +568,7 @@ export function Workspace () {
tooltipClasses="text-nowrap"
tooltipText={<FormattedMessage id='filePanel.workspace.solghaction' />}
>
<div
data-id='soliditygithubaction'
onClick={(e) => {
e.stopPropagation()
addGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSolidityTesting'])
hideIconsMenu(!showIconsMenu)
}}
>
<span
hidden={currentWorkspace === LOCALHOST}
id='soliditygithubaction'
<div
data-id='soliditygithubaction'
onClick={(e) => {
e.stopPropagation()
@ -579,12 +576,85 @@ export function Workspace () {
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSolidityTesting'])
hideIconsMenu(!showIconsMenu)
}}
className='fab fa-github pl-2'
>
</span>
<span className="pl-3">{<FormattedMessage id='filePanel.solghaction' />}</span>
</div>
</CustomTooltip>
<span
hidden={currentWorkspace === LOCALHOST}
id='soliditygithubaction'
data-id='soliditygithubaction'
onClick={(e) => {
e.stopPropagation()
addGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSolidityTesting'])
hideIconsMenu(!showIconsMenu)
}}
className='fab fa-github pl-2'
>
</span>
<span className="pl-3">{<FormattedMessage id='filePanel.solghaction' />}</span>
</div>
</CustomTooltip>,
<CustomTooltip
placement="right-start"
tooltipId="createTsSolTestGHActionTooltip"
tooltipClasses="text-nowrap"
tooltipText={<FormattedMessage id='filePanel.workspace.tssoltestghaction' />}
>
<div
data-id='typescriptsoliditygithubtestaction'
onClick={(e) => {
e.stopPropagation()
addTsSolTestGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addTsSolTestingAction'])
hideIconsMenu(!showIconsMenu)
}}
>
<span
hidden={currentWorkspace === LOCALHOST}
id='tssoliditygithubaction'
data-id='tssoliditygithubaction'
onClick={(e) => {
e.stopPropagation()
addTsSolTestGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addTsSolTestingAction'])
hideIconsMenu(!showIconsMenu)
}}
className='fab fa-github pl-2'
>
</span>
<span className="pl-3">{<FormattedMessage id='filePanel.tssoltestghaction' />}</span>
</div>
</CustomTooltip>,
<CustomTooltip
placement="right-start"
tooltipId="createSlitherGHActionTooltip"
tooltipClasses="text-nowrap"
tooltipText={<FormattedMessage id='filePanel.workspace.slitherghaction' />}
>
<div
data-id='slithergithubtestaction'
onClick={(e) => {
e.stopPropagation()
addSlitherGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSlitherAction'])
hideIconsMenu(!showIconsMenu)
}}
>
<span
hidden={currentWorkspace === LOCALHOST}
id='slithergithubaction'
data-id='slithergithubaction'
onClick={(e) => {
e.stopPropagation()
addSlitherGithubAction()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSlitherAction'])
hideIconsMenu(!showIconsMenu)
}}
className='fab fa-github pl-2'
>
</span>
<span className="pl-3">{<FormattedMessage id='filePanel.slitherghaction' />}</span>
</div>
</CustomTooltip>
]
const menuLength = workspaceMenuIcons.length
let count = 0
@ -640,22 +710,6 @@ export function Workspace () {
)
})
}
<Dropdown.Item>
<DropdownButton
as={ButtonGroup}
key={'end'}
id={'dropdown-button-drop-end'}
drop={'right'}
variant="secondary"
title={'Drop end'}
>
<Dropdown.Item eventKey="1">Action</Dropdown.Item>
<Dropdown.Item eventKey="2">Another action</Dropdown.Item>
<Dropdown.Item eventKey="3">Something else here</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Item eventKey="4">Separated link</Dropdown.Item>
</DropdownButton>
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</span>) : null}

@ -1 +1,48 @@
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: Run SUT Action
uses: EthereumRemix/sol-test@v1
with:
test-path: 'tests'
compiler-version: '0.8.15'
`
export const tsSolTestYml = `
name: ts-sol-test
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: Run SUT Action
uses: EthereumRemix/ts-sol-test@v0.1.4-dev
with:
test-path: 'tests'
contract-path: 'contracts'
compiler-version: '0.8.7'
`
export const slitherYml = `
name: Slither Analysis
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crytic/slither-action@v0.2.0
with:
target: 'src/'
`

Loading…
Cancel
Save