Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
  • Loading branch information
RomanNikitenko committed Feb 3, 2025
1 parent 08c351d commit bcebd15
Show file tree
Hide file tree
Showing 8 changed files with 3,665 additions and 2,644 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18.15.0'
- name: build
run: |
yarn
6 changes: 3 additions & 3 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '12'
node-version: '18.15.0'
- name: build
run: |
yarn
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
"license": "EPL-2.0",
"private": true,
"dependencies": {
"@actions/artifact": "^0.5.0",
"@actions/core": "^1.2.6",
"@actions/tool-cache": "^1.6.1",
"@actions/artifact": "^2.2.1",
"@actions/core": "^1.11.1",
"@actions/tool-cache": "^2.0.2",
"execa": "^5.0.0",
"fs-extra": "^9.1.0",
"inversify": "^5.0.5",
"reflect-metadata": "^0.1.13"
},
"devDependencies": {
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.20",
"@types/jest": "^29.2.5",
"@types/reflect-metadata": "^0.1.0",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"@vercel/ncc": "^0.27.0",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@vercel/ncc": "^0.38.3",
"concurrently": "^5.3.0",
"cpx": "^1.5.0",
"eslint": "^7.18.0",
Expand All @@ -31,10 +31,10 @@
"eslint-plugin-no-null": "^1.0.2",
"if-env": "^1.0.4",
"import-sort-style-eslint": "^6.0.0",
"jest": "^26.6.3",
"jest": "^29.3.1",
"prettier": "^2.2.1",
"prettier-plugin-import-sort": "^0.0.6",
"ts-jest": "^26.4.4",
"ts-jest": "^29.0.3",
"typescript": "^4.1.3"
},
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions src/collect-minikube-events-helper.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/**********************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Copyright (c) 2021-2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
***********************************************************************/
import * as artifact from '@actions/artifact';

import * as core from '@actions/core';
import * as execa from 'execa';
import * as fs from 'fs-extra';
import * as path from 'path';

import artifact, { UploadArtifactOptions } from '@actions/artifact';
import { inject, injectable } from 'inversify';

import { Configuration } from './configuration';
Expand All @@ -33,19 +34,19 @@ export class CollectMinikubeEventsHelper {
]);

// add log as artifact
const artifactClient = artifact.create();
const artifactName = `kubectl events ${this.configuration.jobNameSuffix()}`;

const kubectlEventLogPath = '/tmp/kubectl-events.log';
await fs.writeFile(kubectlEventLogPath, stdout, 'utf-8');

const files = [kubectlEventLogPath];
const rootDirectory = path.dirname(kubectlEventLogPath);
const options = {
continueOnError: true,
const options: UploadArtifactOptions = {
retentionDays: 1,
compressionLevel: 6,
};

// upload log
await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options);
await artifact.uploadArtifact(artifactName, files, rootDirectory, options);
}
}
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Copyright (c) 2021-2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -59,8 +59,12 @@ export class Main {
await this.doStart();
return true;
} catch (error) {
console.error('stack=' + error.stack);
console.error('Unable to start', error);
if (error instanceof Error) {
console.error('stack=' + error.stack);
console.error('Unable to start', error.message);
} else {
console.error('Unable to start', error);
}
return false;
}
}
Expand Down
21 changes: 13 additions & 8 deletions tests/collect-minikube-events-helper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Copyright (c) 2021-2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -9,14 +9,14 @@
***********************************************************************/
import 'reflect-metadata';

import * as artifact from '@actions/artifact';
import * as core from '@actions/core';
import * as execa from 'execa';
import * as fs from 'fs-extra';

import { CollectMinikubeEventsHelper } from '../src/collect-minikube-events-helper';
import { Configuration } from '../src/configuration';
import { Container } from 'inversify';
import artifact from '@actions/artifact';

/* eslint-disable @typescript-eslint/no-explicit-any */

Expand Down Expand Up @@ -46,13 +46,15 @@ describe('Test CollectMinikubeEventsHelper', () => {

test('collect', async () => {
const stdout = 'dummy output of kubectl get events commmand';
const defaultOptions = {
retentionDays: 1,
compressionLevel: 6,
};

(execa as any).mockResolvedValue({ exitCode: 0, stdout });

const fsWriteSpy = jest.spyOn(fs, 'writeFile');
const artifactSpy = jest.spyOn(artifact, 'create');
const artifactClient = { uploadArtifact: jest.fn() } as any;
artifactSpy.mockReturnValue(artifactClient);
const uploadArtifactSpy = jest.spyOn(artifact, 'uploadArtifact').mockResolvedValue({} as any);
fsWriteSpy.mockReturnValue();
jobNameSuffixMethod.mockReturnValue('suffix');
await collectMinikubeEventsHelper.collect();
Expand All @@ -65,8 +67,11 @@ describe('Test CollectMinikubeEventsHelper', () => {
expect((execa as any).mock.calls[0][1][1]).toBe('events');

expect(fsWriteSpy).toBeCalledWith('/tmp/kubectl-events.log', stdout, 'utf-8');
expect(artifactClient.uploadArtifact).toBeCalledWith('kubectl events suffix', ['/tmp/kubectl-events.log'], '/tmp', {
continueOnError: true,
});
expect(uploadArtifactSpy).toHaveBeenCalledWith(
'kubectl events suffix',
['/tmp/kubectl-events.log'],
'/tmp',
defaultOptions
);
});
});
21 changes: 20 additions & 1 deletion tests/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Copyright (c) 2021-2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -105,4 +105,23 @@ describe('Test Main with stubs', () => {
expect(returnCode).toBeFalsy();
expect(launchMinikubeExecuteMethod).toBeCalledTimes(0);
});

test('handle not instance of Error', async () => {
class DummyNonError {}
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {
// empty for tests
});
jest.spyOn(InversifyBinding.prototype, 'initBindings').mockImplementation(() => {
throw new DummyNonError();
});

const main = new Main();
const returnCode = await main.start();

expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
expect(consoleErrorSpy).toHaveBeenCalledWith('Unable to start', expect.any(DummyNonError));
expect(returnCode).toBe(false);

consoleErrorSpy.mockRestore();
});
});
Loading

0 comments on commit bcebd15

Please sign in to comment.