mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
chore: clean up dependencies and eslint rules (#145)
* chore: remove regenerator runtime * chore: move to eslint-config-universe * chore: upgrade semantic release and plugins * chore: clean up jest and use default runner * chore: clean up typescript and updated types * chore: upgrade actions cache
This commit is contained in:
1 parent
3007741466
commit
3ae799926e
12 files changed
+1455
-765
No files matched your search
+2
-14
@@ -1,16 +1,4 @@
|
||||
module.exports = {
|
||||
ignorePatterns: ['/build/**', 'node_modules/**'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint', 'jest', 'prettier'],
|
||||
env: {
|
||||
es6: true,
|
||||
'jest/globals': true,
|
||||
node: true,
|
||||
},
|
||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'prettier/prettier': 'error',
|
||||
},
|
||||
ignorePatterns: ['build/**', 'node_modules/**'],
|
||||
extends: ['universe/node'],
|
||||
};
|
||||
+28
-17
@@ -97,7 +97,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||
if (core.isDebug()) {
|
||||
yield tar_1.listTar(archivePath, compressionMethod);
|
||||
}
|
||||
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
@@ -142,18 +142,29 @@ function saveCache(paths, key, options) {
|
||||
const archiveFolder = yield utils.createTempDirectory();
|
||||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive Path: ${archivePath}`);
|
||||
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
||||
if (core.isDebug()) {
|
||||
yield tar_1.listTar(archivePath, compressionMethod);
|
||||
try {
|
||||
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
||||
if (core.isDebug()) {
|
||||
yield tar_1.listTar(archivePath, compressionMethod);
|
||||
}
|
||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.debug(`File Size: ${archiveFileSize}`);
|
||||
if (archiveFileSize > fileSizeLimit) {
|
||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
||||
}
|
||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
}
|
||||
const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
|
||||
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
||||
core.debug(`File Size: ${archiveFileSize}`);
|
||||
if (archiveFileSize > fileSizeLimit) {
|
||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`);
|
||||
finally {
|
||||
// Try to delete the archive to save space
|
||||
try {
|
||||
yield utils.unlinkFile(archivePath);
|
||||
}
|
||||
catch (error) {
|
||||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
return cacheId;
|
||||
});
|
||||
}
|
||||
@@ -321,7 +332,7 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
|
||||
function uploadFile(httpClient, cacheId, archivePath, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Upload Chunks
|
||||
const fileSize = fs.statSync(archivePath).size;
|
||||
const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
|
||||
const fd = fs.openSync(archivePath, 'r');
|
||||
const uploadOptions = options_1.getUploadOptions(options);
|
||||
@@ -371,7 +382,7 @@ function saveCache(cacheId, archivePath, options) {
|
||||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache');
|
||||
const cacheSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
||||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||||
if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
|
||||
@@ -451,10 +462,10 @@ function createTempDirectory() {
|
||||
});
|
||||
}
|
||||
exports.createTempDirectory = createTempDirectory;
|
||||
function getArchiveFileSizeIsBytes(filePath) {
|
||||
function getArchiveFileSizeInBytes(filePath) {
|
||||
return fs.statSync(filePath).size;
|
||||
}
|
||||
exports.getArchiveFileSizeIsBytes = getArchiveFileSizeIsBytes;
|
||||
exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes;
|
||||
function resolvePaths(patterns) {
|
||||
var e_1, _a;
|
||||
var _b;
|
||||
@@ -759,7 +770,7 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
|
||||
const contentLengthHeader = downloadResponse.message.headers['content-length'];
|
||||
if (contentLengthHeader) {
|
||||
const expectedLength = parseInt(contentLengthHeader);
|
||||
const actualLength = utils.getArchiveFileSizeIsBytes(archivePath);
|
||||
const actualLength = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
if (actualLength !== expectedLength) {
|
||||
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
|
||||
}
|
||||
@@ -67770,8 +67781,8 @@ exports.toRemoteCache = exports.fromRemoteCache = exports.toLocalCache = exports
|
||||
const cache_1 = __nccwpck_require__(7799);
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const toolCache = __importStar(__nccwpck_require__(7784));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
/**
|
||||
* Get the path to the `expo-cli` from cache, if any.
|
||||
* Note, this cache is **NOT** shared between jobs.
|
||||
|
||||
@@ -5,7 +5,6 @@ module.exports = {
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const ncc = require('@vercel/ncc');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const ncc = require('@vercel/ncc');
|
||||
|
||||
build();
|
||||
|
||||
|
||||
+16
-19
@@ -16,12 +16,12 @@
|
||||
"homepage": "https://github.com/expo/expo-github-action#readme",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"lint": "tsc --noEmit && eslint .",
|
||||
"lint": "eslint .",
|
||||
"build": "node ncc.js",
|
||||
"clean": "rimraf build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": "^1.0.7",
|
||||
"@actions/cache": "^1.0.8",
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/io": "^1.1.1",
|
||||
@@ -29,26 +29,23 @@
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^5.0.1",
|
||||
"@semantic-release/git": "^9.0.0",
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@tsconfig/node16": "^1.0.2",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/node": "^16.11.19",
|
||||
"@types/semver": "^7.3.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"@types/semver": "^7.3.9",
|
||||
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
||||
"@typescript-eslint/parser": "^5.9.1",
|
||||
"@vercel/ncc": "^0.33.1",
|
||||
"conventional-changelog-conventionalcommits": "^4.6.0",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-plugin-jest": "^25.2.4",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.3.1",
|
||||
"jest-circus": "^27.3.1",
|
||||
"prettier": "^2.4.1",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"conventional-changelog-conventionalcommits": "^4.6.3",
|
||||
"eslint": "^8.6.0",
|
||||
"eslint-config-universe": "^10.0.0",
|
||||
"jest": "^27.4.7",
|
||||
"prettier": "^2.5.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"semantic-release": "^17.4.4",
|
||||
"ts-jest": "^27.0.7",
|
||||
"typescript": "^4.4.4"
|
||||
"semantic-release": "^18.0.1",
|
||||
"ts-jest": "^27.1.2",
|
||||
"typescript": "^4.5.4"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
import { ReserveCacheError, restoreCache, saveCache } from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import type { InstallConfig } from './install';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/order,import/first */
|
||||
import { getToolsMock, mockInput } from '../utils';
|
||||
|
||||
jest.mock('../../src/tools', () => getToolsMock());
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import os from 'os';
|
||||
import { join } from 'path';
|
||||
import * as remoteCache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import os from 'os';
|
||||
import { join } from 'path';
|
||||
|
||||
import * as cache from '../src/cache';
|
||||
import * as utils from './utils';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/order,import/first */
|
||||
const cli = { exec: jest.fn() };
|
||||
const io = { mkdirP: jest.fn(), which: jest.fn() };
|
||||
const cache = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { valid as validVersion } from 'semver';
|
||||
|
||||
import { resolveVersion } from '../src/packager';
|
||||
|
||||
describe(resolveVersion, () => {
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as cli from '@actions/exec';
|
||||
|
||||
import * as tools from '../src/tools';
|
||||
import * as packager from '../src/packager';
|
||||
import * as tools from '../src/tools';
|
||||
import * as utils from './utils';
|
||||
|
||||
describe(tools.getBinaryName, () => {
|
||||
|
||||
Reference in new issue
Block a user