Skip to content

Commit d5db6fb

Browse files
committed
Refactor offline package test to use build info.
1 parent 7593a84 commit d5db6fb

File tree

4 files changed

+112
-31
lines changed

4 files changed

+112
-31
lines changed

.github/workflows/test_offline.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,26 @@ jobs:
5252
with:
5353
node-version: "20"
5454

55-
- name: Download Archive
55+
- name: Download Build Info files
5656
uses: actions/download-artifact@v5
5757
with:
58-
pattern: offline_installer-${{ matrix.package_name }}-*
58+
pattern: build-info-*-${{ matrix.package_name }}
5959
merge-multiple: true
6060
path: ./artifacts
6161
github-token: ${{ secrets.GITHUB_TOKEN }}
6262
run-id: ${{ inputs.run_id }}
6363

6464
# Non-Windows steps
6565

66-
- name: Get CLI application version number (non-Windows)
66+
- name: Download latest EIM CLI binary (non-Windows)
6767
if: matrix.os != 'windows-latest'
6868
run: |
69-
git fetch --tags
70-
LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)
71-
STRIPPED_TAG=${LATEST_TAG#v}
72-
echo "CLI_TAG=$STRIPPED_TAG" >> $GITHUB_ENV
69+
latest_release=$(curl -s https://api.github.com/repos/espressif/idf-im-ui/releases/latest)
70+
eim_cli_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | test("eim-cli-${{matrix.package_name}}.zip")) | .browser_download_url')
71+
curl -L -o ./artifacts/eim-cli.zip "$eim_cli_url"
7372
74-
- name: Make EIM executable (non-Windows)
75-
if: matrix.os != 'windows-latest'
76-
run: |
77-
ls -la ./artifacts/
78-
unzip ./artifacts/offline_installer*.zip -d ./artifacts/
79-
mv ./artifacts/archive_v*.zst ./artifacts/archive.zst
8073
ls -la ./artifacts/
74+
unzip ./artifacts/eim-cli.zip -d ./artifacts/
8175
chmod +x artifacts/eim
8276
8377
- name: Install dependencies and node.js (Ubuntu)
@@ -102,28 +96,20 @@ jobs:
10296
run: |
10397
export LOG_TO_FILE="true"
10498
export EIM_CLI_PATH="../artifacts/eim"
105-
export EIM_OFFLINE_ARCHIVE="../artifacts/archive.zst"
106-
export EIM_CLI_VERSION="eim ${{ env.CLI_TAG }}"
99+
export BUILD_INFO_PATH="../artifacts"
107100
cd tests
108-
npm run test-CLI --file=CLI-offline
101+
npm run test-offline
109102
continue-on-error: true
110103

111104
# Windows steps
112105

113-
- name: Get CLI application version number (Windows)
106+
- name: Download latest EIM CLI binary (Windows)
114107
if: matrix.os == 'windows-latest'
115108
run: |
116-
git fetch --tags
117-
$LATEST_TAG = (git tag --sort=-creatordate | Select-Object -First 1)
118-
$STRIPPED_TAG = $LATEST_TAG -replace '^v', ''
119-
echo "CLI_TAG=$STRIPPED_TAG" | Out-File -FilePath $env:GITHUB_ENV -Append
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"
120112
121-
- name: Check artifact (Windows)
122-
if: matrix.os == 'windows-latest'
123-
run: |
124-
ls ./artifacts/
125-
Expand-Archive ./artifacts/offline_installer*.zip -DestinationPath ./artifacts/
126-
Move-Item "./artifacts/archive_v*.zst" "artifacts/archive.zst"
127113
ls ./artifacts/
128114
129115
- name: Update Python (Windows)
@@ -137,11 +123,10 @@ jobs:
137123
run: |
138124
$env:LOG_TO_FILE="true"
139125
$env:EIM_CLI_PATH = "..\artifacts\eim.exe"
140-
$env:EIM_OFFLINE_ARCHIVE = "..\artifacts\archive.zst"
141-
$env:EIM_CLI_VERSION = "eim ${{ env.CLI_TAG }}"
126+
$env:BUILD_INFO_PATH = "..\artifacts"
142127
Set-Location -Path "./tests"
143128
Expand-Archive node_modules.zip
144-
npm run test-CLI-win --file=CLI-offline
129+
npm run test-offline
145130
continue-on-error: true
146131

147132
# Copy eim log files to standard location for easier access

tests/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ const getEIMPath = (pathFromCI, defaultFolder) =>
9696
const pathToEIMCLI = getEIMPath(process.env.EIM_CLI_PATH, "eim-cli");
9797
const pathToEIMGUI = getEIMPath(process.env.EIM_GUI_PATH, "eim-gui");
9898

99+
// Get path for build info file
100+
const pathToBuildInfo = process.env.BUILD_INFO_PATH || "~/build_info";
101+
99102
// Default installation folder
100103
const INSTALLFOLDER =
101104
os.platform() !== "win32" ? path.join(os.homedir(), `.espressif`) : `C:\\esp`;
@@ -117,6 +120,7 @@ export {
117120
availableTargets,
118121
pathToEIMCLI,
119122
pathToEIMGUI,
123+
pathToBuildInfo,
120124
EIMGUIVersion,
121125
EIMCLIVersion,
122126
INSTALLFOLDER,

tests/offlineRunner.test.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Test runner to execute offline based on entries of archive index json file.
3+
* Entries should follow this format:
4+
{
5+
"filename": "<archive filename>", //required file to download and test
6+
"version": "vx.x.x", // IDF version contained in the archive
7+
"size": <number>,
8+
"platform": "windows-x64" // Platform where this archive can be used
9+
},
10+
*/
11+
12+
import { describe } from "mocha";
13+
import { runCLICustomInstallTest } from "./scripts/CLICustomInstall.test.js";
14+
import { runInstallVerification } from "./scripts/installationVerification.test.js";
15+
import { runCleanUp } from "./scripts/cleanUpRunner.test.js";
16+
import logger from "./classes/logger.class.js";
17+
import {
18+
pathToEIMCLI,
19+
INSTALLFOLDER,
20+
TOOLSFOLDER,
21+
downloadOfflineArchive,
22+
runInDebug,
23+
pathToBuildInfo,
24+
} from "./config.js";
25+
import os from "os";
26+
import path from "path";
27+
import fs from "fs";
28+
29+
let buildInfo = {};
30+
31+
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+
});
45+
} else {
46+
logger.error(`Directory not found: ${pathToBuildInfo}`);
47+
}
48+
49+
logger.info("Running test script:", buildInfo);
50+
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+
// ];
65+
66+
// const deleteAfterTest = test.deleteAfterTest ?? true;
67+
// const testProxyMode = test.testProxyMode ?? "block";
68+
69+
// describe(`Test${test.id} - ${test.name} ->`, function () {
70+
// this.timeout(6000000);
71+
72+
// runCLICustomInstallTest({
73+
// pathToEim: pathToEIMCLI,
74+
// args: offlineArg,
75+
// testProxyMode,
76+
// });
77+
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+
// }

tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"test-CLI": "export JSON_FILENAME=$npm_config_file && npx mocha --exit --reporter json --reporter-options output=./results-$JSON_FILENAME.json CLIRunner.test.js",
99
"test-CLI-win": "powershell -Command \"$env:JSON_FILENAME=$env:npm_config_file; npx mocha --exit --reporter json --reporter-options output=./results-$env:JSON_FILENAME.json CLIRunner.test.js\"",
1010
"test-GUI": "export JSON_FILENAME=$npm_config_file && npx mocha --exit --reporter json --reporter-options output=./results-$JSON_FILENAME.json GUIRunner.test.js",
11-
"test-GUI-win": "powershell -Command \"$env:JSON_FILENAME=$env:npm_config_file; npx mocha --exit --reporter json --reporter-options output=./results-$env:JSON_FILENAME.json GUIRunner.test.js\""
11+
"test-GUI-win": "powershell -Command \"$env:JSON_FILENAME=$env:npm_config_file; npx mocha --exit --reporter json --reporter-options output=./results-$env:JSON_FILENAME.json GUIRunner.test.js\"",
12+
"test-offline": "npx mocha --exit --reporter json --reporter-options output=./results-offline.json offlineRunner.test.js"
1213
},
1314
"author": "",
1415
"license": "ISC",

0 commit comments

Comments
 (0)