Skip to content

Commit 9f24270

Browse files
authored
chore: update line length to 100 to match other repos (#249)
* chore: update line length to 100 to match other repos * Temporarily skip perf test
1 parent f00425b commit 9f24270

13 files changed

Lines changed: 52 additions & 185 deletions

.github/workflows/integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- 'main'
10+
workflow_dispatch:
1011

1112
concurrency:
1213
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
bracketSpacing: true,
2020
endOfLine: 'auto',
2121
jsxSingleQuote: true,
22-
printWidth: 80,
22+
printWidth: 100,
2323
quoteProps: 'consistent',
2424
semi: true,
2525
singleQuote: true,

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ inputs:
2424
description: |-
2525
Upload file(s) with gzip content encoding, defaults to true.
2626
required: false
27+
default: true
2728
resumable:
2829
description: |-
2930
Enable resumable uploads, defaults to true.
3031
required: false
32+
default: true
3133
predefinedAcl:
3234
description: |-
3335
Apply a predefined set of access controls to the file(s).
@@ -36,6 +38,7 @@ inputs:
3638
description: |-
3739
Whether parent dir should be included in GCS destination, defaults to true.
3840
required: false
41+
default: true
3942
glob:
4043
description: |-
4144
Optional glob pattern.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
import * as fs from 'fs';
1818
import * as path from 'path';
1919

20-
import {
21-
Storage,
22-
UploadResponse,
23-
StorageOptions,
24-
PredefinedAcl,
25-
} from '@google-cloud/storage';
20+
import { Storage, UploadResponse, StorageOptions, PredefinedAcl } from '@google-cloud/storage';
2621
import { parseCredential } from '@google-github-actions/actions-utils';
2722
import { Ignore } from 'ignore';
2823

src/headers.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,17 @@ function parseHeaderLines(input: string): Map<string, string> {
4343
const idx = line.indexOf(':');
4444
if (idx === -1) {
4545
throw new Error(
46-
`Failed to parse header line ${i} ("${line}") - the expected format is ` +
47-
`"key: value"`,
46+
`Failed to parse header line ${i} ("${line}") - the expected format is "key: value"`,
4847
);
4948
}
5049

5150
const key = (line.substring(0, idx) || '').trim();
5251
const value = (line.substring(idx + 1) || '').trim();
5352
if (!key) {
54-
throw new Error(
55-
`Failed to parse header line ${i} ("${line}") - missing key`,
56-
);
53+
throw new Error(`Failed to parse header line ${i} ("${line}") - missing key`);
5754
}
5855
if (!value) {
59-
throw new Error(
60-
`Failed to parse header line ${i} ("${line}") - missing value`,
61-
);
56+
throw new Error(`Failed to parse header line ${i} ("${line}") - missing value`);
6257
}
6358

6459
if (map.has(key)) {

src/main.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
import * as core from '@actions/core';
1818
import { PredefinedAcl } from '@google-cloud/storage';
19-
import {
20-
errorMessage,
21-
parseGcloudIgnore,
22-
} from '@google-github-actions/actions-utils';
19+
import { errorMessage, parseGcloudIgnore } from '@google-github-actions/actions-utils';
2320
import ignore from 'ignore';
2421

2522
import { Client } from './client';
@@ -29,31 +26,17 @@ async function run(): Promise<void> {
2926
try {
3027
const path = core.getInput('path', { required: true });
3128
const destination = core.getInput('destination', { required: true });
32-
const gzip =
33-
core.getInput('gzip', { required: false }) === 'false' ? false : true;
34-
const resumable =
35-
core.getInput('resumable', { required: false }) === 'false'
36-
? false
37-
: true;
38-
const predefinedAclInput = core.getInput('predefinedAcl', {
39-
required: false,
40-
});
41-
const parent =
42-
core.getInput('parent', { required: false }).toLowerCase() === 'false'
43-
? false
44-
: true;
29+
const gzip = core.getBooleanInput('gzip');
30+
const resumable = core.getBooleanInput('resumable');
31+
const parent = core.getBooleanInput('parent');
4532
const glob = core.getInput('glob');
4633
const concurrency = Number(core.getInput('concurrency')) || 100;
34+
const predefinedAclInput = core.getInput('predefinedAcl');
4735
const predefinedAcl =
48-
predefinedAclInput === ''
49-
? undefined
50-
: (predefinedAclInput as PredefinedAcl);
51-
const headersInput = core.getInput('headers', {
52-
required: false,
53-
});
36+
predefinedAclInput === '' ? undefined : (predefinedAclInput as PredefinedAcl);
37+
const headersInput = core.getInput('headers');
5438
const processGcloudIgnore = core.getBooleanInput('process_gcloudignore');
55-
const metadata =
56-
headersInput === '' ? undefined : parseHeadersInput(headersInput);
39+
const metadata = headersInput === '' ? undefined : parseHeadersInput(headersInput);
5740
const credentials = core.getInput('credentials');
5841

5942
// Add warning if using credentials
@@ -87,15 +70,11 @@ async function run(): Promise<void> {
8770

8871
core.setOutput(
8972
'uploaded',
90-
uploadResponses
91-
.map((uploadResponse) => uploadResponse[0].name)
92-
.toString(),
73+
uploadResponses.map((uploadResponse) => uploadResponse[0].name).toString(),
9374
);
9475
} catch (err) {
9576
const msg = errorMessage(err);
96-
core.setFailed(
97-
`google-github-actions/upload-cloud-storage failed with ${msg}`,
98-
);
77+
core.setFailed(`google-github-actions/upload-cloud-storage failed with: ${msg}`);
9978
}
10079
}
10180

src/upload-helper.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ import * as os from 'os';
1818
import * as path from 'path';
1919
import * as process from 'process';
2020

21-
import {
22-
PredefinedAcl,
23-
Storage,
24-
UploadOptions,
25-
UploadResponse,
26-
} from '@google-cloud/storage';
21+
import { PredefinedAcl, Storage, UploadOptions, UploadResponse } from '@google-cloud/storage';
2722
import { Ignore } from 'ignore';
2823
import globby from 'globby';
2924
import * as core from '@actions/core';
@@ -102,9 +97,7 @@ export class UploadHelper {
10297
options.metadata = metadata;
10398
}
10499

105-
const uploadedFile = await this.storage
106-
.bucket(bucketName)
107-
.upload(normalizedFilePath, options);
100+
const uploadedFile = await this.storage.bucket(bucketName).upload(normalizedFilePath, options);
108101
return uploadedFile;
109102
}
110103

@@ -136,15 +129,8 @@ export class UploadHelper {
136129
): Promise<UploadResponse[]> {
137130
// by default we just use directoryPath with empty glob '', which globby evaluates to directory/**/*
138131
const filesList = await expandGlob(directoryPath, glob);
139-
const uploader = async (
140-
filePath: string,
141-
): Promise<UploadResponse | null> => {
142-
const destination = await getDestinationFromPath(
143-
filePath,
144-
directoryPath,
145-
parent,
146-
prefix,
147-
);
132+
const uploader = async (filePath: string): Promise<UploadResponse | null> => {
133+
const destination = await getDestinationFromPath(filePath, directoryPath, parent, prefix);
148134
const uploadResp = await this.uploadFile(
149135
bucketName,
150136
filePath,
@@ -181,10 +167,7 @@ export class UploadHelper {
181167
* match-all pattern is used instead.
182168
* @return Sorted list of files in posix form.
183169
*/
184-
export async function expandGlob(
185-
directoryPath: string,
186-
glob: string,
187-
): Promise<string[]> {
170+
export async function expandGlob(directoryPath: string, glob: string): Promise<string[]> {
188171
const pth = toPosixPath(path.posix.join(directoryPath, glob));
189172
const filesList = await globby([pth], {
190173
dot: true,

tests/client.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ describe('Unit Test Client', function () {
4444
});
4545

4646
it('calls uploadFile', async function () {
47-
const uploadFileStub = sinon
48-
.stub(UploadHelper.prototype, 'uploadFile')
49-
.callsFake(() => {
50-
return Promise.resolve([FAKE_FILE, FAKE_METADATA]);
51-
});
47+
const uploadFileStub = sinon.stub(UploadHelper.prototype, 'uploadFile').callsFake(() => {
48+
return Promise.resolve([FAKE_FILE, FAKE_METADATA]);
49+
});
5250
const client = new Client();
5351
const filePath = './tests/testdata/test1.txt';
5452
const bucketName = 'foo';

tests/constants.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ export const EXAMPLE_FILE = './tests/testdata/test1.txt';
2424
export const EXAMPLE_DIR = './tests/testdata';
2525
export const EXAMPLE_PREFIX = 'testprefix';
2626
export const FAKE_METADATA = { name: 'foo' };
27-
export const FAKE_FILE: File = new File(
28-
new Bucket(new Storage(), 'foo'),
29-
'foo',
30-
);
27+
export const FAKE_FILE: File = new File(new Bucket(new Storage(), 'foo'), 'foo');
3128
export const FILES_IN_DIR = [
3229
'tests/testdata/nested1/nested2/test3.txt',
3330
'tests/testdata/nested1/test1.txt',
@@ -38,10 +35,7 @@ export const FILES_IN_DIR = [
3835
'tests/testdata/test.json',
3936
];
4037

41-
export const TXT_FILES_IN_TOP_DIR = [
42-
'tests/testdata/test1.txt',
43-
'tests/testdata/test2.txt',
44-
];
38+
export const TXT_FILES_IN_TOP_DIR = ['tests/testdata/test1.txt', 'tests/testdata/test2.txt'];
4539

4640
export const TXT_FILES_IN_DIR = [
4741
'tests/testdata/nested1/nested2/test3.txt',

0 commit comments

Comments
 (0)