Skip to content

Commit

Permalink
Merge pull request #208 from tiobe/33188-no_install_tics
Browse files Browse the repository at this point in the history
Fixed issue regarding running without installTICS
  • Loading branch information
janssen-tiobe authored Nov 10, 2023
2 parents 5f5f3dc + a6a6730 commit ac570ce
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
50 changes: 29 additions & 21 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,27 +461,27 @@ async function getChangedFilesOfPullRequest() {
logger_1.logger.header('Retrieving changed files.');
let response;
do {
response = await configuration_1.octokit.graphql(`query($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $after: String) {
rateLimit {
remaining
}
repository(owner: $owner, name: $repo) {
pullRequest(number: $pull_number) {
files(first: $per_page, after: $after) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
path
changeType
additions
deletions
}
}
}
}
response = await configuration_1.octokit.graphql(`query($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $after: String) {
rateLimit {
remaining
}
repository(owner: $owner, name: $repo) {
pullRequest(number: $pull_number) {
files(first: $per_page, after: $after) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
path
changeType
additions
deletions
}
}
}
}
}`, params);
files = files.concat(response.repository.pullRequest.files.nodes
.map((item) => {
Expand Down Expand Up @@ -1422,6 +1422,14 @@ async function buildRunCommand(fileListPath) {
installCommand += ' &&';
}
}
else {
if ((0, os_1.platform)() === 'linux') {
installCommand = `TICS='${configuration_1.ticsConfig.ticsConfiguration}';`;
}
else {
installCommand = `$env:TICS='${configuration_1.ticsConfig.ticsConfiguration}'`;
}
}
if ((0, os_1.platform)() === 'linux') {
return `/bin/bash -c "${installCommand} ${getTicsCommand(fileListPath)}"`;
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@tiobe/install-tics": "^0.4.0",
"canonical-path": "^1.0.0",
"compare-versions": "^6.1.0",
"crypto": "^1.0.1",
"proxy-agent": "^6.3.1",
"semver": "^7.5.4",
"underscore": "^1.13.6"
Expand Down
6 changes: 6 additions & 0 deletions src/tics/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ async function buildRunCommand(fileListPath: string): Promise<string> {
if (platform() === 'linux') {
installCommand += ' &&';
}
} else {
if (platform() === 'linux') {
installCommand = `TICS='${ticsConfig.ticsConfiguration}';`;
} else {
installCommand = `$env:TICS='${ticsConfig.ticsConfiguration}'`;
}
}

if (platform() === 'linux') {
Expand Down
30 changes: 19 additions & 11 deletions test/unit/tics/analyzer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('test multiple types of configuration', () => {

expect(response.statusCode).toEqual(0);
expect(response.completed).toEqual(true);
expect(spy).toHaveBeenCalledWith('/bin/bash -c " TICS -ide github -help "', [], {
expect(spy).toHaveBeenCalledWith(`/bin/bash -c "TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github -help "`, [], {
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
silent: true
});
Expand All @@ -50,10 +50,14 @@ describe('test multiple types of configuration', () => {

expect(response.statusCode).toEqual(0);
expect(response.completed).toEqual(true);
expect(spy).toHaveBeenCalledWith(`/bin/bash -c " TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE "`, [], {
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
silent: true
});
expect(spy).toHaveBeenCalledWith(
`/bin/bash -c "TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE "`,
[],
{
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
silent: true
}
);
});

test('Should call exec with minimal TICS command for Windows', async () => {
Expand All @@ -65,10 +69,14 @@ describe('test multiple types of configuration', () => {

expect(response.statusCode).toEqual(0);
expect(response.completed).toEqual(true);
expect(spy).toHaveBeenCalledWith(`powershell "; if ($?) {TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE }"`, [], {
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
silent: true
});
expect(spy).toHaveBeenCalledWith(
`powershell "$env:TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; if ($?) {TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE }"`,
[],
{
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
silent: true
}
);
});

test('Should call exec with run TICS command for Linux', async () => {
Expand All @@ -86,7 +94,7 @@ describe('test multiple types of configuration', () => {
expect(response.statusCode).toEqual(0);
expect(response.completed).toEqual(true);
expect(spy).toHaveBeenCalledWith(
"/bin/bash -c \" TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9\"",
"/bin/bash -c \"TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9\"",
[],
{
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
Expand All @@ -110,7 +118,7 @@ describe('test multiple types of configuration', () => {
expect(response.statusCode).toEqual(0);
expect(response.completed).toEqual(true);
expect(spy).toHaveBeenCalledWith(
"powershell \"; if ($?) {TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9}\"",
"powershell \"$env:TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; if ($?) {TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9}\"",
[],
{
listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },
Expand Down

0 comments on commit ac570ce

Please sign in to comment.