Skip to content

Commit

Permalink
Drop unnecessary dependencies (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Dec 4, 2023
1 parent 9cdbf90 commit d1c88ea
Show file tree
Hide file tree
Showing 11 changed files with 463 additions and 1,089 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Expand All @@ -24,5 +24,8 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
ignorePatterns: ['**/dist/*'],

rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ support](https://cloud.google.com/support).**
the secrets being requested. See [Authorization](#authorization) for more
information.

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

Expand Down
10 changes: 5 additions & 5 deletions dist/main/index.js

Large diffs are not rendered by default.

962 changes: 120 additions & 842 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 13 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"main": "dist/index.js",
"scripts": {
"build": "ncc build -m src/main.ts -o dist/main",
"lint": "eslint src/ tests/ --ext .ts,.tsx",
"format": "eslint src/ tests/ --ext .ts,.tsx --fix",
"test": "mocha -r ts-node/register -t 150s 'tests/unit/*.test.ts' --exit",
"e2e-tests": "mocha -r ts-node/register -t 150s 'tests/e2e.test.ts' --exit"
"lint": "eslint . --ext .ts,.tsx",
"format": "prettier --write **/*.ts",
"test": "node --require ts-node/register --test-reporter spec --test ./tests/unit/main.test.ts ./tests/unit/output-parser.test.ts",
"e2e-tests": "node --require ts-node/register --test-reporter spec --test ./tests/e2e.test.ts"
},
"repository": {
"type": "git",
Expand All @@ -34,29 +34,23 @@
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/tool-cache": "^2.0.1",
"@google-github-actions/actions-utils": "^0.4.9",
"@google-github-actions/actions-utils": "^0.4.10",
"@google-github-actions/setup-cloud-sdk": "^1.1.3",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/chai": "^4.3.10",
"@types/js-yaml": "^4.0.9",
"@types/mocha": "^10.0.4",
"@types/node": "^20.9.0",
"@types/sinon": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@types/node": "^20.10.3",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@vercel/ncc": "^0.38.1",
"chai": "^4.3.10",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"googleapis": "^128.0.0",
"mocha": "^10.2.0",
"prettier": "^3.0.3",
"sinon": "^17.0.1",
"eslint": "^8.55.0",
"googleapis": "^129.0.0",
"prettier": "^3.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"yaml": "^2.3.4"
}
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ export async function run(): Promise<void> {
if (!deliveryPipeline) {
throw new Error('No delivery pipeline set.');
}
if (!buildArtifacts && !images) {
if (!buildArtifacts && !Object.keys(images)?.length) {
throw new Error('One of `build_artifacts` and `images` inputs must be supplied.');
}
if (buildArtifacts && images && Object.keys(images).length > 0) {
if (buildArtifacts && Object.keys(images)?.length) {
throw new Error('Both `build_artifacts` and `images` inputs set - please select only one.');
}

Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import { KVPair } from '@google-github-actions/actions-utils';
// Generate default annotations as list of key-value pair
export function getDefaultAnnotations(): KVPair {
const annotations: KVPair = {};
annotations[
'commit'
] = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`;
annotations['commit'] =
`${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`;
annotations['git-sha'] = `${process.env.GITHUB_SHA}`;

return annotations;
Expand Down
32 changes: 18 additions & 14 deletions tests/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
* limitations under the License.
*/

import 'mocha';
import { expect } from 'chai';
import { before, describe, it } from 'node:test';
import assert from 'node:assert';

import { getExecOutput } from '@actions/exec';
import { clouddeploy_v1 } from 'googleapis';
import { getExecOutput } from '@actions/exec';
import yaml from 'js-yaml';

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

let release: clouddeploy_v1.Schema$Release;
let toolCommand: string;

before(async function () {
before(async () => {
toolCommand = 'gcloud';
if (NAME && DELIVERY_PIPELINE && PROJECT_ID && REGION) {
// get Service yaml
Expand Down Expand Up @@ -62,33 +62,37 @@ describe('E2E tests', function () {
}
});

it('has the correct annotations', function () {
it('has the correct annotations', async () => {
if (ANNOTATIONS && release) {
const expected = JSON.parse(ANNOTATIONS);
const actual = release?.annotations;
expect(actual).to.deep.include(expected);
const actual = release?.annotations || {};

// Filter out only the keys we care about
const subset = Object.assign({}, ...Object.keys(expected).map((k) => ({ [k]: actual[k] })));

assert.deepStrictEqual(subset, expected);
}
});

it('has the correct description', function () {
it('has the correct description', async () => {
if (DESCRIPTION && release) {
const actual = release?.description;
expect(actual).to.deep.eq(DESCRIPTION);
assert.deepStrictEqual(actual, DESCRIPTION);
}
});

it('has the correct name', function () {
it('has the correct name', async () => {
if (NAME && release) {
const actual = release?.name;
expect(actual).to.deep.eq(NAME);
assert.deepStrictEqual(actual, NAME);
}
});

it('has the correct labels', function () {
it('has the correct labels', async () => {
if (LABELS && release) {
const expected = JSON.parse(LABELS);
const actual = release?.labels;
expect(actual).to.deep.eq(expected);
assert.deepStrictEqual(actual, expected);
}
});
});
Loading

0 comments on commit d1c88ea

Please sign in to comment.