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

[APM] Script static checkers + precommit #77900

Merged
merged 4 commits into from
Sep 21, 2020
Merged

Conversation

dgieselaar
Copy link
Member

Adds a precommit script that can be used in .git/hooks/pre-commit.local. Also scripts Jest and ESLint runs. Those scripts are able to gather files more quickly, resulting in a performance boost.

To run the scripts:

  • ./x-pack/plugins/apm/scripts/precommit
  • ./x-pack/plugins/apm/scripts/jest
  • ./x-pack/plugins/apm/scripts/eslint

image

@dgieselaar dgieselaar added Team:APM All issues that need APM UI Team support release_note:skip Skip the PR/issue when compiling release notes v7.10.0 labels Sep 18, 2020
@dgieselaar dgieselaar requested a review from a team as a code owner September 18, 2020 14:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

task: () =>
execa(
'node',
[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just do require.resolve('jest/bin/jest') here? Not sure what the jest script written here does other than run the CLI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that the same as running yarn jest --config x-pack/plugins/apm/jest.config.js? Because looks like the latter is a little slower to pick up files.

resolve(__dirname, './jest.js'),
'--reporters',
resolve(__dirname, './node_modules/jest-silent-reporter'),
'--collect-coverage',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just for precommit we might want to turn off coverage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dgieselaar
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

distributable file count

id value diff baseline
default 45953 +3 45950

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

fix,
cache: true,
extensions: ['.js', '.jsx', '.ts', '.tsx'],
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this automatically find the right eslintrc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like it.


const config = require('../jest.config.js');

const argv = [...process.argv.slice(2), '--config', JSON.stringify(config)];
Copy link
Member

@sorenlouv sorenlouv Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this could/should be a path
image

Suggested change
const argv = [...process.argv.slice(2), '--config', JSON.stringify(config)];
const argv = [...process.argv.slice(2), '--config', '../jest.config.js'];

(might have to do something with path.resolve('..', 'jest.config.js') to get the correct path)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same approach as the top-level jest test runner uses.

@dgieselaar dgieselaar merged commit 8347fd0 into elastic:master Sep 21, 2020
@dgieselaar dgieselaar deleted the apm-jest branch September 21, 2020 10:32
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Sep 21, 2020
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
dgieselaar added a commit that referenced this pull request Sep 21, 2020
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants