diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 734e07c..44a8807 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,8 @@ jobs: package_name: linux-x64 - os: windows-latest package_name: windows-x64 + - os: macos-latest + package_name: macos-aarch64 steps: - name: Checkout repository @@ -56,24 +58,26 @@ jobs: - name: Run prerequisites test script (non-Windows) if: runner.os != 'Windows' run: | - export EIM_FILE_PATH="../test-bin/eim" - export EIM_VERSION="idf-im-cli 0.1.3" export LOG_TO_FILE="true" - cd tests - npm ci - npm run pre-test + chmod +x ./tests/run_pre_test.sh + . ./tests/run_pre_test.sh "../test-bin/eim" "idf-im-cli 0.1.4" - name: Install dependencies (Ubuntu) if: runner.os == 'Linux' run: | sudo apt-get install -y git cmake ninja-build wget flex bison gperf ccache libffi-dev libssl-dev dfu-util libusb-1.0-0-dev python3 python3-venv python3-pip + - name: Install dependencies (MacOS) + if: runner.os == 'macOS' + run: | + brew install cmake ninja dfu-util + - name: Run IDF installation and post install test script (non-Windows) if: runner.os != 'Windows' run: | export LOG_TO_FILE="true" chmod +x ./tests/run_test.sh - . ./tests/run_test.sh "../test-bin/eim" "idf-im-cli 0.1.3" + . ./tests/run_test.sh "../test-bin/eim" "idf-im-cli 0.1.4" # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -93,12 +97,8 @@ jobs: - name: Run prerequisites test script (Windows) if: runner.os == 'Windows' run: | - $env:EIM_FILE_PATH="..\test-bin\eim.exe" - $env:EIM_VERSION="idf-im-cli 0.1.3" $env:LOG_TO_FILE="true" - Set-Location -Path "./tests" - Expand-Archive node_modules.zip - npm run pre-test + .\tests\run_pre_test.ps1 "..\test-bin\eim.exe" "idf-im-cli 0.1.4" - name: Install dependencies (Windows) if: runner.os == 'windows' @@ -109,7 +109,7 @@ jobs: if: runner.os == 'Windows' run: | $env:LOG_TO_FILE="true" - .\tests\run_test.ps1 "..\test-bin\eim.exe" "idf-im-cli 0.1.3" + .\tests\run_test.ps1 "..\test-bin\eim.exe" "idf-im-cli 0.1.4" # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -117,7 +117,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: test-results-${{ matrix.os }}.zip + name: test-results-${{ matrix.package_name }}.zip path: | ./tests/results-pre-test.xml ./tests/results-default-test.xml diff --git a/tests/README.md b/tests/README.md index f28dc9e..4b708df 100644 --- a/tests/README.md +++ b/tests/README.md @@ -11,8 +11,8 @@ All tests are developed in Node.js using Chain and Mocha as test libraries in co On the test machine, the first step is to copy the testing artifacts. The location of the artifacts can be set using environment variable, or the test will look for the `eim` file in the default location: -Windows: $USERPROFILE\espressif\ -Linux/MacOS: $HOME/espressif +Windows: $USERPROFILE\eim-cli\ +Linux/MacOS: $HOME/eim-cli/ ### Windows @@ -23,15 +23,15 @@ Run this command with administrator priviledges. Install Node.js: https://nodejs.org/en/download/prebuilt-installer/current -`choco install nodejs --version="20.17.0" -y` +`choco install nodejs-lts --version="22.11.0" -y` Install git: https://git-scm.com/download/win `choco install git.install -y` -Clone the test trunk from the public repository: +Clone the public repository: -`git clone -b autotest https://github.com/espressif/idf-im-cli.git` +`git clone https://github.com/espressif/idf-im-cli.git` ### Linux: @@ -40,17 +40,43 @@ Install Git and curl and build-essential packages `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash` Start a new terminal (to load nvm) -`nvm install 20` +`nvm install 22` -Clone the test trunk from the public repository: -`git clone -b autotest https://github.com/espressif/idf-im-cli.git` +Clone the public repository: +`git clone https://github.com/espressif/idf-im-cli.git` -At his point test for prerequisits can be run, the remaining tests requires the pre-requisites to be installed. +> At his point test for prerequisits can be run, the remaining tests requires the pre-requisites to be installed. +Install ESP-IDF pre-requisites +https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32/get-started/linux-macos-setup.html `sudo apt install git cmake ninja-build wget flex bison gperf ccache libffi-dev libssl-dev dfu-util libusb-dev python3 python3-venv python3-pip` ### MacOS +Install homebrew package manager if not already installed: +https://brew.sh/ +`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` + +Install node.js +https://nodejs.org/en/download/package-manager +`brew install node@22` +`echo 'export PATH="/usr/local/opt/node@22/bin:$PATH"' >> ~/.zshrc` + +> This requires to restart the terminal in order to load Node.JS + +Install git +https://git-scm.com/downloads/mac +`brew install git` + +Clone the public repository: +`git clone https://github.com/espressif/idf-im-cli.git` + +> At his point test for prerequisites can be run, the remaining tests requires the pre-requisites to be installed. + +Install ESP-IDF pre-requisites +https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32/get-started/linux-macos-setup.html +`brew install cmake ninja dfu-util` + ## Commands summary Navigate to the idf-im-cli folder, where the repository was cloned. @@ -61,26 +87,42 @@ The scripts should be executed passing as arguments the path to the `eim` applic Open Powershell, and enable script execution: `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass` +Prerequisites test can be executed by running: +`.\tests\run_pre_test.ps1 "" ""` +Default arguments are: +`.\tests\run_pre_test.ps1 "$env:USERPROFILE\eim-cli\eim.exe" "idf-im-cli 0.1.4"` + To execute tests on windows, use the script `.\tests\run_test.ps1 "" ""` - Default arguments are: -`.\tests\run_test.ps1 "$env:USERPROFILE\espressif\eim.exe" "idf-im-cli 0.1.3"` +`.\tests\run_test.ps1 "$env:USERPROFILE\eim-cli\eim.exe" "idf-im-cli 0.1.4"` #### Linux (if needed) Give execution permission to the test script `chmod +x ./tests/run_test.sh` +Prerequisites test can be executed by running: +`. ./tests/run_pre_test.sh "" ""` +Default arguments are: +`. ./tests/run_pre_test.sh "$HOME/eim-cli/eim" "idf-im-cli 0.1.4"` + To execute tests on linux, use the script: `. ./tests/run_test.sh "" ""` - Default arguments are: -`. ./tests/run_test.sh "$HOME/espressif/eim" "idf-im-cli 0.1.3"` +`. ./tests/run_test.sh "$HOME/eim-cli/eim" "idf-im-cli 0.1.4"` #### MacOS -To executing testins in MacOS, use the script: +Prerequisites test can be executed by running: +`. ./tests/run_pre_test.sh "" ""` +Default arguments are: +`. ./tests/run_pre_test.sh "$HOME/eim-cli/eim" "idf-im-cli 0.1.3"` + +To execute tests on linux, use the script: +`. ./tests/run_test.sh "" ""` +Default arguments are: +`. ./tests/run_test.sh "$HOME/eim-cli/eim" "idf-im-cli 0.1.3"` diff --git a/tests/run_pre_test.ps1 b/tests/run_pre_test.ps1 new file mode 100644 index 0000000..514d97a --- /dev/null +++ b/tests/run_pre_test.ps1 @@ -0,0 +1,25 @@ +# Load arguments as environmental variables + +param ( + [Parameter(Mandatory=$true)] + [string]$Path_to_eim, + + [Parameter(Mandatory=$true)] + [string]$Version +) + +# Save the arguments as environment variables +$env:EIM_FILE_PATH = $Path_to_eim +$env:EIM_VERSION = $Version + +Set-Location -Path "./tests" + +# Expand Node modules folder +Expand-Archive node_modules.zip + +# Install node modules using npm ci +# This can be used if the node modules folder is not packed with the repo +# npm ci + +# Run tests using npm run AllTest +npm run pre-test \ No newline at end of file diff --git a/tests/run_pre_test.sh b/tests/run_pre_test.sh new file mode 100644 index 0000000..33a736f --- /dev/null +++ b/tests/run_pre_test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Save the arguments as environment variables +export EIM_FILE_PATH="$1" +export EIM_VERSION="$2" + +cd tests + +# install node modules +npm ci + +# run tests +npm run pre-test \ No newline at end of file diff --git a/tests/run_test.ps1 b/tests/run_test.ps1 index a24c427..5ce59aa 100644 --- a/tests/run_test.ps1 +++ b/tests/run_test.ps1 @@ -15,7 +15,7 @@ $env:EIM_VERSION = $Version Set-Location -Path "./tests" # Expand Node modules folder -# The zip file is currently being expanded in te CI, run tis line if executing the tests locally +# The zip file is currently being expanded in the pre-test, if it was not executed before please run this line locally # Expand-Archive node_modules.zip # Install node modules using npm ci diff --git a/tests/run_test.sh b/tests/run_test.sh index a981574..f2f1c2a 100644 --- a/tests/run_test.sh +++ b/tests/run_test.sh @@ -7,9 +7,10 @@ export EIM_VERSION="$2" cd tests # install node modules -# Node is being installed int eh folder by the CI, run this line if running it locally +# The zip file is currently being expanded in the pre-test, if it was not executed before please run this line locally # npm ci # run tests +set +e npm run default-test npm run variation1-test \ No newline at end of file diff --git a/tests/runs/defaultInstall.test.js b/tests/runs/defaultInstall.test.js index 4fc7b8c..e3defe5 100644 --- a/tests/runs/defaultInstall.test.js +++ b/tests/runs/defaultInstall.test.js @@ -24,7 +24,7 @@ let eimVersion; if (process.env.EIM_FILE_PATH) { pathToEim = process.env.EIM_FILE_PATH; } else { - pathToEim = path.join(os.homedir(), "espressif/eim"); + pathToEim = path.join(os.homedir(), "eim-cli/eim"); } if (process.env.EIM_VERSION) { diff --git a/tests/runs/variation1.test.js b/tests/runs/variation1.test.js index 0e9454d..e653dc5 100644 --- a/tests/runs/variation1.test.js +++ b/tests/runs/variation1.test.js @@ -21,7 +21,7 @@ let pathToEim; if (process.env.EIM_FILE_PATH) { pathToEim = process.env.EIM_FILE_PATH; } else { - pathToEim = path.join(os.homedir(), "espressif/eim"); + pathToEim = path.join(os.homedir(), "eim-cli/eim"); } logger.debug(`Starting custom installation using EIM on ${pathToEim}`);