Skip to content

Commit

Permalink
Merge pull request #3 from EffectiveRange/dev
Browse files Browse the repository at this point in the history
feat: integrate packaging-tools repository
  • Loading branch information
effective-range authored Aug 3, 2024
2 parents c34eaaf + 2cf88f6 commit c8075d2
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
submodules: true

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "resources/packaging-tools"]
path = resources/scripts/packaging-tools
url = https://github.com/EffectiveRange/packaging-tools.git
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ For further development workflow and other details please see the [wiki](https:/

The extension was targeted be used inside an Effective Range dev container for proper operation, but since only vanilla Debian based tooling used, it can be used for any supported project types for remote deployment and debugging.

If your project uses the [Effective Range devcontainer definitions](https://github.com/EffectiveRange/devcontainer-defs) then all the prerequisites are installed there when you open your project with one of the devcontainers. Otherwise the following tools have to be installed on your machine:

- python3 interpreter with pip
- cmake
- [fpm](https://fpm.readthedocs.io/en/latest/), if you have a python project and opt for the fpm based packaging
- [stdeb](https://pypi.org/project/stdeb/), if you have a python project and opt for the dhvirtualenv based packaging
- ssh client for remote deployment and debugging

## Features

This extension has the following features:
Expand All @@ -34,8 +42,11 @@ This extension has the following features:
![ER Dev explorer](images/explorer.png)

- ER Pack:
- The packaging relies on the [Effective Range packaging project](https://github.com/EffectiveRange/packaging-tools) for uniform packaging
- The cmake packaging is driven by the project's CPack settings, and currently it must produce a debian package as an output
- The python packaging is driven by the project's `setup.cfg` file, all the details are available in the [packaging project documentation](https://github.com/EffectiveRange/packaging-tools/blob/main/python/README.md) documentation
- This command can be used to pack the active project
- The command invoked from the command palette
- The command can be invoked from the command palette
- The command can be invoked from the status bar button
- ER Deploy:
- This command deploys the active project to the selected devices
Expand Down Expand Up @@ -65,6 +76,7 @@ This extension contributes the following settings:

The following features will be added in the feature

- dynamically detect the remote machine interpreter path if dhvirtualenv based packaging is in place
- Remote debugger attach for the selected host with process pick, etc for python and C++ debugging
- Support serial connection targets to utilize the UART capabilities of the MrHAT
- Support for ansible dynamic/static inventory targets
Expand Down
5 changes: 3 additions & 2 deletions resources/scripts/deploy_ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ if [ -z $2 ] || { [ $3 != "quick" ] && [ $3 != "all" ]; }; then
fi


PACK_SCRIPT="$SCRIPT_DIR/pack_$1.sh"
PACK_SCRIPT="$SCRIPT_DIR/pack.sh"
PROJTYPE=$1
WSPDIR=$2
TYPE=$3
TARGET=$4
Expand All @@ -34,7 +35,7 @@ fi

shift 4

DEB_FILES_LIST="$("$PACK_SCRIPT" "$WSPDIR")"
DEB_FILES_LIST=$("$PACK_SCRIPT" $PROJTYPE "$WSPDIR")

for file in "$DEB_FILES_LIST"
do
Expand Down
19 changes: 19 additions & 0 deletions resources/scripts/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2024 Ferenc Nandor Janky <[email protected]>
# SPDX-FileCopyrightText: 2024 Attila Gombos <[email protected]>
# SPDX-License-Identifier: MIT
set -e -x

SCRIPT_DIR=$(dirname "$0")

TYPE=$1
shift 1

if [ -z $TYPE ]; then
echo "Usage: $0 <project type> <args>"
exit 1
fi


$SCRIPT_DIR/packaging-tools/$TYPE/pack_$TYPE "$@"
1 change: 1 addition & 0 deletions resources/scripts/packaging-tools
Submodule packaging-tools added at 0b47d9
4 changes: 2 additions & 2 deletions src/cmakeexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CmakeExecutions extends IErDevExecutions {
workspaceFolder: vscode.WorkspaceFolder,
device: ErDeviceModel,
context: DebugLaunchContext,
): Promise<void> {}
): Promise<void> { }

public async setupRemoteDebugger(
workspaceFolder: vscode.WorkspaceFolder,
Expand All @@ -30,7 +30,7 @@ export class CmakeExecutions extends IErDevExecutions {
return context;
}

public packScriptName(): string {
public packScriptName(workspaceFolder?: vscode.WorkspaceFolder): string {
return 'cmake';
}

Expand Down
5 changes: 3 additions & 2 deletions src/erdevexecutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export abstract class IErDevExecutions {
'..',
'resources',
'scripts',
`pack_${this.packScriptName(workspaceFolder)}.sh`,
'pack.sh',
),
);
return this.buildProject(workspaceFolder)
Expand All @@ -56,6 +56,7 @@ export abstract class IErDevExecutions {
workspaceFolder,
'Pack Project',
packScriptUri.fsPath,
this.packScriptName(workspaceFolder) as string,
workspaceFolder.uri.fsPath,
),
)
Expand Down Expand Up @@ -245,7 +246,7 @@ export class SSHDeviceExecution extends IERDeviceExecution {
const term = vscode.window.createTerminal(`SSH:${dev.host}`, '/bin/bash', [
'-c',
'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' +
` -q ${identityArgs(dev).join(' ')} ${toHost(dev)}`,
` -q ${identityArgs(dev).join(' ')} ${toHost(dev)}`,
]);
term.show();
return term;
Expand Down
4 changes: 2 additions & 2 deletions src/executiondispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NoExecution extends IErDevExecutions {
workspaceFolder: WorkspaceFolder,
device: ErDeviceModel,
context: DebugLaunchContext,
): Promise<void> {}
): Promise<void> { }

public async setupRemoteDebugger(
workspaceFolder: WorkspaceFolder,
Expand All @@ -42,7 +42,7 @@ class NoExecution extends IErDevExecutions {
): Promise<void | TaskExecution> {
return Promise.resolve();
}
public packScriptName(): string {
public packScriptName(workspaceFolder?: WorkspaceFolder): string {
throw new Error('Cannot deploy.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pythonexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class PythonExecution extends IErDevExecutions {
return Promise.resolve();
}

public packScriptName(workspaceFolder?: vscode.WorkspaceFolder | undefined): string {
public packScriptName(): string {
return 'python';
}
}
18 changes: 12 additions & 6 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ suite('Extension Test Suite', () => {
const tabs: vscode.Tab[] = vscode.window.tabGroups.all.map((tg) => tg.tabs).flat();
await vscode.window.tabGroups.close(tabs);
});
suiteTeardown(async () => { });
suiteTeardown(async () => {});

teardown(async function (this: Mocha.Context) { });
teardown(async function (this: Mocha.Context) {});

test('pack cmake project proj1', async () => {
const wsp = getWorkspace('proj1');
Expand Down Expand Up @@ -62,7 +62,10 @@ suite('Extension Test Suite', () => {
assert.notStrictEqual(wsp2, undefined);
await openWorkspaceFile(wsp2, 'bin', 'pyproj');
await vscode.commands.executeCommand('erdev.packProject');
assert.strictEqual(existsSync('/tmp/fpm/python3-pyproj_1.0.0_all.deb'), true);
assert.strictEqual(
existsSync(`${wsp2.uri.fsPath}/dist/python3-pyproj_1.0.0_all.deb`),
true,
);
}).timeout(100000);

test('deploy cmake project proj1', async () => {
Expand Down Expand Up @@ -94,8 +97,11 @@ suite('Extension Test Suite', () => {
const handle = await getExtensionHandle();
const api = handle.exports as ErDevApi;
api.setActiveDevice({
id: 'test', host: 'test', hostname: 'localhost', user: 'node',
identity: '/home/node/.ssh/id_rsa'
id: 'test',
host: 'test',
hostname: 'localhost',
user: 'node',
identity: '/home/node/.ssh/id_rsa',
});
assert.strictEqual(existsSync('/usr/bin/proj1'), false);
assert.strictEqual(existsSync('/usr/bin/proj1_2'), false);
Expand Down Expand Up @@ -135,7 +141,7 @@ suite('Extension Test Suite', () => {
api.setActiveDevice({ id: 'test', host: 'test', hostname: 'localhost', user: 'node' });
assert.strictEqual(existsSync('/usr/local/bin/pyproj'), false);
await vscode.commands.executeCommand('erdev.deployProject');
assert.strictEqual(existsSync('/tmp/fpm/python3-pyproj_1.0.0_all.deb'), true);
assert.strictEqual(existsSync(`${wsp.uri.fsPath}/dist/python3-pyproj_1.0.0_all.deb`), true);
assert.strictEqual(existsSync('/usr/local/bin/pyproj'), true);
}).timeout(100000);

Expand Down
2 changes: 2 additions & 0 deletions testwsp/pyproj/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pack-python]
default = fpm-deb

0 comments on commit c8075d2

Please sign in to comment.