Skip to content

Commit 567ad9f

Browse files
committed
Fix on CLI offline install and offline test runner
1 parent d5db6fb commit 567ad9f

12 files changed

+153
-115
lines changed

.github/workflows/test_offline.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
uses: actions/download-artifact@v5
5757
with:
5858
pattern: build-info-*-${{ matrix.package_name }}
59-
merge-multiple: true
6059
path: ./artifacts
6160
github-token: ${{ secrets.GITHUB_TOKEN }}
6261
run-id: ${{ inputs.run_id }}
@@ -66,7 +65,7 @@ jobs:
6665
- name: Download latest EIM CLI binary (non-Windows)
6766
if: matrix.os != 'windows-latest'
6867
run: |
69-
latest_release=$(curl -s https://api.github.com/repos/espressif/idf-im-ui/releases/latest)
68+
latest_release=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/espressif/idf-im-ui/releases/latest)
7069
eim_cli_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | test("eim-cli-${{matrix.package_name}}.zip")) | .browser_download_url')
7170
curl -L -o ./artifacts/eim-cli.zip "$eim_cli_url"
7271
@@ -106,9 +105,9 @@ jobs:
106105
- name: Download latest EIM CLI binary (Windows)
107106
if: matrix.os == 'windows-latest'
108107
run: |
109-
latest_release=$(curl -s https://api.github.com/repos/espressif/idf-im-ui/releases/latest)
110-
eim_cli_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | test("eim-cli-${{matrix.package_name}}.exe")) | .browser_download_url')
111-
curl -L -o ./artifacts/eim-cli.exe "$eim_cli_url"
108+
$latest_release = Invoke-RestMethod -Uri "https://api.github.com/repos/espressif/idf-im-ui/releases/latest"
109+
$eim_cli_url = $latest_release.assets | Where-Object { $_.name -like "eim-cli-${{ matrix.package_name }}.exe" } | Select-Object -ExpandProperty browser_download_url
110+
Invoke-WebRequest -Uri $eim_cli_url -OutFile ".\artifacts\eim-cli.exe"
112111
113112
ls ./artifacts/
114113

tests/CLIRunner.test.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
TOOLSFOLDER,
4040
runInDebug,
4141
} from "./config.js";
42-
import { downloadOfflineArchive } from "./helper.js";
4342
import os from "os";
4443
import path from "path";
4544
import fs from "fs";
@@ -60,40 +59,47 @@ function testRun(jsonScript) {
6059
if (test.type === "prerequisites") {
6160
//route for prerequisites tests
6261

63-
describe(`Test${test.id} - ${test.name} ->`, function () {
62+
describe(`Test${test.id}- ${test.name} |`, function () {
6463
this.timeout(20000);
6564

66-
runCLIPrerequisitesTest(pathToEIMCLI);
65+
runCLIPrerequisitesTest({ id: `${test.id}1`, pathToEim: pathToEIMCLI });
6766
});
6867
} else if (test.type === "arguments") {
6968
//routine for arguments tests
7069

71-
describe(`Test${test.id} - ${test.name} ->`, function () {
70+
describe(`Test${test.id}- ${test.name} |`, function () {
7271
this.timeout(20000);
7372

74-
runCLIArgumentsTest(pathToEIMCLI, EIMCLIVersion);
73+
runCLIArgumentsTest({
74+
id: `${test.id}1`,
75+
pathToEim: pathToEIMCLI,
76+
eimVersion: EIMCLIVersion,
77+
});
7578
});
7679
} else if (test.type === "default") {
7780
//routine for default installation tests
7881

7982
const deleteAfterTest = test.deleteAfterTest ?? true;
8083
const testProxyMode = test.testProxyMode ?? false;
8184

82-
describe(`Test${test.id} - ${test.name} ->`, function () {
85+
describe(`Test${test.id}- ${test.name} |`, function () {
8386
this.timeout(6000000);
8487

8588
runCLIWizardInstallTest({
89+
id: `${test.id}1`,
8690
pathToEim: pathToEIMCLI,
8791
testProxyMode,
8892
});
8993

9094
runInstallVerification({
95+
id: `${test.id}2`,
9196
installFolder: INSTALLFOLDER,
9297
idfList: [IDFDefaultVersion],
9398
toolsFolder: TOOLSFOLDER,
9499
});
95100

96101
runCleanUp({
102+
id: `${test.id}3`,
97103
installFolder: INSTALLFOLDER,
98104
toolsFolder: TOOLSFOLDER,
99105
deleteAfterTest,
@@ -141,23 +147,26 @@ function testRun(jsonScript) {
141147
const deleteAfterTest = test.deleteAfterTest ?? true;
142148
const testProxyMode = test.testProxyMode ?? false;
143149

144-
describe(`Test${test.id} - ${test.name} ->`, function () {
150+
describe(`Test${test.id}- ${test.name} |`, function () {
145151
this.timeout(6000000);
146152

147153
runCLICustomInstallTest({
154+
id: `${test.id}1`,
148155
pathToEim: pathToEIMCLI,
149156
args: installArgs,
150157
testProxyMode,
151158
});
152159

153160
runInstallVerification({
161+
id: `${test.id}2`,
154162
installFolder,
155163
idfList: idfUpdatedList,
156164
targetList,
157165
toolsFolder: TOOLSFOLDER,
158166
});
159167

160168
runCleanUp({
169+
id: `${test.id}3`,
161170
installFolder,
162171
toolsFolder: TOOLSFOLDER,
163172
deleteAfterTest,
@@ -177,10 +186,11 @@ function testRun(jsonScript) {
177186
? path.join(os.homedir(), test.data.installFolder)
178187
: INSTALLFOLDER;
179188

180-
describe(`Test${test.id} - ${test.name} ->`, function () {
189+
describe(`Test${test.id}- ${test.name} |`, function () {
181190
this.timeout(60000);
182191

183192
runVersionManagementTest({
193+
id: `${test.id}1`,
184194
pathToEim: pathToEIMCLI,
185195
idfList: idfUpdatedList,
186196
installFolder,
@@ -191,32 +201,25 @@ function testRun(jsonScript) {
191201
const deleteAfterTest = test.deleteAfterTest ?? true;
192202
const testProxyMode = test.testProxyMode ?? "block";
193203

194-
describe(`Test${test.id} - ${test.name} ->`, async function () {
204+
describe(`Test${test.id}- ${test.name} |`, async function () {
195205
this.timeout(6000000);
196206

197-
const pathToOfflineArchive = await downloadOfflineArchive({
198-
idfVersion: IDFDefaultVersion,
199-
});
200-
201-
const offlineArg = [
202-
`${
203-
runInDebug ? "-vvv " : ""
204-
}--use-local-archive "${pathToOfflineArchive}"`,
205-
];
206-
207207
runCLICustomInstallTest({
208+
id: `${test.id}1`,
208209
pathToEim: pathToEIMCLI,
209-
args: offlineArg,
210+
offlineIDFVersion: IDFDefaultVersion,
210211
testProxyMode,
211212
});
212213

213214
runInstallVerification({
215+
id: `${test.id}2`,
214216
installFolder: INSTALLFOLDER,
215217
idfList: [IDFDefaultVersion],
216218
toolsFolder: TOOLSFOLDER,
217219
});
218220

219221
runCleanUp({
222+
id: `${test.id}3`,
220223
installFolder: INSTALLFOLDER,
221224
toolsFolder: TOOLSFOLDER,
222225
deleteAfterTest,

tests/config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
import { log } from "console";
78
import logger from "./classes/logger.class.js";
89
import os from "os";
910
import path from "path";
@@ -75,12 +76,17 @@ const TOOLSMIRRORS = {
7576
// Default versions for EIM CLI and GUI for offline testing
7677
const EIMCLIVersion = process.env.EIM_CLI_VERSION || "eim 0.5.0";
7778
const EIMGUIVersion = process.env.EIM_GUI_VERSION || "0.5.0";
79+
logger.info(
80+
`EIM CLI version set to: ${EIMCLIVersion} and GUI to: ${EIMGUIVersion}`
81+
);
7882

7983
// Get platform name from environmental variables
80-
const pkgName =
81-
process.env.PACKAGE_NAME || os.platform() !== "win32"
82-
? "windows-x64"
83-
: "linux-x64";
84+
const pkgName = process.env.PACKAGE_NAME
85+
? process.env.PACKAGE_NAME
86+
: os.platform() === "win32"
87+
? "windows-x64"
88+
: "linux-x64";
89+
logger.info(`Package name set to: ${pkgName}`);
8490

8591
// Default path to EIM CLI and GUI executables for offline testing
8692
//Should use path provided by environment variables or default to home directory
@@ -95,22 +101,29 @@ const getEIMPath = (pathFromCI, defaultFolder) =>
95101

96102
const pathToEIMCLI = getEIMPath(process.env.EIM_CLI_PATH, "eim-cli");
97103
const pathToEIMGUI = getEIMPath(process.env.EIM_GUI_PATH, "eim-gui");
104+
logger.info(
105+
`Path to EIM CLI set to: ${pathToEIMCLI} and GUI to: ${pathToEIMGUI}`
106+
);
98107

99108
// Get path for build info file
100109
const pathToBuildInfo = process.env.BUILD_INFO_PATH || "~/build_info";
110+
logger.info(`Path to build info set to: ${pathToBuildInfo}`);
101111

102112
// Default installation folder
103113
const INSTALLFOLDER =
104114
os.platform() !== "win32" ? path.join(os.homedir(), `.espressif`) : `C:\\esp`;
115+
logger.info(`Installation folder set to: ${INSTALLFOLDER}`);
105116

106117
// Default tools folder
107118
const TOOLSFOLDER =
108119
os.platform() !== "win32"
109120
? path.join(os.homedir(), `.espressif`)
110121
: `C:\\Espressif`;
122+
logger.info(`Tools folder set to: ${TOOLSFOLDER}`);
111123

112124
// Enable running EIM in debug mode
113125
const runInDebug = (process.env.DEBUG || "false") === "true";
126+
logger.info(`Run in debug mode: ${runInDebug}`);
114127

115128
export {
116129
IDFMIRRORS,

tests/helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IDFDefaultVersion, pkgName } from "./config.js";
33
import { Readable } from "stream";
44
import { finished } from "stream/promises";
55
import os from "os";
6+
import fs from "fs";
67
import path from "path";
78

89
// Base url for offline archive files
@@ -64,11 +65,12 @@ const downloadOfflineArchive = async ({
6465
packageName = pkgName,
6566
}) => {
6667
const archiveUrl = `${offlineBaseUrl}${idfVersion}_${packageName}.zst`;
68+
6769
const pathToOfflineArchive = path.resolve(
6870
process.cwd(),
6971
`offlineArchive_${idfVersion}.zst`
7072
);
71-
logger.info(`Downloading offline archive from ${archiveUrl}...`);
73+
logger.info(`Downloading offline archive from ${archiveUrl}`);
7274
try {
7375
const res = await fetch(archiveUrl);
7476
if (res.ok) {

tests/offlineRunner.test.js

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,74 +18,72 @@ import {
1818
pathToEIMCLI,
1919
INSTALLFOLDER,
2020
TOOLSFOLDER,
21-
downloadOfflineArchive,
22-
runInDebug,
2321
pathToBuildInfo,
2422
} from "./config.js";
25-
import os from "os";
2623
import path from "path";
2724
import fs from "fs";
2825

29-
let buildInfo = {};
26+
let buildInfo = [];
3027

3128
if (fs.existsSync(pathToBuildInfo)) {
32-
const files = fs
33-
.readdirSync(pathToBuildInfo)
34-
.filter((file) => file.endsWith(".json"));
35-
files.forEach((file) => {
36-
const filePath = path.join(pathToBuildInfo, file);
37-
try {
38-
const content = fs.readFileSync(filePath, "utf8");
39-
const jsonData = JSON.parse(content);
40-
buildInfo[file] = jsonData;
41-
} catch (err) {
42-
logger.error(`Failed to read or parse ${file}: ${err.message}`);
43-
}
44-
});
29+
function readJsonFilesRecursively(dir) {
30+
const entries = fs.readdirSync(dir, { withFileTypes: true });
31+
entries.forEach((entry) => {
32+
const fullPath = path.join(dir, entry.name);
33+
if (entry.isDirectory()) {
34+
readJsonFilesRecursively(fullPath);
35+
} else if (entry.isFile() && entry.name.endsWith(".json")) {
36+
try {
37+
const content = fs.readFileSync(fullPath, "utf8");
38+
const jsonData = JSON.parse(content);
39+
buildInfo.push(jsonData);
40+
} catch (err) {
41+
logger.error(`Failed to read or parse ${fullPath}: ${err.message}`);
42+
}
43+
}
44+
});
45+
}
46+
readJsonFilesRecursively(pathToBuildInfo);
4547
} else {
4648
logger.error(`Directory not found: ${pathToBuildInfo}`);
4749
}
4850

4951
logger.info("Running test script:", buildInfo);
5052

51-
// testRun(buildInfo);
52-
53-
// function testRun(archiveInfo) {
54-
// // run tests for each archive information
55-
// archiveInfo.forEach(async (info) => {
56-
// const pathToOfflineArchive = await downloadOfflineArchive({
57-
// idfVersion: info.version,
58-
// });
59-
60-
// const offlineArg = [
61-
// `${
62-
// runInDebug ? "-vvv " : ""
63-
// }--use-local-archive "${pathToOfflineArchive}"`,
64-
// ];
53+
testRun(buildInfo);
6554

66-
// const deleteAfterTest = test.deleteAfterTest ?? true;
67-
// const testProxyMode = test.testProxyMode ?? "block";
55+
function testRun(archiveInfo) {
56+
// run tests for each archive information
57+
archiveInfo.forEach((info) => {
58+
describe(`Test1- Offline Package Test |`, function () {
59+
logger.info(
60+
`Testing for IDF version: ${info.version} on platform: ${info.platform}`
61+
);
62+
// Set timeout to 100 minutes for installation tests
63+
// as downloading and installing can take a while
64+
this.timeout(6000000);
6865

69-
// describe(`Test${test.id} - ${test.name} ->`, function () {
70-
// this.timeout(6000000);
66+
runCLICustomInstallTest({
67+
id: `11`,
68+
pathToEim: pathToEIMCLI,
69+
offlineIDFVersion: info.version,
70+
offlinePkgName: info.platform,
71+
testProxyMode: "block",
72+
});
7173

72-
// runCLICustomInstallTest({
73-
// pathToEim: pathToEIMCLI,
74-
// args: offlineArg,
75-
// testProxyMode,
76-
// });
74+
runInstallVerification({
75+
id: `12`,
76+
installFolder: INSTALLFOLDER,
77+
idfList: [info.version],
78+
toolsFolder: TOOLSFOLDER,
79+
});
7780

78-
// runInstallVerification({
79-
// installFolder: INSTALLFOLDER,
80-
// idfList: [IDFDefaultVersion],
81-
// toolsFolder: TOOLSFOLDER,
82-
// });
83-
84-
// runCleanUp({
85-
// installFolder: INSTALLFOLDER,
86-
// toolsFolder: TOOLSFOLDER,
87-
// deleteAfterTest,
88-
// });
89-
// });
90-
// });
91-
// }
81+
runCleanUp({
82+
id: `13`,
83+
installFolder: INSTALLFOLDER,
84+
toolsFolder: TOOLSFOLDER,
85+
deleteAfterTest: true,
86+
});
87+
});
88+
});
89+
}

0 commit comments

Comments
 (0)