remixd script

pull/3285/head
filip mertens 2 years ago
parent c3c3c8652f
commit c1f4d1ef63
  1. 42
      .circleci/config.yml
  2. 23
      apps/remix-ide/ci/remixd_test.sh
  3. 61
      libs/remixd/src/services/foundryClient.ts

@ -76,6 +76,43 @@ jobs:
- run: node dist/libs/remix-tests/bin/remix-tests ./libs/remix-tests/tests/examples_0/assert_ok_test.sol - run: node dist/libs/remix-tests/bin/remix-tests ./libs/remix-tests/tests/examples_0/assert_ok_test.sol
- run: yarn run test:libs - run: yarn run test:libs
remixd:
docker:
- image: cimg/node:14.17.6-browsers
resource_class:
xlarge
working_directory: ~/remix-project
steps:
- browser-tools/install-browser-tools
- run:
command: |
google-chrome --version
firefox --version
geckodriver --version
chromedriver --version
rm LICENSE.chromedriver 2> /dev/null
- checkout
- attach_workspace:
at: .
- run: unzip ./persist/dist.zip
- restore_cache:
keys:
- v1-deps-{{ checksum "yarn.lock" }}
- run: yarn
- run: yarn run downloadsolc_assets_e2e && yarn run downloadsolc_assets_dist
- run: ls -la ./dist/apps/remix-ide/assets/js
- run: yarn run selenium-install || yarn run selenium-install
- run:
name: Start Selenium
command: yarn run selenium
background: true
- run: ./apps/remix-ide/ci/remixd_test.sh
- store_test_results:
path: ./reports/tests
- store_artifacts:
path: ./reports/screenshots
remix-ide-browser: remix-ide-browser:
docker: docker:
- image: cimg/node:14.17.6-browsers - image: cimg/node:14.17.6-browsers
@ -273,6 +310,9 @@ workflows:
matrix: matrix:
parameters: parameters:
script: ["browser_tests_plugin_api.sh", "browser_tests_etherscan_plugin.sh", "browser_tests_vyper_plugin.sh"] script: ["browser_tests_plugin_api.sh", "browser_tests_etherscan_plugin.sh", "browser_tests_vyper_plugin.sh"]
- remixd:
requires:
- build
- remix-ide-browser: - remix-ide-browser:
requires: requires:
- build - build
@ -316,4 +356,4 @@ workflows:
branches: branches:
only: remix_beta only: remix_beta
# VS Code Extension Version: 1.5.0 # VS Code Extension Version: 1.5.1

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}}
echo "$BUILD_ID"
TEST_EXITCODE=0
# install foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge init foundry
ls -la foundry
sleep 5
yarn run build:e2e
echo "$TEST_EXITCODE"
if [ "$TEST_EXITCODE" -eq 1 ]
then
exit 1
fi

@ -14,6 +14,8 @@ export class FoundryClient extends PluginClient {
warnlog: boolean warnlog: boolean
buildPath: string buildPath: string
cachePath: string cachePath: string
logTimeout: NodeJS.Timeout
processingTimeout: NodeJS.Timeout
constructor(private readOnly = false) { constructor(private readOnly = false) {
super() super()
@ -36,12 +38,13 @@ export class FoundryClient extends PluginClient {
this.listenOnFoundryCompilation() this.listenOnFoundryCompilation()
} else { } else {
console.log('Foundry out folder doesn\'t exist... waiting for the first compilation.') console.log('Foundry out folder doesn\'t exist... waiting for the first compilation.')
this.listenOFoundryFolder() this.listenOnFoundryFolder()
} }
} }
listenOFoundryFolder() {
listenOnFoundryFolder() {
try { try {
this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true }) this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true })
// watch for new folders // watch for new folders
@ -55,7 +58,7 @@ export class FoundryClient extends PluginClient {
} }
} }
compile(configPath: string) { compile() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.readOnly) { if (this.readOnly) {
const errMsg = '[Foundry Compilation]: Cannot compile in read-only mode' const errMsg = '[Foundry Compilation]: Cannot compile in read-only mode'
@ -82,9 +85,19 @@ export class FoundryClient extends PluginClient {
}) })
} }
checkPath() {
console.log('checkPath', fs.existsSync(this.buildPath), fs.existsSync(this.cachePath), fs.existsSync(join(this.cachePath, 'solidity-files-cache.json')))
if (!fs.existsSync(this.buildPath) || !fs.existsSync(this.cachePath)) {
this.listenOnFoundryFolder()
return false
}
if (!fs.existsSync(join(this.cachePath, 'solidity-files-cache.json'))) return false
return true
}
private async processArtifact() { private async processArtifact() {
if (!this.checkPath()) return
const folderFiles = await fs.readdir(this.buildPath) // "out" folder const folderFiles = await fs.readdir(this.buildPath) // "out" folder
if (!fs.existsSync(join(this.cachePath, 'solidity-files-cache.json'))) return
try { try {
const cache = JSON.parse(await fs.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' })) const cache = JSON.parse(await fs.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' }))
// name of folders are file names // name of folders are file names
@ -102,24 +115,32 @@ export class FoundryClient extends PluginClient {
await this.readContract(path, compilationResult, cache) await this.readContract(path, compilationResult, cache)
this.emit('compilationFinished', compilationResult.compilationTarget, { sources: compilationResult.input }, 'soljson', compilationResult.output, compilationResult.solcVersion) this.emit('compilationFinished', compilationResult.compilationTarget, { sources: compilationResult.input }, 'soljson', compilationResult.output, compilationResult.solcVersion)
} }
if (!this.warnlog) {
clearTimeout(this.logTimeout)
this.logTimeout = setTimeout(() => {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', { type: 'log', value: 'receiving compilation result from Foundry' }) this.call('terminal', 'log', { type: 'log', value: 'receiving compilation result from Foundry' }), 1000
this.warnlog = true })
}
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
async triggerProcessArtifact() {
// prevent multiple calls
clearTimeout(this.processingTimeout)
this.processingTimeout = setTimeout(async () => await this.processArtifact(), 1000)
}
listenOnFoundryCompilation() { listenOnFoundryCompilation() {
try { try {
this.watcher = chokidar.watch(this.cachePath, { depth: 0, ignorePermissionErrors: true, ignoreInitial: true }) this.watcher = chokidar.watch(this.cachePath, { depth: 0, ignorePermissionErrors: true, ignoreInitial: true })
this.watcher.on('change', async (f: string) => this.processArtifact()) this.watcher.on('change', async () => await this.triggerProcessArtifact())
this.watcher.on('add', async (f: string) => this.processArtifact()) this.watcher.on('add', async () => await this.triggerProcessArtifact())
// process the artifact on activation // process the artifact on activation
setTimeout(() => this.processArtifact(), 1000) this.triggerProcessArtifact()
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
@ -188,19 +209,7 @@ export class FoundryClient extends PluginClient {
} }
async sync() { async sync() {
console.log('syncing from Foundry') console.log('syncing Foundry with Remix...')
if (fs.existsSync(this.buildPath) && fs.existsSync(this.cachePath)) { this.processArtifact()
if (!fs.existsSync(join(this.cachePath, 'solidity-files-cache.json'))) {
console.log('No compilation data found')
// @ts-ignore
this.call('terminal', 'log', { type: 'log', value: 'No compilation data found' })
} else{
this.processArtifact()
// @ts-ignore
this.call('terminal', 'log', { type: 'log', value: 'synced with Foundry' })
}
} else {
this.listenOFoundryFolder()
}
} }
} }

Loading…
Cancel
Save