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(iotevents): support comparison operators #19329

Merged
merged 9 commits into from
Apr 8, 2022

Conversation

yamatatsu
Copy link
Contributor

@yamatatsu yamatatsu commented Mar 10, 2022

This PR includes to implement comparison operators.

  • integ test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Mar 10, 2022

@github-actions github-actions bot added the @aws-cdk/aws-iotevents Related to AWS IoT Events label Mar 10, 2022
@yamatatsu yamatatsu marked this pull request as draft March 10, 2022 16:12
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Looks good @yamatatsu! One question.

packages/@aws-cdk/aws-iotevents/lib/expression.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed skinny85’s stale review March 11, 2022 15:02

Pull request has been modified.

Comment on lines 43 to 53
onInput: [{
eventName: 'test-input-event',
actions: [
['neq', iotevents.Expression.neq(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['gt', iotevents.Expression.gt(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['lt', iotevents.Expression.lt(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['gte', iotevents.Expression.gte(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['lte', iotevents.Expression.lte(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['or', iotevents.Expression.or(iotevents.Expression.fromString('true'), iotevents.Expression.fromString('false'))] as const,
].map(([variableName, value]) => ({ bind: () => ({ configuration: { setVariable: { variableName, value: value.evaluate() } } }) })),
}],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skinny85
I have added integ test but it is efficient?
I wanted to confirm that these expressions would work on AWS actually. And its purpose is filled. But I wonder this integ code have value for aws-cdk.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think I would skip this. Doesn't seem particularly elegant.

I could see doing this in a unit test, but I wouldn't do it an an integ test.

@yamatatsu yamatatsu marked this pull request as ready for review March 11, 2022 20:31
@yamatatsu yamatatsu requested a review from skinny85 March 11, 2022 20:31
@skinny85
Copy link
Contributor

@yamatatsu note that I'll be on vacation for the next 2 weeks, so my responses here might be delayed. Thanks for your patience!

/**
* Indicates the priority of the operator.
* This is intended to be set according to MDN rules.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#table
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 have adopted MDN as the operator priority rule. I think it can be used to whatever follow general rules and has concrete numbers.

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Looks fantastic @yamatatsu! Super clean, and doesn't render the extra parenthesis. Thanks for the extra effort you put into this!

I have a few last stylistic comments, but other than that, we're good to go here!

Comment on lines 43 to 53
onInput: [{
eventName: 'test-input-event',
actions: [
['neq', iotevents.Expression.neq(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['gt', iotevents.Expression.gt(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['lt', iotevents.Expression.lt(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['gte', iotevents.Expression.gte(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['lte', iotevents.Expression.lte(iotevents.Expression.fromString('31.7'), iotevents.Expression.fromString('31.7'))] as const,
['or', iotevents.Expression.or(iotevents.Expression.fromString('true'), iotevents.Expression.fromString('false'))] as const,
].map(([variableName, value]) => ({ bind: () => ({ configuration: { setVariable: { variableName, value: value.evaluate() } } }) })),
}],
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think I would skip this. Doesn't seem particularly elegant.

I could see doing this in a unit test, but I wouldn't do it an an integ test.

packages/@aws-cdk/aws-iotevents/lib/expression.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iotevents/lib/expression.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed skinny85’s stale review April 5, 2022 11:50

Pull request has been modified.

@yamatatsu yamatatsu requested a review from skinny85 April 5, 2022 12:44
@skinny85 skinny85 added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Apr 5, 2022
skinny85
skinny85 previously approved these changes Apr 5, 2022
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @yamatatsu!

@skinny85 skinny85 changed the title feat(iot-events): support comparison operators feat(iotevents): support comparison operators Apr 5, 2022
@github-actions github-actions bot added the p2 label Apr 5, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 5, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Apr 7, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed skinny85’s stale review April 8, 2022 17:24

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Apr 8, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: a5737a8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 95cb3f3 into aws:master Apr 8, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 8, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

otaviomacedo pushed a commit that referenced this pull request Apr 11, 2022
This PR includes to implement comparison operators.

- [x] integ test

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
This PR includes to implement comparison operators.

- [x] integ test

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit that referenced this pull request Jul 29, 2022
This PR adds rest binary operators of IoT Events.
This PR does not add new integ tests because of [this conversation](#19329 (comment)).

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
josephedward pushed a commit to josephedward/aws-cdk that referenced this pull request Aug 30, 2022
This PR adds rest binary operators of IoT Events.
This PR does not add new integ tests because of [this conversation](aws#19329 (comment)).

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-iotevents Related to AWS IoT Events p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants