Skip to content

Commit 7c87f92

Browse files
committed
Allow offline test to run on released archives.
1 parent 01b1306 commit 7c87f92

File tree

6 files changed

+84
-16
lines changed

6 files changed

+84
-16
lines changed

.github/workflows/build_offline_installer_archives.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,5 +582,5 @@ jobs:
582582
uses: ./.github/workflows/test_offline.yml
583583
with:
584584
ref: ${{ inputs.ref || github.ref }}
585-
run_id: ${{ github.run_id }}
586-
eim_cli_run_id: ${{ (github.event_name == 'workflow_call' && inputs.run_id) || 'release' }}
585+
build_info_run_id: ${{ github.run_id }}
586+
eim_cli_run_id: ${{ inputs.run_id }}

.github/workflows/test_offline.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
ref:
77
required: true
88
type: string
9-
run_id:
9+
build_info_run_id:
1010
required: true
1111
type: string
1212
eim_cli_run_id:
@@ -16,10 +16,11 @@ on:
1616

1717
workflow_dispatch:
1818
inputs:
19-
run_id:
20-
description: "The run id from which to take the offline installer archive"
19+
build_info_run_id:
20+
description: "The run id from which to take the offline archive build info files - Use 'release' to take from eim download page"
2121
required: true
2222
type: string
23+
default: "release"
2324
eim_cli_run_id:
2425
description: "The run id from which to take the eim-cli binary - Use 'release' to take from latest release"
2526
required: false
@@ -66,13 +67,14 @@ jobs:
6667
with:
6768
python-version: "3.12.9"
6869

69-
- name: Download Build Info files
70+
- name: Download Build Info files from another run_id
7071
uses: actions/download-artifact@v5
72+
if: inputs.build_info_run_id != 'release'
7173
with:
7274
pattern: build-info-*-${{ matrix.package_name }}
7375
path: ./artifacts
7476
github-token: ${{ secrets.GITHUB_TOKEN }}
75-
run-id: ${{ inputs.run_id }}
77+
run-id: ${{ inputs.build_info_run_id }}
7678

7779
- name: Download EIM-CLI artifacts from another run id
7880
uses: actions/download-artifact@v4
@@ -86,6 +88,14 @@ jobs:
8688

8789
# Non-Windows steps
8890

91+
- name: Download Build Info file from Espressif download page (non-Windows)
92+
if: matrix.os != 'windows-latest' && inputs.build_info_run_id == 'release'
93+
run: |
94+
mkdir -p ./artifacts
95+
curl -fsSL -o ./artifacts/offline_archives.json https://dl.espressif.com/dl/eim/offline_archives.json
96+
echo "Downloaded $(wc -c < ./artifacts/offline_archives.json) bytes"
97+
ls -la ./artifacts/
98+
8999
- name: Download latest EIM CLI binary (non-Windows)
90100
if: matrix.os != 'windows-latest' && inputs.eim_cli_run_id == 'release'
91101
run: |
@@ -137,6 +147,14 @@ jobs:
137147

138148
# Windows steps
139149

150+
- name: Download Build Info file from Espressif download page (Windows)
151+
if: matrix.os == 'windows-latest' && inputs.build_info_run_id == 'release'
152+
run: |
153+
New-Item -ItemType Directory -Force -Path "./artifacts" | Out-Null
154+
Invoke-WebRequest -Uri 'https://dl.espressif.com/dl/eim/offline_archives.json' -OutFile './artifacts/offline_archives.json' -UseBasicParsing
155+
Write-Host "Downloaded $(Get-Item ./artifacts/offline_archives.json).Length bytes"
156+
ls ./artifacts/
157+
140158
- name: Download latest EIM CLI binary (Windows)
141159
if: matrix.os == 'windows-latest' && inputs.eim_cli_run_id == 'release'
142160
run: |

tests/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ logger.info(`Run in debug mode: ${runInDebug}`);
132132

133133
// Define versions of python Wheels included in the offline package
134134
let pythonWheelsVersion = ["311"]
135-
if (os.platform !== "win32") {
136-
pythonWheelsVersion.push("310", "312", "313")
135+
if (os.platform() !== "win32") {
136+
pythonWheelsVersion.push("310", "312", "313");
137137
}
138138
logger.info(`Python wheels versions included: ${pythonWheelsVersion.join(", ")}`)
139139

tests/helper.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ function getPlatformKey() {
3131
return null;
3232
}
3333

34+
// function to get the platform string used in the EIM build info files
35+
function getPlatformKey_eim() {
36+
const arch = os.arch();
37+
const platform = os.platform();
38+
39+
if (platform === "linux") {
40+
if (arch === "x64") return "linux-x64";
41+
if (arch === "arm64") return "linux-aarch64";
42+
}
43+
if (platform === "darwin") {
44+
if (arch === "x64") return "macos-x64";
45+
if (arch === "arm64") return "macos-aarch64";
46+
}
47+
if (platform === "win32") {
48+
if (arch === "x64") return "windows-x64";
49+
if (arch === "arm64") return "windows-aarch64";
50+
}
51+
return null;
52+
}
53+
3454
// function to get the OS name matching strings from GUI
3555
function getOSName() {
3656
const platform = os.platform();
@@ -128,5 +148,12 @@ const getAvailableFeatures = async (idfVersion = IDFDefaultVersion) => {
128148
}
129149
}
130150

131-
export { getPlatformKey, getOSName, getArchitecture, downloadOfflineArchive, getAvailableFeatures };
151+
export {
152+
getPlatformKey,
153+
getPlatformKey_eim,
154+
getOSName,
155+
getArchitecture,
156+
downloadOfflineArchive,
157+
getAvailableFeatures,
158+
};
132159

tests/offlineRunner.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
pathToBuildInfo,
2222
pythonWheelsVersion,
2323
} from "./config.js";
24+
import { getPlatformKey_eim } from "./helper.js";
2425
import path from "path";
2526
import fs from "fs";
2627

@@ -37,14 +38,20 @@ if (fs.existsSync(pathToBuildInfo)) {
3738
try {
3839
const content = fs.readFileSync(fullPath, "utf8");
3940
const jsonData = JSON.parse(content);
40-
buildInfo.push(jsonData);
41+
if (Array.isArray(jsonData)) {
42+
buildInfo.push(...jsonData);
43+
} else {
44+
buildInfo.push(jsonData);
45+
}
4146
} catch (err) {
4247
logger.error(`Failed to read or parse ${fullPath}: ${err.message}`);
4348
}
4449
}
4550
});
4651
}
4752
readJsonFilesRecursively(pathToBuildInfo);
53+
const runnerPlatform = getPlatformKey_eim();
54+
buildInfo = buildInfo.filter((info) => info.platform === runnerPlatform);
4855
} else {
4956
logger.error(`Directory not found: ${pathToBuildInfo}`);
5057
}

tests/scripts/CLICustomInstall.test.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import logger from "../classes/logger.class.js";
55
import TestProxy from "../classes/TestProxy.class.js";
66
import { downloadOfflineArchive } from "../helper.js";
77
import fs from "fs";
8+
import path from "path";
9+
import os from "os";
810

911
export function runCLICustomInstallTest({
1012
id = 0,
@@ -20,6 +22,7 @@ export function runCLICustomInstallTest({
2022
let testRunner = null;
2123
let proxy = null;
2224
let pathToOfflineArchive = null;
25+
const archiveDir = path.join(os.homedir(), "archive");
2326

2427
before(async function () {
2528
logger.debug(
@@ -53,8 +56,10 @@ export function runCLICustomInstallTest({
5356
}
5457
if (pathToOfflineArchive) {
5558
args.push(`--use-local-archive "${pathToOfflineArchive}"`);
56-
testRunner.sendInput("mkdir ~/archive");
57-
testRunner.sendInput(`tar -xf ${pathToOfflineArchive} -C ~/archive`);
59+
testRunner.sendInput(`mkdir ${archiveDir}`);
60+
testRunner.sendInput(
61+
`tar -xf ${pathToOfflineArchive} -C ${archiveDir}`
62+
);
5863
}
5964
if (offlineIDFVersion && !pathToOfflineArchive) {
6065
logger.info(">>>>>>> Offline archive not found, skipping this test");
@@ -93,7 +98,7 @@ export function runCLICustomInstallTest({
9398
if (pathToOfflineArchive) {
9499
try {
95100
fs.rmSync(pathToOfflineArchive, { force: true });
96-
fs.rmSync("~/archive", { recursive: true, force: true });
101+
fs.rmSync(archiveDir, { recursive: true, force: true });
97102
logger.info(`Successfully deleted offline archive`);
98103
} catch (err) {
99104
logger.info(`Error deleting offline archive`);
@@ -111,12 +116,23 @@ export function runCLICustomInstallTest({
111116
fs.existsSync(pathToOfflineArchive),
112117
`Offline archive not found at ${pathToOfflineArchive}`
113118
).to.be.true;
119+
logger.info(`Checking for wheels folder for Python ${pythonVersion}`);
120+
logger.info(
121+
`Looking into ${path.join(archiveDir, `wheels_py${pythonVersion}`)}`
122+
);
123+
logger.info(`Contents: ${fs.readdirSync(archiveDir)}`);
124+
logger.info(
125+
`Contents2: ${fs.readdirSync(
126+
path.join(archiveDir, `wheels_py${pythonVersion}`)
127+
)}`
128+
);
114129
expect(
115-
fs.existsSync(`~/archive/wheels_py${pythonVersion}`),
130+
fs.existsSync(path.join(archiveDir, `wheels_py${pythonVersion}`)),
116131
`Wheels folder for Python ${pythonVersion} not found in offline archive`
117132
).to.be.true;
118133
expect(
119-
fs.readdirSync(`~/archive/wheels_py${pythonVersion}`).length > 0,
134+
fs.readdirSync(path.join(archiveDir, `wheels_py${pythonVersion}`))
135+
.length > 0,
120136
`No wheels found for Python ${pythonVersion} in offline archive`
121137
).to.be.true;
122138
});

0 commit comments

Comments
 (0)