Skip to content

Commit 0f07c4b

Browse files
authored
Merge pull request #6 from getappmap/feat/expand-inputs
feat: Add additional installer options
2 parents e662b9d + bebd64c commit 0f07c4b

File tree

8 files changed

+62
-14
lines changed

8 files changed

+62
-14
lines changed

.github/workflows/appmap-archive.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
- name: Install and configure AppMap tools
1919
uses: ./
2020
id: install-appmap
21+
with:
22+
verbose: true
2123
- name: Build AppMaps
2224
run: yarn appmap
2325
- name: Archive AppMaps

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
runs-on: ubuntu-latest
99
name: Build, test and package
1010
steps:
11-
- name: Checkout step
11+
- name: Checkout
1212
uses: actions/checkout@v3
13-
- name: Install dependencies
13+
- name: Install dependency libraries
1414
run: yarn install
1515
- name: Build
1616
run: yarn build

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ can also add the following step to your workflow to commit the changes automatic
1717
uses: EndBug/add-and-commit@v9
1818
```
1919

20+
## Prerequisites
21+
22+
Before running this action, ensure that the programming language and package manager used by your
23+
project are installed and available.
24+
2025
## Development
2126

2227
```
@@ -35,6 +40,6 @@ $ yarn package
3540

3641
## TODO
3742

38-
- [ ] Update description to action.yml.
3943
- [ ] Update repo description in GitHub.
4044
- [ ] Use appmap-action-utils
45+
- [x] Update description in action.yml.

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ description:
55
inputs:
66
appmap-config:
77
description: appmap.yml configuration contents.
8+
project-type:
9+
description: |
10+
Type of project to be configured. Valid values include bundler, yarn, npm, gradle, maven,
11+
pip, pipenv, and poetry. Consult https://appmap.io/docs/add-appmap-to-a-project.html for
12+
more information.
13+
build-file:
14+
description: |
15+
Build file to be configured, in case of ambiguity. This is an advanced option.
16+
installer-name:
17+
description: |
18+
Installer name to be used, in case of ambiguity. This is an advanced option.
819
tools-url:
920
description: URL to the AppMap tools.
1021
default: https://github.com/getappmap/appmap-js/releases/download/%40appland%2Fappmap-preflight-v1.0-pre.1/appmap-preflight-linux-x64

dist/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ class Installer {
6363
(0, log_1.default)(log_1.LogLevel.Info, `Installing the appmap.yml configuration provided by action input.`);
6464
yield (0, promises_1.writeFile)('appmap.yml', this.appmapConfig);
6565
}
66-
yield (0, executeCommand_1.executeCommand)(`${this.appmapToolsPath} install --no-interactive --no-overwrite-appmap-config`);
66+
let cmd = `${this.appmapToolsPath} install --no-interactive --no-overwrite-appmap-config`;
67+
if (this.projectType)
68+
cmd += ` --project-type ${this.projectType}`;
69+
if (this.buildFile)
70+
cmd += ` --build-file ${this.buildFile}`;
71+
if (this.installerName)
72+
cmd += ` --installer-name ${this.installerName}`;
73+
yield (0, executeCommand_1.executeCommand)(cmd);
6774
(0, log_1.default)(log_1.LogLevel.Info, `AppMap language library has been installed and configured.`);
6875
});
6976
}
@@ -262,14 +269,22 @@ function uploadPatchFile(path) {
262269
yield upload.uploadArtifact('appmap-install.patch', [path], '.');
263270
});
264271
}
272+
const Options = {
273+
'appmap-config': 'appmapConfig',
274+
'project-type': 'projectType',
275+
'installer-name': 'installerName',
276+
'build-file': 'buildFile',
277+
};
265278
function runInGitHub() {
266279
return __awaiter(this, void 0, void 0, function* () {
267280
(0, verbose_1.default)(core.getBooleanInput('verbose'));
268-
const appmapConfig = core.getInput('appmap-config');
269281
const appmapToolsURL = core.getInput('tools-url');
270282
const installer = new Installer_1.default(appmapToolsURL);
271-
if (appmapConfig)
272-
installer.appmapConfig = appmapConfig;
283+
for (const [inputName, fieldName] of Object.entries(Options)) {
284+
const value = core.getInput(inputName);
285+
if (value)
286+
installer[fieldName] = value;
287+
}
273288
yield installer.installAppMapTools();
274289
yield installer.installAppMapLibrary();
275290
const patch = yield installer.buildPatchFile();

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Installer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import log, {LogLevel} from './log';
88
export default class Installer {
99
public appmapConfig?: string;
1010
public appmapToolsPath: string;
11+
public projectType?: string;
12+
public installerName?: string;
13+
public buildFile?: string;
1114

1215
constructor(public appmapToolsURL: string) {
1316
this.appmapToolsPath = join(tmpdir(), 'appmap');
@@ -24,9 +27,11 @@ export default class Installer {
2427
log(LogLevel.Info, `Installing the appmap.yml configuration provided by action input.`);
2528
await writeFile('appmap.yml', this.appmapConfig);
2629
}
27-
await executeCommand(
28-
`${this.appmapToolsPath} install --no-interactive --no-overwrite-appmap-config`
29-
);
30+
let cmd = `${this.appmapToolsPath} install --no-interactive --no-overwrite-appmap-config`;
31+
if (this.projectType) cmd += ` --project-type ${this.projectType}`;
32+
if (this.buildFile) cmd += ` --build-file ${this.buildFile}`;
33+
if (this.installerName) cmd += ` --installer-name ${this.installerName}`;
34+
await executeCommand(cmd);
3035

3136
log(LogLevel.Info, `AppMap language library has been installed and configured.`);
3237
}

src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,23 @@ async function uploadPatchFile(path: string) {
1111
await upload.uploadArtifact('appmap-install.patch', [path], '.');
1212
}
1313

14+
const Options: Record<string, keyof Installer> = {
15+
'appmap-config': 'appmapConfig',
16+
'project-type': 'projectType',
17+
'installer-name': 'installerName',
18+
'build-file': 'buildFile',
19+
};
20+
1421
export async function runInGitHub(): Promise<void> {
1522
verbose(core.getBooleanInput('verbose'));
16-
const appmapConfig = core.getInput('appmap-config');
17-
const appmapToolsURL = core.getInput('tools-url');
1823

24+
const appmapToolsURL = core.getInput('tools-url');
1925
const installer = new Installer(appmapToolsURL);
20-
if (appmapConfig) installer.appmapConfig = appmapConfig;
26+
27+
for (const [inputName, fieldName] of Object.entries(Options)) {
28+
const value = core.getInput(inputName);
29+
if (value) (installer as any)[fieldName] = value;
30+
}
2131

2232
await installer.installAppMapTools();
2333
await installer.installAppMapLibrary();

0 commit comments

Comments
 (0)