Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 298eea4

Browse files
authored
refactor: update to for era-test-node rename (#7)
* fix: update to handle repo renaming * fix: update to handle repo renaming
1 parent 36ffd2e commit 298eea4

9 files changed

+462
-1276
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Era Test Node Action 🚀
22

3+
### ⚠️ Warning
4+
5+
This action has been **archived** in favor of [`anvil-zksync-action`](https://github.com/dutterbutter/anvil-zksync-action).
6+
By default, this action fetches version `v0.1.0-alpha.34` of `era-test-node` unless a different tag is specified, as this was the last release before the binary was renamed. Tags past this may not work given the binary difference.
7+
38
## Description
49

510
This GitHub Action runs the [`era_test_node`](https://github.com/matter-labs/era-test-node) with various options. It allows for high configurability and makes it easy to integrate `era_test_node` into your CI/CD workflows on GitHub Actions.

dist/338.index.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"use strict";exports.id=338,exports.ids=[338],exports.modules={1338:(e,t,n)=>{var a=Object.defineProperty,r=(e,t)=>a(e,"name",{value:t,configurable:!0});n(3024),n(4379);const o=n(529);n(7067),n(4708),n(8522),n(7075),n(4573),n(7975),n(5453),n(3136),n(7030);let i=0;const s={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++};let d=1;const E=d,A=d*=2,l=r((e=>32|e),"lower"),h=r((()=>{}),"noop"),D=class{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=h,this.onHeaderField=h,this.onHeadersEnd=h,this.onHeaderValue=h,this.onPartBegin=h,this.onPartData=h,this.onPartEnd=h,this.boundaryChars={},e="\r\n--"+e;const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=s.START_BOUNDARY}write(e){let t=0;const n=e.length;let a=this.index,{lookbehind:o,boundary:i,boundaryChars:d,index:h,state:D,flags:c}=this;const T=this.boundary.length,f=T-1,_=e.length;let u,R;const b=r((e=>{this[e+"Mark"]=t}),"mark"),H=r((e=>{delete this[e+"Mark"]}),"clear"),p=r(((e,t,n,a)=>{(void 0===t||t!==n)&&this[e](a&&a.subarray(t,n))}),"callback"),P=r(((n,a)=>{const r=n+"Mark";r in this&&(a?(p(n,this[r],t,e),delete this[r]):(p(n,this[r],e.length,e),this[r]=0))}),"dataCallback");for(t=0;t<n;t++)switch(u=e[t],D){case s.START_BOUNDARY:if(h===i.length-2){if(45===u)c|=A;else if(13!==u)return;h++;break}if(h-1==i.length-2){if(c&A&&45===u)D=s.END,c=0;else{if(c&A||10!==u)return;h=0,p("onPartBegin"),D=s.HEADER_FIELD_START}break}u!==i[h+2]&&(h=-2),u===i[h+2]&&h++;break;case s.HEADER_FIELD_START:D=s.HEADER_FIELD,b("onHeaderField"),h=0;case s.HEADER_FIELD:if(13===u){H("onHeaderField"),D=s.HEADERS_ALMOST_DONE;break}if(h++,45===u)break;if(58===u){if(1===h)return;P("onHeaderField",!0),D=s.HEADER_VALUE_START;break}if(R=l(u),R<97||R>122)return;break;case s.HEADER_VALUE_START:if(32===u)break;b("onHeaderValue"),D=s.HEADER_VALUE;case s.HEADER_VALUE:13===u&&(P("onHeaderValue",!0),p("onHeaderEnd"),D=s.HEADER_VALUE_ALMOST_DONE);break;case s.HEADER_VALUE_ALMOST_DONE:if(10!==u)return;D=s.HEADER_FIELD_START;break;case s.HEADERS_ALMOST_DONE:if(10!==u)return;p("onHeadersEnd"),D=s.PART_DATA_START;break;case s.PART_DATA_START:D=s.PART_DATA,b("onPartData");case s.PART_DATA:if(a=h,0===h){for(t+=f;t<_&&!(e[t]in d);)t+=T;t-=f,u=e[t]}if(h<i.length)i[h]===u?(0===h&&P("onPartData",!0),h++):h=0;else if(h===i.length)h++,13===u?c|=E:45===u?c|=A:h=0;else if(h-1===i.length)if(c&E){if(h=0,10===u){c&=~E,p("onPartEnd"),p("onPartBegin"),D=s.HEADER_FIELD_START;break}}else c&A&&45===u?(p("onPartEnd"),D=s.END,c=0):h=0;if(h>0)o[h-1]=u;else if(a>0){const e=new Uint8Array(o.buffer,o.byteOffset,o.byteLength);p("onPartData",0,a,e),a=0,b("onPartData"),t--}break;case s.END:break;default:throw new Error(`Unexpected state entered: ${D}`)}P("onHeaderField"),P("onHeaderValue"),P("onPartData"),this.index=h,this.state=D,this.flags=c}end(){if(this.state===s.HEADER_FIELD_START&&0===this.index||this.state===s.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==s.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}};r(D,"MultipartParser");let c=D;function T(e){const t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;const n=t[2]||t[3]||"";let a=n.slice(n.lastIndexOf("\\")+1);return a=a.replace(/%22/g,'"'),a=a.replace(/&#(\d{4});/g,((e,t)=>String.fromCharCode(t))),a}async function f(e,t){if(!/multipart/i.test(t))throw new TypeError("Failed to fetch");const n=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new TypeError("no or bad content-type header, no multipart boundary");const a=new c(n[1]||n[2]);let i,s,d,E,A,l;const h=[],D=new o.FormData,f=r((e=>{d+=b.decode(e,{stream:!0})}),"onPartData"),_=r((e=>{h.push(e)}),"appendToFile"),u=r((()=>{const e=new o.File(h,l,{type:A});D.append(E,e)}),"appendFileToFormData"),R=r((()=>{D.append(E,d)}),"appendEntryToFormData"),b=new TextDecoder("utf-8");b.decode(),a.onPartBegin=function(){a.onPartData=f,a.onPartEnd=R,i="",s="",d="",E="",A="",l=null,h.length=0},a.onHeaderField=function(e){i+=b.decode(e,{stream:!0})},a.onHeaderValue=function(e){s+=b.decode(e,{stream:!0})},a.onHeaderEnd=function(){if(s+=b.decode(),i=i.toLowerCase(),"content-disposition"===i){const e=s.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(E=e[2]||e[3]||""),l=T(s),l&&(a.onPartData=_,a.onPartEnd=u)}else"content-type"===i&&(A=s);s="",i=""};for await(const t of e)a.write(t);return a.end(),D}r(T,"_fileName"),r(f,"toFormData"),t.toFormData=f}};

dist/794.index.cjs

-1
This file was deleted.

dist/index.cjs

+1-1
Large diffs are not rendered by default.

dist/index.cjs.LICENSE.txt

+22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1+
/*!
2+
* mime-db
3+
* Copyright(c) 2014 Jonathan Ong
4+
* Copyright(c) 2015-2022 Douglas Christopher Wilson
5+
* MIT Licensed
6+
*/
7+
8+
/*!
9+
* mime-types
10+
* Copyright(c) 2014 Jonathan Ong
11+
* Copyright(c) 2015 Douglas Christopher Wilson
12+
* MIT Licensed
13+
*/
14+
115
/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
216

317
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
418

519
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
620

721
/*! ws. MIT License. Einar Otto Stangvik <[email protected]> */
22+
23+
/**
24+
* @license
25+
* web-streams-polyfill v3.3.3
26+
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
27+
* This code is released under the MIT license.
28+
* SPDX-License-Identifier: MIT
29+
*/

index.cjs

+65-53
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
1-
const { getInput, setFailed, addPath } = require('@actions/core');
2-
const { exec } = require('@actions/exec');
3-
const tc = require('@actions/tool-cache');
4-
const { spawn } = require('child_process');
5-
const { fetch } = require('ofetch');
6-
const axios = require('axios');
1+
const { getInput, setFailed, addPath } = require("@actions/core");
2+
const { exec } = require("@actions/exec");
3+
const tc = require("@actions/tool-cache");
4+
const { spawn } = require("child_process");
5+
const { fetch } = require("ofetch");
6+
const axios = require("axios");
77

8-
const ERA_TEST_NODE_RELEASE_TAG = getInput('releaseTag') || 'latest';
9-
const ERA_TEST_NODE_ARCH = getInput('target') || 'x86_64-unknown-linux-gnu';
8+
const ERA_TEST_NODE_RELEASE_TAG = getInput("releaseTag") || "latest";
9+
const ERA_TEST_NODE_ARCH = getInput("target") || "x86_64-unknown-linux-gnu";
1010

1111
async function getDownloadUrl() {
1212
let apiUrl;
13-
if (ERA_TEST_NODE_RELEASE_TAG === 'latest') {
14-
apiUrl = 'https://api.github.com/repos/matter-labs/era-test-node/releases/latest';
13+
if (ERA_TEST_NODE_RELEASE_TAG === "latest") {
14+
apiUrl =
15+
"https://api.github.com/repos/matter-labs/era-test-node/releases/tags/v0.1.0-alpha.34";
1516
} else {
1617
apiUrl = `https://api.github.com/repos/matter-labs/era-test-node/releases/tags/${ERA_TEST_NODE_RELEASE_TAG}`;
1718
}
1819

1920
const response = await fetch(apiUrl);
2021
if (!response.ok) {
21-
throw new Error(`Failed to fetch release info for tag ${ERA_TEST_NODE_RELEASE_TAG}. HTTP Status: ${response.status}`);
22+
throw new Error(
23+
`Failed to fetch release info for tag ${ERA_TEST_NODE_RELEASE_TAG}. HTTP Status: ${response.status}`
24+
);
2225
}
2326

2427
const releaseInfo = await response.json();
2528

2629
if (!releaseInfo || !releaseInfo.assets || !releaseInfo.assets.length) {
27-
throw new Error(`Release assets for tag ${ERA_TEST_NODE_RELEASE_TAG} are not available.`);
30+
throw new Error(
31+
`Release assets for tag ${ERA_TEST_NODE_RELEASE_TAG} are not available.`
32+
);
2833
}
2934

30-
const assetInfo = releaseInfo.assets.find(asset => asset.name.includes(ERA_TEST_NODE_ARCH));
35+
const assetInfo = releaseInfo.assets.find((asset) =>
36+
asset.name.includes(ERA_TEST_NODE_ARCH)
37+
);
3138
if (!assetInfo) {
3239
throw new Error(`Asset with architecture ${ERA_TEST_NODE_ARCH} not found.`);
3340
}
@@ -37,101 +44,106 @@ async function getDownloadUrl() {
3744

3845
async function run() {
3946
try {
40-
const mode = getInput('mode') || 'run';
41-
const network = getInput('network');
42-
const forkAtHeight = getInput('forkAtHeight');
43-
const port = getInput('port');
44-
const showCalls = getInput('showCalls');
45-
const showStorageLogs = getInput('showStorageLogs');
46-
const showVmDetails = getInput('showVmDetails');
47-
const showGasDetails = getInput('showGasDetails');
48-
const resolveHashes = getInput('resolveHashes');
49-
const log = getInput('log');
50-
const logFilePath = getInput('logFilePath');
51-
52-
let toolPath = tc.find('era_test_node', ERA_TEST_NODE_RELEASE_TAG);
47+
const mode = getInput("mode") || "run";
48+
const network = getInput("network");
49+
const forkAtHeight = getInput("forkAtHeight");
50+
const port = getInput("port");
51+
const showCalls = getInput("showCalls");
52+
const showStorageLogs = getInput("showStorageLogs");
53+
const showVmDetails = getInput("showVmDetails");
54+
const showGasDetails = getInput("showGasDetails");
55+
const resolveHashes = getInput("resolveHashes");
56+
const log = getInput("log");
57+
const logFilePath = getInput("logFilePath");
58+
59+
let toolPath = tc.find("era_test_node", ERA_TEST_NODE_RELEASE_TAG);
5360

5461
if (!toolPath) {
5562
const downloadUrl = await getDownloadUrl();
5663
const tarFile = await tc.downloadTool(downloadUrl);
5764
const extractedDir = await tc.extractTar(tarFile);
58-
toolPath = await tc.cacheDir(extractedDir, 'era_test_node', ERA_TEST_NODE_RELEASE_TAG);
65+
toolPath = await tc.cacheDir(
66+
extractedDir,
67+
"era_test_node",
68+
ERA_TEST_NODE_RELEASE_TAG
69+
);
5970
}
6071
addPath(toolPath);
6172

62-
await exec('chmod', ['+x', `${toolPath}/era_test_node`]);
73+
await exec("chmod", ["+x", `${toolPath}/era_test_node`]);
6374

6475
let args = [];
6576

6677
if (port) {
67-
args.push('--port', port);
78+
args.push("--port", port);
6879
}
6980
if (showCalls) {
70-
args.push('--show-calls', showCalls);
81+
args.push("--show-calls", showCalls);
7182
}
7283
if (showStorageLogs) {
73-
args.push('--show-storage-logs', showStorageLogs);
84+
args.push("--show-storage-logs", showStorageLogs);
7485
}
7586
if (showVmDetails) {
76-
args.push('--show-vm-details', showVmDetails);
87+
args.push("--show-vm-details", showVmDetails);
7788
}
7889
if (showGasDetails) {
79-
args.push('--show-gas-details', showGasDetails);
90+
args.push("--show-gas-details", showGasDetails);
8091
}
81-
if (resolveHashes === 'true') {
82-
args.push('--resolve-hashes');
92+
if (resolveHashes === "true") {
93+
args.push("--resolve-hashes");
8394
}
8495
if (log) {
85-
args.push('--log', log);
96+
args.push("--log", log);
8697
}
8798
if (logFilePath) {
88-
args.push('--log-file-path', logFilePath);
99+
args.push("--log-file-path", logFilePath);
89100
}
90-
if (mode === 'fork') {
91-
args.push('fork');
101+
if (mode === "fork") {
102+
args.push("fork");
92103
if (network) {
93104
args.push(network);
94105
}
95106
if (forkAtHeight) {
96-
args.push('--fork-at', forkAtHeight);
107+
args.push("--fork-at", forkAtHeight);
97108
}
98109
} else {
99-
args.push('run');
110+
args.push("run");
100111
}
101112

102-
console.log('Starting era_test_node with args:', args);
113+
console.log("Starting era_test_node with args:", args);
103114

104115
const child = spawn(`${toolPath}/era_test_node`, args, {
105116
detached: true,
106-
stdio: 'ignore'
117+
stdio: "ignore",
107118
});
108119

109-
child.on('error', (error) => {
120+
child.on("error", (error) => {
110121
console.error(`Failed to start child process: ${error}`);
111122
});
112123

113-
child.on('exit', (code, signal) => {
124+
child.on("exit", (code, signal) => {
114125
if (code) {
115126
console.log(`Child process exited with code ${code}`);
116127
} else if (signal) {
117128
console.log(`Child process killed with signal ${signal}`);
118129
} else {
119-
console.log('Child process exited');
130+
console.log("Child process exited");
120131
}
121132
});
122133

123134
child.unref();
124135
// sanity check
125136
// Adding a timeout to give the node some time to start up before checking
126137
setTimeout(async () => {
127-
if(port && await isNodeRunning(port)) {
138+
if (port && (await isNodeRunning(port))) {
128139
console.log(`Confirmed: era_test_node is running on port ${port}`);
129140
} else {
130-
console.error('Health check failed: era_test_node appears to be not running.');
131-
setFailed('Failed to start era_test_node');
141+
console.error(
142+
"Health check failed: era_test_node appears to be not running."
143+
);
144+
setFailed("Failed to start era_test_node");
132145
}
133146
}, 5000);
134-
135147
} catch (error) {
136148
setFailed(error.message);
137149
}
@@ -145,10 +157,10 @@ async function isNodeRunning(port) {
145157
jsonrpc: "2.0",
146158
id: 1,
147159
method: "eth_blockNumber",
148-
params: []
160+
params: [],
149161
});
150-
return (response.data && response.data.result !== undefined);
162+
return response.data && response.data.result !== undefined;
151163
} catch (error) {
152164
return false;
153165
}
154-
}
166+
}

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"@actions/core": "^1.10.1",
1616
"@actions/exec": "^1.1.1",
1717
"@actions/tool-cache": "^2.0.1",
18+
"axios": "^1.7.8",
19+
"debug": "^4.3.7",
1820
"ofetch": "^1.3.3"
1921
},
2022
"devDependencies": {

0 commit comments

Comments
 (0)