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

feat: @app and @filename intrinsics #7078

Merged
merged 13 commits into from
Sep 6, 2024
Merged

Conversation

Chriscbr
Copy link
Contributor

@Chriscbr Chriscbr commented Sep 4, 2024

Closes #6058

This PR introduces the @app and @filename intrinsics to the language. @filename is a complement to the existing @dirname intrinsic, and @app provides a way to access the globally accessible app. @app exposes some meta information that can be useful, like whether the app is being compiled as a test or not, and the platform parameter system. In the CDK world, the app is also the "root" of the tree that all resources get added to.

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@Chriscbr Chriscbr requested a review from a team as a code owner September 4, 2024 23:09
Copy link

github-actions bot commented Sep 4, 2024

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistance, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and standard library @chriscbr
Wing Console @skyrpex
Wing compiler and language design @chriscbr
VSCode extension and language server @chriscbr
Wing CLI @chriscbr
Documentation @boyney123
Examples @boyney123
Wing Playground @skyrpex

@monadabot
Copy link
Contributor

monadabot commented Sep 4, 2024

Console preview environment is available at https://wing-console-pr-7078.fly.dev 🚀

Last Updated (UTC) 2024-09-06 02:57

monadabot and others added 4 commits September 5, 2024 01:24
Signed-off-by: monada-bot[bot] <monabot@monada.co>
Signed-off-by: monada-bot[bot] <monabot@monada.co>
Signed-off-by: monada-bot[bot] <monabot@monada.co>
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 4, 2024
@Chriscbr
Copy link
Contributor Author

Chriscbr commented Sep 4, 2024

Mmm... I thought this wasn't necessary, but I found an example where it still seems like it's load-bearing. Basically, if you compile your Wing app to have multiple tests, this will take on different values, so this is valid:

bring cloud;
bring "constructs" as constructs;
bring expect;

class BucketFactory {
  pub static makeBucket(scope: constructs.IConstruct): cloud.Bucket {
    let bucket = new cloud.Bucket() in scope;
    // apply customizations to bucket...
    return bucket;
  }
}

let bucket = BucketFactory.makeBucket(this);

test "can use bucket" {
  bucket.put("hello", "world");
  expect.equal(bucket.list().length, 1);
}

test "can use other bucket" {
  bucket.put("yo", "sup");
  expect.equal(bucket.list().length, 1);
}

But if you were to change it to:

let bucket = BucketFactory.makeBucket(@app);

Then the test can't be run on AWS, because in preflight it tries creating two buckets with the same scope and name.

I'm not totally sure how to resolve this, so I'll revert a few of the changes and leave in this for now.

@Chriscbr Chriscbr changed the title feat!: @app and @filename intrinsics feat: @app and @filename intrinsics Sep 4, 2024
monadabot and others added 3 commits September 5, 2024 02:11
Signed-off-by: monada-bot[bot] <monabot@monada.co>
Signed-off-by: monada-bot[bot] <monabot@monada.co>
@monadabot
Copy link
Contributor

monadabot commented Sep 5, 2024

Benchmarks

Comparison to Baseline ⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 55ms±0.69 55ms±0.47 -1ms (-1.12%)⬜
functions_10.test.w -t sim 475ms±17.04 497ms±15.06 +22ms (+4.66%)🟥
functions_10.test.w -t tf-aws 2125ms±27.72 2128ms±16.43 +3ms (+0.13%)⬜
jsii_small.test.w -t sim 368ms±2.5 368ms±2.3 0ms (-0.03%)⬜
jsii_small.test.w -t tf-aws 591ms±1.95 591ms±5 +0ms (+0.02%)⬜
functions_1.test.w -t sim 397ms±5.13 396ms±2.98 -1ms (-0.34%)⬜
functions_1.test.w -t tf-aws 828ms±8.82 818ms±4.44 -10ms (-1.2%)⬜
empty.test.w -t sim 365ms±4.75 359ms±4.18 -6ms (-1.61%)⬜
empty.test.w -t tf-aws 586ms±4.18 584ms±3.67 -1ms (-0.25%)⬜
hello_world.test.w -t sim 407ms±3.09 401ms±3.34 -6ms (-1.4%)⬜
hello_world.test.w -t tf-aws 1454ms±5.74 1445ms±4.74 -9ms (-0.64%)⬜
jsii_big.test.w -t sim 2917ms±10.26 2909ms±7.34 -8ms (-0.28%)⬜
jsii_big.test.w -t tf-aws 3113ms±12.55 3095ms±9.07 -18ms (-0.57%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 55ms 54ms 56ms 0ms 1ms
functions_10.test.w -t sim 497ms 476ms 550ms 15ms 21ms
functions_10.test.w -t tf-aws 2128ms 2092ms 2160ms 16ms 23ms
jsii_small.test.w -t sim 368ms 362ms 374ms 2ms 3ms
jsii_small.test.w -t tf-aws 591ms 578ms 604ms 5ms 7ms
functions_1.test.w -t sim 396ms 390ms 404ms 3ms 4ms
functions_1.test.w -t tf-aws 818ms 811ms 828ms 4ms 6ms
empty.test.w -t sim 359ms 347ms 366ms 4ms 6ms
empty.test.w -t tf-aws 584ms 577ms 593ms 4ms 5ms
hello_world.test.w -t sim 401ms 394ms 408ms 3ms 5ms
hello_world.test.w -t tf-aws 1445ms 1431ms 1452ms 5ms 7ms
jsii_big.test.w -t sim 2909ms 2897ms 2927ms 7ms 10ms
jsii_big.test.w -t tf-aws 3095ms 3076ms 3109ms 9ms 13ms
Last Updated (UTC) 2024-09-05 01:05

eladb
eladb previously requested changes Sep 5, 2024
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

I think these need to be documented somewhere

@Chriscbr
Copy link
Contributor Author

Chriscbr commented Sep 6, 2024

@eladb missed that, thanks - I added it to the language ref

@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 6, 2024
@Chriscbr Chriscbr dismissed eladb’s stale review September 6, 2024 16:26

Added documentation

@Chriscbr Chriscbr merged commit 07e2faf into main Sep 6, 2024
23 checks passed
@Chriscbr Chriscbr deleted the rybickic/filename-app-intrinsics branch September 6, 2024 16:26
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.84.3.

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

Successfully merging this pull request may close these issues.

Expose app global variable
3 participants