Skip to content

Commit d1c88ea

Browse files
authored
Drop unnecessary dependencies (#47)
1 parent 9cdbf90 commit d1c88ea

File tree

11 files changed

+463
-1089
lines changed

11 files changed

+463
-1089
lines changed

.eslintrc.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* Copyright 2023 Google LLC
33
*
4-
* Licensed under the Apache License, Version 2.0 (the 'License');
4+
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
88
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an 'AS IS' BASIS,
11+
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
@@ -24,5 +24,8 @@ module.exports = {
2424
'plugin:@typescript-eslint/recommended',
2525
'plugin:prettier/recommended',
2626
],
27-
ignorePatterns: ['**/dist/*'],
27+
28+
rules: {
29+
'@typescript-eslint/no-explicit-any': 'off',
30+
},
2831
};

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ support](https://cloud.google.com/support).**
1717
the secrets being requested. See [Authorization](#authorization) for more
1818
information.
1919

20-
- This action runs using Node 16. If you are using self-hosted GitHub Actions
20+
- This action runs using Node 20. If you are using self-hosted GitHub Actions
2121
runners, you must use runner version
2222
[2.285.0](https://github.com/actions/virtual-environments) or newer.
2323

dist/main/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 120 additions & 842 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "ncc build -m src/main.ts -o dist/main",
8-
"lint": "eslint src/ tests/ --ext .ts,.tsx",
9-
"format": "eslint src/ tests/ --ext .ts,.tsx --fix",
10-
"test": "mocha -r ts-node/register -t 150s 'tests/unit/*.test.ts' --exit",
11-
"e2e-tests": "mocha -r ts-node/register -t 150s 'tests/e2e.test.ts' --exit"
8+
"lint": "eslint . --ext .ts,.tsx",
9+
"format": "prettier --write **/*.ts",
10+
"test": "node --require ts-node/register --test-reporter spec --test ./tests/unit/main.test.ts ./tests/unit/output-parser.test.ts",
11+
"e2e-tests": "node --require ts-node/register --test-reporter spec --test ./tests/e2e.test.ts"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -34,29 +34,23 @@
3434
"@actions/core": "^1.10.1",
3535
"@actions/exec": "^1.1.1",
3636
"@actions/tool-cache": "^2.0.1",
37-
"@google-github-actions/actions-utils": "^0.4.9",
37+
"@google-github-actions/actions-utils": "^0.4.10",
3838
"@google-github-actions/setup-cloud-sdk": "^1.1.3",
3939
"js-yaml": "^4.1.0"
4040
},
4141
"devDependencies": {
42-
"@types/chai": "^4.3.10",
4342
"@types/js-yaml": "^4.0.9",
44-
"@types/mocha": "^10.0.4",
45-
"@types/node": "^20.9.0",
46-
"@types/sinon": "^17.0.1",
47-
"@typescript-eslint/eslint-plugin": "^6.10.0",
48-
"@typescript-eslint/parser": "^6.10.0",
43+
"@types/node": "^20.10.3",
44+
"@typescript-eslint/eslint-plugin": "^6.13.1",
45+
"@typescript-eslint/parser": "^6.13.1",
4946
"@vercel/ncc": "^0.38.1",
50-
"chai": "^4.3.10",
51-
"eslint": "^8.53.0",
52-
"eslint-config-prettier": "^9.0.0",
47+
"eslint-config-prettier": "^9.1.0",
5348
"eslint-plugin-prettier": "^5.0.1",
54-
"googleapis": "^128.0.0",
55-
"mocha": "^10.2.0",
56-
"prettier": "^3.0.3",
57-
"sinon": "^17.0.1",
49+
"eslint": "^8.55.0",
50+
"googleapis": "^129.0.0",
51+
"prettier": "^3.1.0",
5852
"ts-node": "^10.9.1",
59-
"typescript": "^5.2.2",
53+
"typescript": "^5.3.2",
6054
"yaml": "^2.3.4"
6155
}
6256
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ export async function run(): Promise<void> {
9999
if (!deliveryPipeline) {
100100
throw new Error('No delivery pipeline set.');
101101
}
102-
if (!buildArtifacts && !images) {
102+
if (!buildArtifacts && !Object.keys(images)?.length) {
103103
throw new Error('One of `build_artifacts` and `images` inputs must be supplied.');
104104
}
105-
if (buildArtifacts && images && Object.keys(images).length > 0) {
105+
if (buildArtifacts && Object.keys(images)?.length) {
106106
throw new Error('Both `build_artifacts` and `images` inputs set - please select only one.');
107107
}
108108

src/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import { KVPair } from '@google-github-actions/actions-utils';
1919
// Generate default annotations as list of key-value pair
2020
export function getDefaultAnnotations(): KVPair {
2121
const annotations: KVPair = {};
22-
annotations[
23-
'commit'
24-
] = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`;
22+
annotations['commit'] =
23+
`${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`;
2524
annotations['git-sha'] = `${process.env.GITHUB_SHA}`;
2625

2726
return annotations;

tests/e2e.test.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@
1414
* limitations under the License.
1515
*/
1616

17-
import 'mocha';
18-
import { expect } from 'chai';
17+
import { before, describe, it } from 'node:test';
18+
import assert from 'node:assert';
1919

20-
import { getExecOutput } from '@actions/exec';
2120
import { clouddeploy_v1 } from 'googleapis';
21+
import { getExecOutput } from '@actions/exec';
2222
import yaml from 'js-yaml';
2323

2424
/* eslint-disable @typescript-eslint/no-non-null-assertion */
25-
describe('E2E tests', function () {
25+
describe('E2E tests', async () => {
2626
const { ANNOTATIONS, DELIVERY_PIPELINE, DESCRIPTION, LABELS, NAME, PROJECT_ID, REGION } =
2727
process.env;
2828

2929
let release: clouddeploy_v1.Schema$Release;
3030
let toolCommand: string;
3131

32-
before(async function () {
32+
before(async () => {
3333
toolCommand = 'gcloud';
3434
if (NAME && DELIVERY_PIPELINE && PROJECT_ID && REGION) {
3535
// get Service yaml
@@ -62,33 +62,37 @@ describe('E2E tests', function () {
6262
}
6363
});
6464

65-
it('has the correct annotations', function () {
65+
it('has the correct annotations', async () => {
6666
if (ANNOTATIONS && release) {
6767
const expected = JSON.parse(ANNOTATIONS);
68-
const actual = release?.annotations;
69-
expect(actual).to.deep.include(expected);
68+
const actual = release?.annotations || {};
69+
70+
// Filter out only the keys we care about
71+
const subset = Object.assign({}, ...Object.keys(expected).map((k) => ({ [k]: actual[k] })));
72+
73+
assert.deepStrictEqual(subset, expected);
7074
}
7175
});
7276

73-
it('has the correct description', function () {
77+
it('has the correct description', async () => {
7478
if (DESCRIPTION && release) {
7579
const actual = release?.description;
76-
expect(actual).to.deep.eq(DESCRIPTION);
80+
assert.deepStrictEqual(actual, DESCRIPTION);
7781
}
7882
});
7983

80-
it('has the correct name', function () {
84+
it('has the correct name', async () => {
8185
if (NAME && release) {
8286
const actual = release?.name;
83-
expect(actual).to.deep.eq(NAME);
87+
assert.deepStrictEqual(actual, NAME);
8488
}
8589
});
8690

87-
it('has the correct labels', function () {
91+
it('has the correct labels', async () => {
8892
if (LABELS && release) {
8993
const expected = JSON.parse(LABELS);
9094
const actual = release?.labels;
91-
expect(actual).to.deep.eq(expected);
95+
assert.deepStrictEqual(actual, expected);
9296
}
9397
});
9498
});

0 commit comments

Comments
 (0)