Skip to content

Commit e27392b

Browse files
authored
chore: update filenames to match other projects (#253)
1 parent 87251ac commit e27392b

File tree

5 files changed

+47
-39
lines changed

5 files changed

+47
-39
lines changed

action.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Copyright 2020 Google LLC
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
name: Deploy to App Engine
162
author: Google LLC
173
description: |-

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "Github Action: Deploy to Google App Engine",
55
"main": "dist/index.js",
66
"scripts": {
7-
"build": "ncc build -m src/index.ts",
7+
"build": "ncc build -m src/main.ts",
88
"lint": "eslint src/ tests/ --ext .ts,.tsx",
99
"format": "eslint src/ tests/ --ext .ts,.tsx --fix",
10-
"test": "mocha -r ts-node/register -t 150s 'tests/*.test.ts' --exit"
10+
"test": "mocha -r ts-node/register -t 600s 'tests/*.test.ts' --exit"
1111
},
1212
"repository": {
1313
"type": "git",

src/index.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ import {
3636
getToolCommand,
3737
} from '@google-github-actions/setup-cloud-sdk';
3838

39-
import { errorMessage, parseFlags } from '@google-github-actions/actions-utils';
39+
import {
40+
errorMessage,
41+
isPinnedToHead,
42+
parseFlags,
43+
pinnedToHeadWarning,
44+
} from '@google-github-actions/actions-utils';
4045

4146
export const GCLOUD_METRICS_ENV_VAR = 'CLOUDSDK_METRICS_ENVIRONMENT';
4247
export const GCLOUD_METRICS_LABEL = 'github-actions-deploy-appengine';
@@ -60,8 +65,15 @@ export function setUrlOutput(output: string): string | undefined {
6065
* primary entry point. It is documented inline.
6166
*/
6267
export async function run(): Promise<void> {
63-
exportVariable(GCLOUD_METRICS_ENV_VAR, GCLOUD_METRICS_LABEL);
6468
try {
69+
// Register metrics
70+
exportVariable(GCLOUD_METRICS_ENV_VAR, GCLOUD_METRICS_LABEL);
71+
72+
// Warn if pinned to HEAD
73+
if (isPinnedToHead()) {
74+
logWarning(pinnedToHeadWarning('v0'));
75+
}
76+
6577
// Get action inputs.
6678
let projectId = getInput('project_id');
6779
const cwd = getInput('working_directory');
@@ -169,3 +181,8 @@ export async function run(): Promise<void> {
169181
setFailed(`google-github-actions/deploy-appengine failed with: ${msg}`);
170182
}
171183
}
184+
185+
// Execute this as the entrypoint when requested.
186+
if (require.main === module) {
187+
run();
188+
}
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
*/
1616

1717
import 'mocha';
18+
import { expect } from 'chai';
1819
import * as sinon from 'sinon';
20+
1921
import * as core from '@actions/core';
2022
import * as exec from '@actions/exec';
2123
import * as setupGcloud from '@google-github-actions/setup-cloud-sdk';
22-
import { expect } from 'chai';
23-
import { run, setUrlOutput } from '../src/deploy-appengine';
24+
25+
import { run, setUrlOutput } from '../src/main';
2426

2527
// These are mock data for github actions inputs, where camel case is expected.
2628
const fakeInputs: { [key: string]: string } = {
@@ -38,6 +40,11 @@ function getInputMock(name: string): string {
3840
return fakeInputs[name];
3941
}
4042

43+
// Stub somewhat annoying logs
44+
function doNothing(): void {
45+
/** do nothing */
46+
}
47+
4148
describe('#run', function () {
4249
beforeEach(async function () {
4350
this.stubs = {
@@ -54,10 +61,16 @@ describe('#run', function () {
5461
isProjectIdSet: sinon.stub(setupGcloud, 'isProjectIdSet').resolves(false),
5562
getExecOutput: sinon.stub(exec, 'getExecOutput'),
5663
};
64+
65+
sinon.stub(core, 'debug').callsFake(doNothing);
66+
sinon.stub(core, 'info').callsFake(doNothing);
67+
sinon.stub(core, 'warning').callsFake(doNothing);
68+
sinon.stub(core, 'setOutput').callsFake(doNothing);
5769
});
5870

5971
afterEach(function () {
6072
Object.keys(this.stubs).forEach((k) => this.stubs[k].restore());
73+
sinon.restore();
6174
});
6275

6376
it('installs the gcloud SDK if it is not already installed', async function () {
@@ -96,6 +109,17 @@ describe('#run', function () {
96109
});
97110

98111
describe('#setUrlOutput', function () {
112+
beforeEach(() => {
113+
sinon.stub(core, 'debug').callsFake(doNothing);
114+
sinon.stub(core, 'info').callsFake(doNothing);
115+
sinon.stub(core, 'warning').callsFake(doNothing);
116+
sinon.stub(core, 'setOutput').callsFake(doNothing);
117+
});
118+
119+
afterEach(() => {
120+
sinon.restore();
121+
});
122+
99123
it('correctly parses the URL', function () {
100124
const output = `
101125
Services to deploy:

0 commit comments

Comments
 (0)