Skip to content

Commit

Permalink
Merge pull request #199 from tiobe/33077-tmpdir_missing
Browse files Browse the repository at this point in the history
Always run upload artifact when analysis has run
  • Loading branch information
janssen-tiobe authored Nov 1, 2023
2 parents 41ea128 + 768f469 commit 4c4b995
Show file tree
Hide file tree
Showing 22 changed files with 740 additions and 487 deletions.
551 changes: 298 additions & 253 deletions dist/index.js

Large diffs are not rendered by default.

120 changes: 67 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@
"@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"
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@types/node": "^20.8.6",
"@types/underscore": "^1.11.11",
"@typescript-eslint/parser": "^6.7.5",
"@types/node": "^20.8.9",
"@types/underscore": "^1.11.12",
"@typescript-eslint/parser": "^6.9.0",
"@vercel/ncc": "^0.38.1",
"async-listen": "^3.0.1",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"http-proxy": "^1.18.1",
"jest": "^29.7.0",
Expand Down
5 changes: 3 additions & 2 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import HttpClient from '@tiobe/http-client';
import { ProxyAgent } from 'proxy-agent';
import { EOL } from 'os';
import { getBaseUrl } from '@tiobe/install-tics';
import { randomBytes } from 'crypto';

export const githubConfig = {
baseUrl: process.env.GITHUB_API_URL ? process.env.GITHUB_API_URL : 'https://api.github.com',
Expand All @@ -17,7 +18,7 @@ export const githubConfig = {
branchdir: process.env.GITHUB_WORKSPACE ? process.env.GITHUB_WORKSPACE : '',
commitSha: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : '',
eventName: context.eventName,
id: `${context.runId.toString()}-${process.env.GITHUB_RUN_ATTEMPT}`,
id: `${context.runId.toString()}-${process.env.GITHUB_RUN_ATTEMPT || randomBytes(4).toString('hex')}`,
pullRequestNumber: getPullRequestNumber(),
debugger: isDebug()
};
Expand Down Expand Up @@ -105,5 +106,5 @@ const octokitOptions: OctokitOptions = {
};

export const octokit = getOctokit(ticsConfig.githubToken, octokitOptions, retry);
export const baseUrl = getBaseUrl(ticsConfig.ticsConfiguration);
export const baseUrl = getBaseUrl(ticsConfig.ticsConfiguration).href;
export const viewerUrl = ticsConfig.viewerUrl ? ticsConfig.viewerUrl.replace(/\/+$/, '') : baseUrl;
3 changes: 2 additions & 1 deletion src/github/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { handleOctokitError } from '../helper/error';
export async function getPostedReviewComments(): Promise<ReviewComment[]> {
let response: ReviewComment[] = [];
try {
logger.info('Retrieving posted review comments.');
logger.header('Retrieving posted review comments.');
const params = {
owner: githubConfig.owner,
repo: githubConfig.reponame,
Expand All @@ -22,6 +22,7 @@ export async function getPostedReviewComments(): Promise<ReviewComment[]> {
const message = handleOctokitError(error);
logger.error(`Could not retrieve the review comments: ${message}`);
}
logger.info('Retrieve posted review comments.');
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion src/github/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function uploadArtifact(): Promise<void> {
try {
logger.header('Uploading artifact');
const tmpDir = getTmpDir() + '/ticstmpdir';
logger.info(`Logs written to ${tmpDir}`);
logger.info(`Logs gotten from ${tmpDir}`);
const response = await artifactClient.uploadArtifact('ticstmpdir', getFilesInFolder(tmpDir), tmpDir);

if (response.failedItems.length > 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/github/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { handleOctokitError } from '../helper/error';
export async function getPostedComments(): Promise<Comment[]> {
let response: Comment[] = [];
try {
logger.info('Retrieving posted review comments.');
logger.header('Retrieving posted comments.');
const params = {
owner: githubConfig.owner,
repo: githubConfig.reponame,
Expand All @@ -25,6 +25,7 @@ export async function getPostedComments(): Promise<Comment[]> {
const message = handleOctokitError(error);
logger.error(`Could not retrieve the comments: ${message}`);
}
logger.info('Retrieved posted comments.');
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion src/github/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function getChangedFilesOfCommit(): Promise<ChangedFile[]> {
logger.info('Retrieved changed files from commit.');
} catch (error: unknown) {
const message = handleOctokitError(error);
logger.exit(`Could not retrieve the changed files: ${message}`);
throw Error(`Could not retrieve the changed files: ${message}`);
}
return response;
}
6 changes: 3 additions & 3 deletions src/github/pulls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { normalize, resolve } from 'canonical-path';
import { logger } from '../helper/logger';
import { githubConfig, octokit, ticsConfig } from '../configuration';
import { ChangedFile } from './interfaces';
import { handleOctokitError } from '../helper/error';
import { handleOctokitError as getMessageFromOctokitError } from '../helper/error';

/**
* Sends a request to retrieve the changed files for a given pull request to the GitHub API.
Expand Down Expand Up @@ -40,8 +40,8 @@ export async function getChangedFilesOfPullRequest(): Promise<ChangedFile[]> {
});
logger.info('Retrieved changed files from pull request.');
} catch (error: unknown) {
const message = handleOctokitError(error);
logger.exit(`Could not retrieve the changed files: ${message}`);
const message = getMessageFromOctokitError(error);
throw Error(`Could not retrieve the changed files: ${message}`);
}
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function handleOctokitError(error: unknown): string {
let message = 'reason unkown';
if (error instanceof Error) {
message = '';
const retryCount = (error as RequestError).request?.request?.retryCount;
const retryCount = <number | undefined>(error as RequestError).request?.request?.retryCount;
if (retryCount) {
message = `Retried ${retryCount} time(s), but got: `;
}
Expand Down
Loading

0 comments on commit 4c4b995

Please sign in to comment.