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

move source code into localstack-core #10800

Merged
merged 2 commits into from May 24, 2024
Merged

move source code into localstack-core #10800

merged 2 commits into from May 24, 2024

Conversation

thrau
Copy link
Member

@thrau thrau commented May 9, 2024

Motivation

This is the first transitional step into a multi-distribution + namespace package localstack setup. Before we introduce multiple distributions and a namespace package, we can move the localstack source code into localstack-core, and use the src layout to keep everything backwards compatible, while at the same time committing one of the biggest involved changes, which is mkdir localstack-core && mv localstack localstack-core.

Once we introduce multiple distribution, each distribution will have a flat layout again, but that requires restructuring of the entire project setup.

Find all relevant information on how to adopt the change in #10860

Changes

  • the localstack source code (localstack package) now lives in ./localstack-core rather than ./. In the container, it now moved from /opt/code/localstack/localstack to /opt/code/localstack/localstack-core/localstack

Merging the PR

I would like to manually merge this PR because i'd like the file move and config updates separate from each other. this will make it easier to understand in the history, potentially make rebasing easier, and also allow us to clearly ignore the renames (although they should be by default by git).

turns out this was not really needed so i just squash merged

TODO

What's left to do:

  • Fix plux add compatibility for editable wheels and src layout plux#20
  • Fix build pipeline
    • Fix test selection
    • Fix s3 image pipeline
    • Fix pro test pipeline
    • Fix not-implemented collection
    • Fix cobertura report
  • Release and update to plux 1.10 update plux to 1.10.0 #10830
  • Update localstack.dev.run
  • Create documentation how the editor (pycharm/vscode) setup now changes
  • Write an issue description that explains the change (and while it may break some people's localstack scripts, the source code location is not part of the public API)
  • Communicate reasons and implications to the team
  • Prepare PR rebasing instructions
  • Clean up the PR commit history for manual merge
  • Manually merge the PR

@thrau thrau changed the title Move source code move source code into localstack-core May 9, 2024
@thrau thrau force-pushed the move-source-code branch 2 times, most recently from 56f75ac to 25f59c4 Compare May 14, 2024 23:15
@thrau thrau added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label May 15, 2024
Copy link

github-actions bot commented May 15, 2024

S3 Image Test Results (AMD64 / ARM64)

  2 files  ±0    2 suites  ±0   3m 10s ⏱️ -10s
400 tests ±0  348 ✅ ±0   52 💤 ±0  0 ❌ ±0 
800 runs  ±0  696 ✅ ±0  104 💤 ±0  0 ❌ ±0 

Results for commit d5a3fea. ± Comparison against base commit b8290ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 15, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 41m 19s ⏱️ -54s
2 979 tests ±0  2 674 ✅ ±0  305 💤 ±0  0 ❌ ±0 
2 981 runs  ±0  2 674 ✅ ±0  307 💤 ±0  0 ❌ ±0 

Results for commit 52fbeec. ± Comparison against base commit 6eeb7cc.

♻️ This comment has been updated with latest results.

@thrau thrau mentioned this pull request May 15, 2024
@@ -134,7 +134,7 @@ jobs:
circleci-agent step halt
else
source .venv/bin/activate
python -m localstack.testing.testselection.scripts.generate_test_selection_from_pr /tmp/workspace/repo $CI_PULL_REQUEST target/testselection/test-selection.txt
PYTHONPATH=localstack-core python -m localstack.testing.testselection.scripts.generate_test_selection_from_pr /tmp/workspace/repo $CI_PULL_REQUEST target/testselection/test-selection.txt
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed after #10830 has been merged, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

no this has nothing to do with the plugin loading, but just the src layout.

without installing localstack with pip install -e . into the activated venv, the python binary cannot find the source code when a src layout is used.
another option is to cd into localstack-core, or move test selection scripts out of ls all together

@dominikschubert
Copy link
Member

dominikschubert commented May 16, 2024

@thrau

collecting a few of my findings below, will update with more when I encounter them

  • ASF generation is broken `FileNotFoundError: [Errno 2] No such file or directory: 'localstack/aws/api/stepfunctions'
  • CloudFormation resource provider generation script is broken and needs to be adjusted since it assumes a few things around the localstack/localstack-ext directory setup
    • this is only used manually, so I can just fix that after the merge

Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Awesome! This is going to be a great step towards a proper structure and code separation between the different areas / hierarchies in the codebase!
The changes themselves are looking great, and the separation in the two commits is super-helpful (so +1 for the manual merge of the PR to avoid a squash commit).
The changes right now are nearly covering all cases, I just found a few small things that still need to be adjusted and some thins we could run to find potential integration issues early:

  • The S3 workflow trigger needs to be adjusted (hasn't been changed, so I cannot comment on it in the PR diff view):
    - localstack/aws/*.py
    - localstack/aws/handlers/*¨
    - localstack/aws/protocol/**
    - localstack/aws/serving/**
    - localstack/aws/api/s3/**
    - localstack/http/**
    - localstack/runtime/**
    - localstack/services/s3/**
    - localstack/*.py
  • The a path in a step in the ASF update action needs to be updated (see comment).
  • The test runs are currently testing the integration using the "companion branch detection". Maybe it would be useful to just create a dev release from this commit before actually merging it? With this published dev release we could trigger the different pipelines in our downstream projects, testing the integration. If we find issues we can fix them without any interruptions (we can just directly yank or delete the dev release on PyPi).

Let me know if I can help anywhere along the way! 🚀

@@ -525,7 +527,7 @@ def create_code_directory(service_name: str, code: str, base_path: str):
@click.option("--doc/--no-doc", default=False, help="whether or not to generate docstrings")
@click.option(
"--path",
default="./localstack/aws/api",
default="./localstack-core/localstack/aws/api",
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, this change isn't enough to fix the ASF update action...
I did a test-run of the pipeline on this branch: https://github.com/localstack/localstack/actions/runs/9158663716/job/25177480610
The run is looking good, but the change detection is broken:

fatal: ambiguous argument 'localstack/aws/api/': unknown revision or path not in the working tree.

This should be easily fixed by adjusting the paths in this job step:

- name: Check for changes
id: check-for-changes
run: |
# Check if there are changed files and store the result in target/diff-check.log
# Check against the PR branch if it exists, otherwise against the master
# Store the result in target/diff-check.log and store the diff count in the GitHub Action output "diff-count"
mkdir -p target
(git diff --name-only origin/asf-auto-updates localstack/aws/api/ 2>/dev/null || git diff --name-only origin/master localstack/aws/api/ 2>/dev/null) | tee target/diff-check.log
echo "diff-count=$(cat target/diff-check.log | wc -l)" >> $GITHUB_OUTPUT
# Store a (multiline-sanitized) list of changed services (compared to the master) in the GitHub Action output "changed-services"
echo "changed-services<<EOF" >> $GITHUB_OUTPUT
echo "$(git diff --name-only origin/master localstack/aws/api/ | sed 's#localstack/aws/api/#- #g' | sed 's#/__init__.py##g' | sed 's/_/-/g')" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

@thrau thrau merged commit 958890a into master May 24, 2024
29 of 35 checks passed
@thrau thrau deleted the move-source-code branch May 24, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants