Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #661 from Microsoft/pre-release
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
helenlivsc authored Nov 22, 2017
2 parents 3b17249 + 2eeb9cd commit 4881284
Show file tree
Hide file tree
Showing 48 changed files with 5,248 additions and 210 deletions.
2 changes: 1 addition & 1 deletion AZ3166/jenkins/DevKitTestTool/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<add key="DevKitSourceRelativePath" value="devkit-sdk\AZ3166\src"/>
<add key="InstallPackageBlobUrl" value="https://azureboard.blob.core.windows.net/staging/installpackage/devkit_install_{0}.zip"/>
<add key="ResultFolder" value="TestResult"/>
<add key="PackageName" value="arduino_source_{0}.{1}.zip" />
<add key="PackageName" value="AZ3166-{0}.{1}.zip" />
<add key="SystemVersionFilePath" value="devkit-sdk\AZ3166\src\cores\arduino\system\SystemVersion.cpp"/>
<add key="TelemetryFilePath" value="IoTDevKitInstallation.Win\src\telemetry.js"/>
<add key="TaskInstallationScriptFilePath" value="IoTDevKitInstallation.Win\src\tasks\task-installation.js"/>
Expand Down
12 changes: 6 additions & 6 deletions AZ3166/jenkins/DevKitTestTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static int Main(string[] args)
Thread.Sleep(30 * 1000);
_listener.Stop();
watch.Stop();
Console.WriteLine($"DevKit unit test execution time: {watch.Elapsed.Minutes} minutes");
Console.WriteLine($"DevKit unit test execution time: {watch.Elapsed.TotalMinutes} minutes");

Console.WriteLine("Generate test report");
GenerateReport("UnitTestReport", watch.Elapsed.Minutes, logFilePath);
Expand All @@ -84,7 +84,7 @@ public static int Main(string[] args)
VerifyLibraryExamples(exampleFolderPath);

watch.Stop();
Console.WriteLine($"DevKit examples verification time: {watch.Elapsed.Minutes} minutes.");
Console.WriteLine($"DevKit examples verification time: {watch.Elapsed.TotalMinutes} minutes.");

Console.WriteLine("Generate test report");
GenerateReport("ExampleReport", watch.Elapsed.Minutes);
Expand Down Expand Up @@ -220,7 +220,7 @@ private static void RunUnitTests(string testCasePath)
}
else
{
unitTestResult.Add(file.Name, "succeed");
unitTestResult.Add(file.FullName, "succeed");
}

Console.WriteLine("END\r\n");
Expand Down Expand Up @@ -257,12 +257,12 @@ private static void VerifyLibraryExamples(string exampleFolderPath)

if (string.IsNullOrEmpty(error))
{
examplesTestResult.Add(file.Name, "succeed");
examplesTestResult.Add(file.FullName, "succeed");
Console.WriteLine($"Result: succeeded.\r\n");
}
else
{
examplesTestResult.Add(file.Name, error);
examplesTestResult.Add(file.FullName, error);
Console.WriteLine(error);
Console.WriteLine("Result: failed.\r\n");
}
Expand Down Expand Up @@ -581,7 +581,7 @@ private static void UpdateBoardManagerUrl()
throw new FileNotFoundException($"Failed to find the task-installation.js, file path: {filePath}");
}

string newUrl = ConfigurationManager.AppSettings["BoardManagerURL"].ToString();
string newUrl = ConfigurationManager.AppSettings["BoardManagerURL"].ToString().Trim();
string content = File.ReadAllText(filePath);

content = content.Replace("BOARD_URL_PLACEHOLDER", newUrl);
Expand Down
118 changes: 84 additions & 34 deletions AZ3166/jenkins/InstallationPackageScript/src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,33 @@ import fs from 'fs';
const constants = {
projectDir: __dirname,
scriptDir: path.join(__dirname, '../IoTDevKitInstallation.Win'),
usbDir: path.join(__dirname, '../usb_install'),
packageOrigin: path.join(__dirname, '../devkit-sdk/AZ3166/src'),
packageDest: path.join(__dirname, '../AZ3166/AZ3166/hardware/stm32f4'),
finalZip: path.join(__dirname, `../TestResult/usb_install_{version}.${process.env.BUILD_NUMBER}.zip`),
versionFile: path.join(__dirname, `../system_version.txt`),
az3166Origin: path.join(__dirname, '../AZ3166'),
az3166Dest: path.join(__dirname, '../usb_install/tools/AZ3166')
packageOrigin: path.join(__dirname, `../TestResult/AZ3166-{version}.${process.env.BUILD_NUMBER}.zip`),
versionFile: path.join(__dirname, '../system_version.txt'),

devkitDirForWin: path.join(__dirname, '../devkit_install_win'),
packageDestForWin : path.join(__dirname, '../devkit_install_win/tools/staging/AZ3166-{version}.zip'),
toolsOriginForWin: path.join(__dirname, '../Tools/win'),
toolsDestForWin: path.join(__dirname, '../devkit_install_win/tools/staging'),
invalidFolderForWin: path.join(__dirname, '../devkit_install_win/tools/darwin'),
jsonFileDirForWin: path.join(__dirname, '../devkit_install_win/package.json'),
finalZipForWin: path.join(__dirname, `../TestResult/devkit_install_win_{version}.${process.env.BUILD_NUMBER}.zip`),

devkitDirForMac: path.join(__dirname, '../devkit_install_mac'),
packageDestForMac : path.join(__dirname, '../devkit_install_mac/tools/staging/AZ3166-{version}.zip'),
toolsOriginForMac: path.join(__dirname, '../Tools/mac'),
toolsDestForMac: path.join(__dirname, '../devkit_install_mac/tools/staging'),
invalidFolderForMac: path.join(__dirname, '../devkit_install_mac/tools/win32'),
jsonFileDirForMac: path.join(__dirname, '../devkit_install_mac/package.json'),
finalZipForMac: path.join(__dirname, `../TestResult/devkit_install_mac_{version}.${process.env.BUILD_NUMBER}.zip`)
};

const command = {
npmInstall: 'npm install',
gulpBabel: 'gulp babel',
zipPackage: '7z a -r ../usb_install/tools/AZ3166.zip ../AZ3166/*',
zipFinal: `7z a -r ../TestResult/usb_install_{version}.${process.env.BUILD_NUMBER}.zip ../usb_install/*`

zipFinalForWin: `7z a -r ../TestResult/devkit_install_win_{version}.${process.env.BUILD_NUMBER}.zip ../devkit_install_win/*`,

zipFinalForMac: `7z a -r ../TestResult/devkit_install_mac_{version}.${process.env.BUILD_NUMBER}.zip ../devkit_install_mac/*`
};

const timeout = 600 * 1000;
Expand All @@ -36,56 +49,93 @@ export async function buildNewCode() {
process.chdir(constants.projectDir);
}

export function removeUsbInstall() {
console.log('remove usb_install');
fsExtra.removeSync(constants.usbDir);
fsExtra.mkdirSync(constants.usbDir);
export function removeDevKitInstall() {
console.log('remove devkit_install');
fsExtra.removeSync(constants.devkitDirForWin);
fsExtra.mkdirSync(constants.devkitDirForWin);

fsExtra.removeSync(constants.devkitDirForMac);
fsExtra.mkdirSync(constants.devkitDirForMac);
}

export function copyScripts() {
console.log('copy scripts source');
let files = fsExtra.readdirSync(constants.scriptDir);
for (let i = 0; i < files.length; ++i) {
if (['node_modules', '.git', '.gitignore', 'LICENSE', 'README.md'].indexOf(files[i]) === -1) {
fsExtra.copySync(path.join(constants.scriptDir, files[i]), path.join(constants.usbDir, files[i]));
if (['node_modules', '.git', '.gitignore', 'LICENSE', 'README.md', 'src'].indexOf(files[i]) === -1) {
fsExtra.copySync(path.join(constants.scriptDir, files[i]), path.join(constants.devkitDirForWin, files[i]));
fsExtra.copySync(path.join(constants.scriptDir, files[i]), path.join(constants.devkitDirForMac, files[i]));
}
}
}

export function getVersionInfo(){
let data = fs.readFileSync(constants.versionFile);
versionInfo = data.toString();
}

export function removePackage() {
console.log('remove package');
fsExtra.removeSync(constants.packageDest);
fsExtra.mkdirSync(constants.packageDest);
fsExtra.mkdirSync(path.join(constants.packageDest,versionInfo));
export function copyAZ3166Package() {
console.log('copy AZ3166 zip package');
fsExtra.copySync(constants.packageOrigin.replace("{version}",versionInfo), constants.packageDestForWin.replace("{version}",versionInfo));
fsExtra.copySync(constants.packageOrigin.replace("{version}",versionInfo), constants.packageDestForMac.replace("{version}",versionInfo));
}

export function copyPackage() {
console.log('copy package source');
let files = fsExtra.readdirSync(constants.packageOrigin);
for (let i = 0; i < files.length; ++i) {
fsExtra.copySync(path.join(constants.packageOrigin, files[i]), path.join(path.join(constants.packageDest,versionInfo), files[i]));
export function copyToolChain() {
console.log('copy tools');
let winFiles = fsExtra.readdirSync(constants.toolsOriginForWin);
for (let i = 0; i < winFiles.length; ++i) {
fsExtra.copySync(path.join(constants.toolsOriginForWin, winFiles[i]), path.join(constants.toolsDestForWin, winFiles[i]));
}

let macFiles = fsExtra.readdirSync(constants.toolsOriginForMac);
for (let i = 0; i < macFiles.length; ++i) {
fsExtra.copySync(path.join(constants.toolsOriginForMac, macFiles[i]), path.join(constants.toolsDestForMac, macFiles[i]));
}
}

export function copyAZ3166() {
console.log('copy AZ3166 folder');
let files = fsExtra.readdirSync(constants.az3166Origin);
for (let i = 0; i < files.length; ++i) {
fsExtra.copySync(path.join(constants.az3166Origin, files[i]), path.join(constants.az3166Dest, files[i]));
}
export function removeInvalidFiles()
{
console.log('remove invalid files');
fsExtra.removeSync(path.join(constants.devkitDirForWin, 'install.sh'));
fsExtra.removeSync(constants.invalidFolderForWin);

fsExtra.removeSync(path.join(constants.devkitDirForMac, 'install.cmd'));
fsExtra.removeSync(constants.invalidFolderForMac);
}

export function updateSerialPort()
{
console.log('update serialPort');

var winFile = require(constants.jsonFileDirForWin);
winFile.dependencies["serialport"] = "^4.0.7";

var winDest = JSON.stringify(winFile, null, 2);
fs.writeFile(constants.jsonFileDirForWin, winDest);

var macFile = require(constants.jsonFileDirForMac);
macFile.dependencies["serialport"] = "^6.0.3";

var macDest = JSON.stringify(macFile, null, 2);
fs.writeFile(constants.jsonFileDirForMac, macDest);

}

export async function zipFinal() {
console.log('zip the final package');
let files = glob.sync(path.dirname(constants.finalZip.replace("{version}",versionInfo)).replace(/\\/g, '/') + '/usb_install*.zip');
_.each(files, file => {
let winFiles = glob.sync(path.dirname(constants.finalZipForWin.replace("{version}",versionInfo)).replace(/\\/g, '/') + '/usb_install_win*.zip');
_.each(winFiles, file => {
console.log('deleting' ,file);
fs.unlinkSync(file);
});

let macFiles = glob.sync(path.dirname(constants.finalZipForMac.replace("{version}",versionInfo)).replace(/\\/g, '/') + '/usb_install_mac*.zip');
_.each(macFiles, file => {
console.log('deleting' ,file);
fs.unlinkSync(file);
});

await util.execStdout(command.zipFinal.replace("{version}",versionInfo), timeout);
await util.execStdout(command.zipFinalForMac.replace("{version}",versionInfo), timeout);
await util.execStdout(command.zipFinalForWin.replace("{version}",versionInfo), timeout);
}
18 changes: 10 additions & 8 deletions AZ3166/jenkins/InstallationPackageScript/src/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import {
buildNewCode,
removeUsbInstall,
removeDevKitInstall,
copyScripts,
getVersionInfo,
removePackage,
copyPackage,
copyAZ3166,
copyAZ3166Package,
copyToolChain,
removeInvalidFiles,
updateSerialPort,
zipFinal,
} from './generate';

async function main() {
await buildNewCode();
removeUsbInstall();
removeDevKitInstall();
copyScripts();
getVersionInfo();
removePackage();
copyPackage();
copyAZ3166();
copyAZ3166Package();
copyToolChain();
removeInvalidFiles();
updateSerialPort();
await zipFinal();
}

Expand Down
Loading

0 comments on commit 4881284

Please sign in to comment.