Skip to content

Commit

Permalink
Fix actions (#25)
Browse files Browse the repository at this point in the history
* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* add make-project action

* update flash action

* update flash action

* update flash action

* syntax test

* syntax test

* syntax test

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Update ocdflash action to take multiple boards

* Final updates to existing actions

* final testing

* Add timeout parameter

* fix input to ocderase action

* fix input to ocderase action

* fix input to ocderase action

* fix input to ocderase action

* Remove floating files and update Actions test workflow

* Add READMEs to actions

* move

* debug

* corrected path

* fixed bugs and things

* updated checkout step

* debug

* had fun today

* dunno

* removed action for test

* update path sys append

* update path sys append

* silent make

* path?

* path

* otas apply owner'

* update gitignore

* updated ocd commands to use owner optionally

* updated path in wf

* on push wf

* added error check resource man

* actually use right project

* updated path to var

* multiple resets

* uses build and flash workflows

* fixed error

* multiline fix

* Update OCD/Make actions to allow for stdout suppression

* use dep

* try distclean

* update test

* manual reset and flash

* apply owner

* apply owner

* fixed get owner

* add sleep to tests

* debug print

* repeat button press

* repeat button press

* repeat button press

* repeat button press

* repeat button press

* Test new failing process

* fix print bug

* update step

* update step 2

* update step 2

* supress output

* added functionality to resource manager and actions

* added dats test

* moved dats first and retry xfer step

* moved dats first and retry xfer step

* flash datc 690

* removed flash step from dats test

* debug

* debug

* debug

* fixed arg assertion

* debug

* fixed ownership in dats

* pre test flush

* pre test flush

* update pass condition

* increase timeout

* replace adv names

* replace adv names

* debug

* debug

* debug

* debug

* debug

* debug

* fixed sed operation

* updated timeout'

* linted

* speed test sleep time change

* changed adv names or 665 and 690

* run speed test first

* run speed test first

* run speed test first

* use two flash banks

* increase timeout

* updated tests to be class based

* lint

* lint

* readd phy test

* debug

* debug

* delete post erase step

* delete post erase step

* playing with sleep times

* manual speed test

* manual speed test

* delete last erase

* test uart driver update

* FLASH TWO Steps

* fixed workflow

* more syntax

* removed speed temp

* otas update

* lint

* disable dats to test otas

* fixed error

* lint2

* debug print

* update names otas

* fixed path

* apply extra reset

* more debug

* removed newline from print

* swap client and server

* update

* test 665

* reflash 655 with correct adv name

* fixed make command

* fixed make command

* debug

* debug

* added better debug to cli for tests

* added better debug to cli for tests

* readd 655 all:

* readd 655 all:

* readd speed test

* removed btn 2 m from speed test

* removed btn 2 m from speed test

* removed btn 2 m from speed test

* Update make, flash, and erase actions

* why are you not running

* why are you not running

* update pass condition for phy

* save console logs after run

* update tests and gitignore

* update tests and gitignore

* remove post text recover

* add output to directory

* added artifact upload for tests

* upload results

* debug

* debug

* use env in workflow

* longer time to pair after connect

* updated global env to wf

* updated global env to wf

* fixed infinite timeout

* use env test dir

* use env test dir

* debug

* remove debug print

* added console logs for otas

* fixed undeclare var error

* added console logs for otas

* added env checks for conditional runs

* added env checks for conditional runs

* added env checks for conditional runs

* debug

* fixed directory output

* fixed directory output

* fixed directory output

* removed print

* archive otas output

* resource manger contains owner as member

* Update OCD actions for backwards compatibility

* force debug test run

* ensure all boards are unlocked

* debug

* debug

* debug

* literally forgot to import a package

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* made find-board action work

* update resource manager

* update find-board documentation

---------

Co-authored-by: EricB-ADI <[email protected]>
Co-authored-by: Lorne Smith <[email protected]>
  • Loading branch information
3 people authored May 31, 2024
1 parent 0e1e555 commit 81db715
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 53 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/action_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,37 @@ jobs:
printenv
#----------------------------------------------------------------------------------------------
# Test findBoard
- name: TestFind
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/find-board@v1
id: boardGet
with:
target: |
MAX32655
MAX32665
group: APP

- name: GetFound
run: |
echo $MAX32655
echo $MAX32665
env:
MAX32655: ${{ steps.boardGet.outputs.board1 }}
MAX32665: ${{ steps.boardGet.outputs.board2 }}

#----------------------------------------------------------------------------------------------
# Test lockBoard --> lock action
- name: TestLock
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@main
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@v1
with:
boards: |
max32655_board1
max32655_board2
lock: true
# #----------------------------------------------------------------------------------------------
# Test OCDFlash action
- name: TestFlash
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocdflash@main
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocdflash@v1
with:
board: |
max32655_board1
Expand All @@ -86,24 +106,22 @@ jobs:
# # #----------------------------------------------------------------------------------------------
# Test OCDReset action
- name: TestReset
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocdreset@main
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocdreset@v1
with:
board: |
max32655_board1
#----------------------------------------------------------------------------------------------
# Test OCDErase action
- name: TestErase
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocderase@main
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/ocderase@v1
with:
board: |
max32655_board1
has_two_flash_banks: false
#----------------------------------------------------------------------------------------------
# Test lockBoard --> unlock action
- name: TestUnlock
if: always()
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@main
uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@v1
with:
boards: |
max32655_board1
all_owned: true
lock: false
16 changes: 9 additions & 7 deletions Resource_Share/src/resource_manager/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,15 @@ def print_applicable_items(
applicable_items_open = []
applicable_items_inuse = []
for rname in self.resources:
if target :
if self.get_item_value(f"{rname}.target") != target.upper():
continue
if group:
if self.get_item_value(f"{rname}.group") != group.upper():
continue

try:
if target :
if self.get_item_value(f"{rname}.target") != target.upper():
continue
if group:
if self.get_item_value(f"{rname}.group") != group.upper():
continue
except KeyError:
continue
if self.resource_in_use(rname):
applicable_items_inuse.append(rname)
else:
Expand Down
17 changes: 10 additions & 7 deletions Resource_Share/src/resource_manager_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def config_cli() -> argparse.Namespace:
default=[],
action="extend",
nargs="*",
help="Name of resource to unlock per boards_config.json",
help="Name of board to unlock per boards_config.json",
)

parser.add_argument(
Expand All @@ -107,7 +107,7 @@ def config_cli() -> argparse.Namespace:
default=[],
action="extend",
nargs="*",
help="Name of resource to lock per boards_config.json",
help="Name of board to lock per boards_config.json",
)

parser.add_argument(
Expand Down Expand Up @@ -141,7 +141,7 @@ def config_cli() -> argparse.Namespace:
"-f",
"--find-board",
nargs=2,
default=["", ""],
default=None,
help="Find a board which matches the criteria TARGET GROUP",
)
parser.add_argument(
Expand Down Expand Up @@ -182,20 +182,20 @@ def main():
resource_manager.print_usage()

if args.unlock_all:
print("Unlocking all resources!")
print("Unlocking all boards!")
resource_manager.unlock_all_resources()
sys.exit(0)

if lock_boards:
print(f"Attempting to lock resources {lock_boards}")
print(f"Attempting to lock all boards {lock_boards}")

could_lock = resource_manager.lock_resources(lock_boards, args.owner)

if could_lock:
print("Successfully locked resources")
print("Successfully locked boards")
sys.exit(0)
else:
print("Failed to lock all resources")
print("Failed to lock all boards")
sys.exit(-1)

if unlock_boards:
Expand Down Expand Up @@ -224,6 +224,9 @@ def main():
for resource in resources:
print(resource)

if args.find_board is not None:
resource_manager.print_applicable_items(target=args.find_board[0], group=args.find_board[1])

sys.exit(0)


Expand Down
15 changes: 8 additions & 7 deletions actions/common/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');

const findTargetDirectory = function(dir, target) {
const files = fs.readdirSync(dir);
Expand All @@ -10,22 +11,22 @@ const findTargetDirectory = function(dir, target) {
if (file === target) {
return fullPath;
}
}

const found = findTargetDirectory(fullPath, target);
if (found) {
return found;
const found = findTargetDirectory(fullPath, target);
if (found) {
return found;
}
}
}
return null;
}

const getBoardData = function (boardId, itemName) {
const args = ['-g' `${boardId}.${itemName}`]
const args = ['-g', `${boardId}.${itemName}`]
let boardData = [];
return new Promise((resolve, reject) => {
const getCmd = spawn('resource_manager', args);
getCmd.stdout.on('data', (data) => { boardData.push(data.toString()) });
getCmd.stdout.on('data', (data) => { boardData.push(data.toString().trim()) });
getCmd.stderr.on('data', (data) => { console.log(data.toString()) });
getCmd.on('error', (error) => { console.log(`ERROR: ${error.message}`) });
getCmd.on('close', (code) => {
Expand All @@ -44,7 +45,7 @@ const getBoardOwner = function (boardId) {
let ownerData = []
return new Promise((resolve, reject) => {
const getCmd = spawn('resource_manager', args);
getCmd.stdout.on('data', (data) => { ownerData.push(data.toString()) });
getCmd.stdout.on('data', (data) => { ownerData.push(data.toString().trim()) });
getCmd.stderr.on('data', (data) => { console.log(data.toString()) });
getCmd.on('error', (error) => { console.log(`ERROR: ${error.message}`) });
getCmd.on('close', (code) => {
Expand Down
12 changes: 9 additions & 3 deletions actions/find-board/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ If multiple boards are required with the same criteria, the number of boards can

## Outputs

### board_ids
### board[n]

Space separated list containing the IDs of boards which match the criteria. The action will always return IDs for available boards before returning IDs for boards which are currently in use.
Board matching the given criteria, where `n` is from 1...10 and matches the position of the criteria in the original input.

## Example usage

Expand All @@ -39,5 +39,11 @@ The output can be accessed via `${{ steps.STEPID.outputs.OUTPUTNAME}}. In this c

```yaml
- name: Echo Output
run: echo "Found matching boards --> ${{ steps.findBoards.outputs.board_ids }}"
run: echo "Found matching boards --> ${{ steps.findBoards.outputs.board1 }}, ${{ steps.findBoards.outputs.board2 }}"
```

Console output:

```
Found matching boards --> max32655_board1, max32655_board2
```
24 changes: 21 additions & 3 deletions actions/find-board/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: findBoard
description: 'Find boards matching the given criteria'
description: 'Find boards matching the given criteria. At max 10 boards can be returned at once.'
inputs:
target:
description: 'Desired part number.'
Expand All @@ -12,8 +12,26 @@ inputs:
required: false
default: '1'
outputs:
board_ids:
description: 'Space separated list of board IDs'
board1:
description: 'Board ID which meets the given criteria.'
board2:
description: 'Board ID which meets the given criteria.'
board3:
description: 'Board ID which meets the given criteria.'
board4:
description: 'Board ID which meets the given criteria.'
board5:
description: 'Board ID which meets the given criteria.'
board6:
description: 'Board ID which meets the given criteria.'
board7:
description: 'Board ID which meets the given criteria.'
board8:
description: 'Board ID which meets the given criteria.'
board9:
description: 'Board ID which meets the given criteria.'
board10:
description: 'Board ID which meets the given criteria.'
runs:
using: 'node20'
main: 'index.js'
26 changes: 18 additions & 8 deletions actions/find-board/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const findBoardList = function (target, group) {
reject(code);
}
console.log("Found: %s", foundBoards[0]);
resolve(foundBoards[0]);
resolve(foundBoards[0].trim());
})
})
}
Expand All @@ -41,32 +41,42 @@ const main = async function() {
'!! ERROR: Mismatched parameter lengths. Boards could not be selected. !!'
);
}
var retBoards = '';
let retBoards = [];
if (GROUPS.length === 1 && TARGET_NAMES.length === 1) {
let matches = await findBoardList(TARGET_NAMES[0], GROUPS[0]).split(" ");
let matches = await findBoardList(TARGET_NAMES[0], GROUPS[0]);
matches = matches.split(" ");
if (matches.length < NUM_BOARDS) {
throw new Error('!! ERROR: Not enough matches to fill desired amount of boards. !!');
}
for (let i = 0; i < NUM_BOARDS; i++) {
retBoards = `${retBoards} ${matches[i]}`;
retBoards.push(matches[i]);
}
} else {
let matches = [];
let valid = [];
for (let i = 0; i < GROUPS.length; i++) {
matches[i] = findBoardList(TARGET_NAMES[i], GROUPS[i].split(" "));
matches[i] = await findBoardList(TARGET_NAMES[i], GROUPS[i]);
matches[i] = matches[i].split(" ");
valid[i] = Array(matches[i].length).fill(true);
}
console.log(matches)
for (let i = 0; i < GROUPS.length; i++) {
let match = matches[i][valid[i].indexOf(true)];
for (let j = i+1; j < GROUPS.length; j++) {
if (matches[j].index(match) !== -1) {
if (matches[j].indexOf(match) !== -1) {
valid[j][matches[j].indexOf(match)] = false;
}
}
retBoards = `${retBoards} ${match}`;
retBoards.push(match);
}
}

for (let i = 0; i < 10; i++) {
if (i >= retBoards.length) {
Core.setOutput(`board${i+1}`, "");
} else {
Core.setOutput(`board${i+1}`, retBoards[i]);
}
}
Core.setOutput('board_ids', retBoards.trim());
}
main()
3 changes: 2 additions & 1 deletion actions/lock-board/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Github = require('@actions/github');
const { env } = require('node:process');
const { ALL } = require('node:dns');

const { spawn } = require('child_process');
const BOARD_IDS = Core.getMultilineInput('boards');
const LOCK_FLAG = Core.getBooleanInput('lock', {required: false});
const TIMEOUT = Core.getInput('timeout', {required: false });
Expand Down Expand Up @@ -48,7 +49,7 @@ const unlock = function (boardIds, ownerRef, timeout) {
}

const unlockOwner = function (ownerRef) {
const args = ['unlock-owner', `${ownerRef}`];
const args = ['--unlock-owner', `${ownerRef}`];
return new Promise((resolve, reject) => {
const cmd = spawn('resource_manager', args);
cmd.stdout.on('data', (data) => { console.log(data.toString()) });
Expand Down
5 changes: 2 additions & 3 deletions actions/make-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const makeProject = async function (projectPath, distclean, build_flags, board="
{
makeArgs.push(`BOARD=${board}`)
}

let retVal = 0;
await cleanProject(projectPath, distclean, suppress).then(
(success) => procSuccess(success, 'Clean'),
Expand All @@ -59,9 +58,9 @@ const makeProject = async function (projectPath, distclean, build_flags, board="
}
);

let logOut = '';
let dumpOut = '';
return new Promise((resolve, reject) => {
let logOut = '';
let dumpOut = '';
if (retVal < 0) {
reject(retVal);
}
Expand Down
3 changes: 3 additions & 0 deletions actions/ocdflash/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
description: 'Perform distclean before building? (ignored if build=false)'
required: false
default: 'false'
owner:
description: "Name of owner of resources"
required: false
suppress_output:
description: 'Used to suppress console unless an error is encountered.'
required: false
Expand Down
10 changes: 4 additions & 6 deletions actions/ocdflash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { spawn } = require('child_process');
const { env } = require('node:process');
const { getBoardData, getBoardOwner, procSuccess, procFail, fileExists, findTargetDirectory } = require('../common');
const { makeProject } = require('../make-project');
const { Cipher } = require('crypto');

const BOARD_IDS = Core.getMultilineInput('board');
const PROJECT_DIRS = Core.getMultilineInput('project');
Expand All @@ -13,7 +14,8 @@ const BUILD_FLAG = Core.getBooleanInput('build', { required: false });
const BUILD_FLAGS = Core.getMultilineInput('build_flags', { required: false });
const DISTCLEAN_FLAG = Core.getBooleanInput('distclean', { required: false });
const SUPPRESS_FLAG = Core.getBooleanInput('suppress_output', { required: false });
const OWNER_REF = Github.context.ref;
let tmp = Core.getInput('owner', {required: false });
const OWNER_REF = tmp ? tmp : Github.context.ref;

const flashBoard = function (target, elf, dap, gdb, tcl, telnet, suppress) {
const args = [
Expand Down Expand Up @@ -84,11 +86,7 @@ const main = async function () {
getBoardData(BOARD_IDS[i], 'ocdports.gdb'),
getBoardData(BOARD_IDS[i], 'ocdports.tcl'),
getBoardData(BOARD_IDS[i], 'ocdports.telnet'),
getBoardData(BOARD_IDS[i], 'ocdports.telnet'),
getBoardData(BOARD_IDS[i], 'board'),



getBoardData(BOARD_IDS[i], 'board')
]).catch((err) => console.error(err));

let projPath = findTargetDirectory(path.join(MSDK_PATH, 'Examples', targets[i]), PROJECT_DIRS[i])
Expand Down

0 comments on commit 81db715

Please sign in to comment.