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

chore: Improvements for local build process #5168

Closed
wants to merge 6 commits into from

Conversation

mgyorke
Copy link
Contributor

@mgyorke mgyorke commented Apr 16, 2024

Pull Request Submission

Please check the boxes once done.

The pull request must:

  • Reviewer Documentation
    • follow CONTRIBUTING rules
    • be accompanied by a detailed description of the changes
    • contain a risk assessment of the change (Low | Medium | High) with regards to breaking existing functionality. A change e.g. of an underlying language plugin can completely break the functionality for that language, but appearing as only a version change in the dependencies.
    • highlight breaking API if applicable
    • contain a link to the automatic tests that cover the updated functionality.
    • contain testing instructions in case that the reviewer wants to manual verify as well, to add to the manual testing done by the author.
    • link to the link to the PR for the User-facing documentation
  • User facing Documentation
    • update any relevant documentation in gitbook by submitting a gitbook PR, and including the PR link here
    • ensure that the message of the final single commit is descriptive and prefixed with either feat: or fix: , others might be used in rare occasions as well, if there is no need to document the changes in the release notes. The changes or fixes should be described in detail in the commit message for the changelog & release notes.
  • Testing
    • Changes, removals and additions to functionality must be covered by acceptance / integration tests or smoke tests - either already existing ones, or new ones, created by the author of the PR.

Pull Request Review

All pull requests must undergo a thorough review process before being merged.
The review process of the code PR should include code review, testing, and any necessary feedback or revisions.
Pull request reviews of functionality developed in other teams only review the given documentation and test reports.

Manual testing will not be performed by the reviewing team, and is the responsibility of the author of the PR.

For Node projects: It’s important to make sure changes in package.json are also affecting package-lock.json correctly.

If a dependency is not necessary, don’t add it.

When adding a new package as a dependency, make sure that the change is absolutely necessary. We would like to refrain from adding new dependencies when possible.
Documentation PRs in gitbook are reviewed by Snyk's content team. They will also advise on the best phrasing and structuring if needed.

Pull Request Approval

Once a pull request has been reviewed and all necessary revisions have been made, it is approved for merging into
the main codebase. The merging of the code PR is performed by the code owners, the merging of the documentation PR
by our content writers.

What does this PR do?

This PR simplifies the local development setup by automating dependency installation for Python and adding specific targets for local build.

Changes:

  • Dependency Management: Updated the install-dev-dependencies.sh script to create a .venv and install required Python dependencies at the project root.

  • Makefile Targets: Introduced two new Makefile targets:
    make install-depsAutomates dependency setup, wraps the installation script
    make build-local Triggers the local build process using the local .venv

  • Documentation: Updated CONTRIBUTING.md with clear instructions for local development setup and usage of the new targets.

Where should the reviewer start?

scripts/install-dev-dependencies.sh
MakeFile

How should this be manually tested?

make install-deps it shouldn't fail even if the dependencies are already installed.
Check if the .venv is created and if it contains the dependencies.
make build-local it should prepare the build as usual

Any background context you want to provide?

What are the relevant tickets?

Screenshots

Additional questions

mgyorke added 4 commits April 17, 2024 15:36
The installation script creates a local .venv environment that
needs to be activated before starting a build.
To exclude Python specific .venv folder
Updated the instructions to clarify the use of venv
@mgyorke mgyorke force-pushed the chore/improvements-for-local-run branch from 66d97b0 to ff634e0 Compare April 17, 2024 12:37
@mgyorke mgyorke force-pushed the chore/improvements-for-local-run branch from ff634e0 to 8bd1ac9 Compare April 17, 2024 12:45
@mgyorke mgyorke marked this pull request as ready for review April 17, 2024 13:16
@mgyorke mgyorke requested a review from a team as a code owner April 17, 2024 13:16
build-local: pre-build
@( \
source $(WORKING_DIR)/.venv/bin/activate; \
cd $(EXTENSIBLE_CLI_DIR); $(MAKE) build-full install bindir=$(WORKING_DIR)/$(BINARY_OUTPUT_FOLDER) USE_LEGACY_EXECUTABLE_NAME=1; \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Do we really need a differentiation between build and build-local? I'm worried that local and CI build get out of sync at some point. I would like to see everyone using the same command to build.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to expand the thought, I wonder if we can make the usage of the virtual environment invisible to the make user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, the initial assumption in the MakeFile is that Python dependencies are installed globally before we run Make. This is handled by CircleCI in the preparatory steps.

We could change this, to use venv in the pipelines and then the build targets are the same everywhere. I see this as the ideal approach but I hesitated to touch the pipelines without discussing possible implications first.

The other two solutions I see are more pragmatic, as the current build path remains the same:

  • dedicated build target for local build, proposed in this PR;
  • do some checks in the existing build target so that it activates the venv if it runs locally or proceed as usual when running in container;

@@ -37,14 +37,17 @@ make clean

To build the project, run the following command in the root of the repository.

Now we trigger the build process:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Isn't this what the previous line says? Do you really want to keep both? Maybe merge their content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I'll clean this up once we decide on the approach.

Another example, if we want the output in console and to run a single test suite by name:

```
npm run test:acceptance -- --selectProjects coreCli --reporters=default -t 'woof'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Let's remove the jest-junit from the package.json and only add it when running in CI. That way, the developer doesn't have to specify the default reporter, which improves the local developer experience.

@@ -8,7 +8,7 @@ To install the required development dependencies in homebrew based environments,
The only additional prerequisite is having [homebrew](https://brew.sh/) installed.

```sh
./scripts/install-dev-dependencies.sh
make install-deps
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: can we assume make to be available? Probably since we don't install it anywhere, we might want to mention it like we do with brew above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, AFAIK it's bunded with the Xcode Command line tools that are a prerequisite for homebrew.
We could check for the dependencies that we assume are already installed and inform the user.

I see how this may be necessary if the developer has different toolchains for managing dependencies and they touch PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants