Skip to content

Commit 2c0eae9

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

File tree

4 files changed

+59
-9
lines changed

4 files changed

+59
-9
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: 21 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,13 @@ 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+
curl -fsSL -o ./artifacts/offline_archives.json https://dl.espressif.com/dl/eim/offline_archives.json
95+
echo "Downloaded $(wc -c < ./artifacts/offline_archives.json) bytes"
96+
ls -la ./artifacts/
97+
8998
- name: Download latest EIM CLI binary (non-Windows)
9099
if: matrix.os != 'windows-latest' && inputs.eim_cli_run_id == 'release'
91100
run: |
@@ -137,6 +146,13 @@ jobs:
137146

138147
# Windows steps
139148

149+
- name: Download Build Info file from Espressif download page (Windows)
150+
if: matrix.os == 'windows-latest' && inputs.build_info_run_id == 'release'
151+
run: |
152+
Invoke-WebRequest -Uri 'https://dl.espressif.com/dl/eim/offline_archives.json' -OutFile './artifacts/offline_archives.json' -UseBasicParsing
153+
Write-Host "Downloaded $(Get-Item ./artifacts/offline_archives.json).Length bytes"
154+
ls ./artifacts/
155+
140156
- name: Download latest EIM CLI binary (Windows)
141157
if: matrix.os == 'windows-latest' && inputs.eim_cli_run_id == 'release'
142158
run: |

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-aarch4";
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
}

0 commit comments

Comments
 (0)