Skip to content

Commit

Permalink
Add MacOS and simply commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricio-ESP committed Nov 8, 2024
1 parent 7e670b1 commit b735159
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 31 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Expand All @@ -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'
Expand All @@ -109,15 +109,15 @@ 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"
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

- name: Upload test results
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
Expand Down
70 changes: 56 additions & 14 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand All @@ -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.
Expand All @@ -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 "<PATH TO EIM.EXE>" "<Version being tested>"`
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 "<PATH TO EIM.EXE>" "<Version being tested>"`

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 "<PATH TO EIM>" "<Version being tested>"`
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 "<PATH TO EIM>" "<Version being tested>"`

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 "<PATH TO EIM>" "<Version being tested>"`
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 "<PATH TO EIM>" "<Version being tested>"`
Default arguments are:
`. ./tests/run_test.sh "$HOME/eim-cli/eim" "idf-im-cli 0.1.3"`

<TODO>

Expand Down
25 changes: 25 additions & 0 deletions tests/run_pre_test.ps1
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions tests/run_pre_test.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/run_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/runs/defaultInstall.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/runs/variation1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit b735159

Please sign in to comment.