Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests with Serverless v3 #1062

Merged
merged 4 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extends:
- plugin:promise/recommended
- plugin:import/errors
- plugin:import/warnings
- prettier
parser: "@babel/eslint-parser"
parserOptions:
requireConfigFile: false
Expand All @@ -18,10 +19,8 @@ plugins:
- promise
- lodash
- import
- prettier
rules:
indent: [ error, 2, {
MemberExpression: off
} ]
linebreak-style: [ error, unix ]
semi: [ error, always ]
quotes: [ error, single, { avoidEscape: true } ]
Expand All @@ -32,7 +31,6 @@ rules:
brace-style: [ error, '1tbs' ]
comma-spacing: [ error, { before: false, after: true } ]
comma-style: [ error, last, { exceptions: { VariableDeclaration: true } } ]
array-bracket-spacing: [ error, always, { singleValue: false } ]
computed-property-spacing: [ error, never ]
object-curly-spacing: [ error, always ]
prefer-const: error
Expand All @@ -47,3 +45,11 @@ rules:
lodash/prop-shorthand: off
lodash/prefer-lodash-method: [ error, { ignoreObjects: [ BbPromise, path ] } ]
max-len: [ error, { code: 120, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true } ]
prettier/prettier: [ error, {
printWidth: 120,
arrowParens: 'avoid',
bracketSpacing: true,
semi: true,
singleQuote: true,
trailingComma: 'none',
} ]
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- "10"
- "12"
- "14"
- "16"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -97,3 +98,34 @@ jobs:

- name: "Run tests"
run: "npm run test"

serverless-v2:
runs-on: ${{ matrix.os }}
name: Node.js ${{ matrix.node }} on ${{ matrix.os }} with Serverless v2

strategy:
matrix:
os:
- ubuntu-20.04
node:
- "14"

steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: "Install Node.js"
uses: actions/setup-node@v2
with:
node-version: "${{ matrix.node }}"

- name: "Install Serverless v2"
run: npm install serverless@2

- name: "Install dependencies"
run: npm ci

- name: "Run tests"
run: "npm run test"
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ yarn-error.log
.eslintrc.yml
.huskyrc
.lintstagedrc.yml
prettier.config.js
2 changes: 1 addition & 1 deletion examples/typescript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
externals: [nodeExternals()],
devtool: 'source-map',
resolve: {
extensions: [ '.js', '.jsx', '.json', '.ts', '.tsx' ]
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx']
},
output: {
libraryTarget: 'commonjs2',
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ServerlessWebpack {
},
package: {
type: 'entrypoint',
lifecycleEvents: [ 'packExternalModules', 'packageModules', 'copyExistingArtifacts' ]
lifecycleEvents: ['packExternalModules', 'packageModules', 'copyExistingArtifacts']
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions lib/packExternalModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function getProdModules(externalModules, packagePath, nodeModulesRelativeDir, de
moduleVersion = _.get(_.get(originInfo, 'dependencies', {})[module.external], 'version');
if (!moduleVersion) {
// eslint-disable-next-line lodash/path-style
moduleVersion = _.get(dependencyGraph, [ 'dependencies', module.external, 'version' ]);
moduleVersion = _.get(dependencyGraph, ['dependencies', module.external, 'version']);
}
if (!moduleVersion) {
this.serverless.cli.log(`WARNING: Could not determine version of module ${module.external}`);
Expand Down Expand Up @@ -378,12 +378,12 @@ module.exports = {
.then(() =>
hasPackageLock
? BbPromise.fromCallback(callback =>
fse.copy(
path.join(compositeModulePath, packager.lockfileName),
path.join(modulePath, packager.lockfileName),
callback
fse.copy(
path.join(compositeModulePath, packager.lockfileName),
path.join(modulePath, packager.lockfileName),
callback
)
)
)
: BbPromise.resolve()
)
.tap(
Expand Down
2 changes: 1 addition & 1 deletion lib/packagers/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class NPM {
static runScripts(cwd, scriptNames) {
const command = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
return BbPromise.mapSeries(scriptNames, scriptName => {
const args = [ 'run', scriptName ];
const args = ['run', scriptName];

return Utils.spawnProcess(command, args, { cwd });
}).return();
Expand Down
6 changes: 3 additions & 3 deletions lib/packagers/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Yarn {

static getProdDependencies(cwd, depth) {
const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn';
const args = [ 'list', `--depth=${depth || 1}`, '--json', '--production' ];
const args = ['list', `--depth=${depth || 1}`, '--json', '--production'];

// If we need to ignore some errors add them here
const ignoredYarnErrors = [];
Expand Down Expand Up @@ -123,7 +123,7 @@ class Yarn {
}

const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn';
const args = [ 'install', '--non-interactive' ];
const args = ['install', '--non-interactive'];

// Convert supported packagerOptions
if (!packagerOptions.noFrozenLockfile) {
Expand All @@ -147,7 +147,7 @@ class Yarn {
static runScripts(cwd, scriptNames) {
const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn';
return BbPromise.mapSeries(scriptNames, scriptName => {
const args = [ 'run', scriptName ];
const args = ['run', scriptName];

return Utils.spawnProcess(command, args, { cwd });
}).return();
Expand Down
4 changes: 2 additions & 2 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { getAllNodeFunctions, isNodeRuntime } = require('./utils');
* This should cover most of the cases. For complex setups the user should
* build his own entries with help of the other exports.
*/
const preferredExtensions = [ '.js', '.ts', '.jsx', '.tsx' ];
const preferredExtensions = ['.js', '.ts', '.jsx', '.tsx'];

module.exports = {
validate() {
Expand Down Expand Up @@ -249,7 +249,7 @@ module.exports = {
const entry = path.relative('.', value);
const entryFile = _.replace(entry, new RegExp(`${path.extname(entry)}$`), '');

const entryFuncs = _.filter(allEntryFunctions, [ 'handlerFile', entryFile ]);
const entryFuncs = _.filter(allEntryFunctions, ['handlerFile', entryFile]);
if (_.isEmpty(entryFuncs)) {
// We have to make sure that for each entry there is an entry function item.
entryFuncs.push({});
Expand Down
Loading