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

merge queue: embarking main (e237587) and #122 together #125

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c076325
feat: `bring eventbridge`
skorfmann Dec 22, 2023
456259d
Merge branch 'main' into eventbridge
skorfmann Dec 22, 2023
c316216
Merge branch 'main' into eventbridge
eladb Dec 30, 2023
52b9fe8
fix (#45)
MarkMcCulloh Dec 30, 2023
2cd6d10
fix(websockets): fix token usage in simulator (#46)
eladb Jan 1, 2024
aafd29b
chore(bedrock): replacing BEDROCK_DEV with isTestEnvironment (#47)
Jan 2, 2024
c65266b
feat: `bring github` (#39)
eladcon Jan 2, 2024
5c0d7b5
fix(github): mts to js files (#48)
Jan 2, 2024
2a18bad
fix(github): using interface for credentials instead of cloud.secret …
Jan 2, 2024
c18f81b
fix(github): can't compile to tf-aws, missing cloud.service (#50)
Jan 3, 2024
dfa0cb1
chore: set up GitHub releases (#51)
Chriscbr Jan 4, 2024
7ec95d7
chore: mergify fixes (#52)
Chriscbr Jan 4, 2024
ce2696d
chore: fix mergify conditions (#53)
Chriscbr Jan 4, 2024
9adcff4
chore: mergify fixing continued (#54)
Chriscbr Jan 4, 2024
6b9db75
chore: mergify fixes (#55)
Chriscbr Jan 4, 2024
0439bf9
chore: testing
Chriscbr Jan 4, 2024
e4e9ae2
fix: unit test regression (#56)
Chriscbr Jan 4, 2024
40c0f54
Merge branch 'main' into eventbridge
skorfmann Feb 29, 2024
0db1cc1
deployable version
skorfmann Feb 29, 2024
a97d641
remove accidental commit
skorfmann Feb 29, 2024
1d6e04c
Update eventbridge/platform/sim/bus.w
eladcon Mar 7, 2024
df57157
wip
eladcon Mar 7, 2024
7fbd3fa
wip
eladcon Mar 7, 2024
1861b0c
wip
eladcon Mar 7, 2024
e6b86c3
wip
eladcon Mar 7, 2024
9978071
wip
eladcon Mar 13, 2024
0a72274
wip
eladcon Mar 13, 2024
82df437
wip
eladcon Mar 13, 2024
261ce73
wip
eladcon Mar 13, 2024
7091031
Merge branch 'main' into eventbridge-readme
eladcon Mar 13, 2024
9cf9f8a
wip
eladcon Mar 13, 2024
74a678a
wip
eladcon Mar 13, 2024
40c07dc
Merge branch 'main' into eventbridge-optional-props
eladcon Mar 13, 2024
69aad72
wip
eladcon Mar 13, 2024
456312f
wip
eladcon Mar 13, 2024
35e84ee
wip
eladcon Mar 13, 2024
9befa33
generate workflows
eladcon Mar 14, 2024
316c302
Merge of #122
mergify[bot] Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ jobs:
- name: Test
run: wing test
working-directory: checks
canary-eventbridge:
name: Test eventbridge
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: eventbridge
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
- name: Install dependencies
run: npm install --include=dev
working-directory: eventbridge
- name: Test
run: wing test
working-directory: eventbridge
canary-fifoqueue:
name: Test fifoqueue
runs-on: ubuntu-latest
Expand Down Expand Up @@ -109,6 +130,27 @@ jobs:
- name: Test
run: wing test
working-directory: github
canary-lock:
name: Test lock
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: lock
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
- name: Install dependencies
run: npm install --include=dev
working-directory: lock
- name: Test
run: wing test
working-directory: lock
canary-ngrok:
name: Test ngrok
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eventbridge-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
paths:
- eventbridge/**
jobs:
build:
build-eventbridge:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/eventbridge-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
- main
paths:
- eventbridge/**
- "!eventbridge/package-lock.json"
jobs:
build:
build-eventbridge:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -16,7 +17,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
Expand All @@ -29,9 +30,25 @@ jobs:
- name: Pack
run: wing pack
working-directory: eventbridge
- name: Get package version
run: echo WINGLIB_VERSION=$(node -p "require('./package.json').version") >>
"$GITHUB_ENV"
working-directory: eventbridge
- name: Publish
run: npm publish --access=public --registry https://registry.npmjs.org --tag
latest *.tgz
working-directory: eventbridge
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag commit
uses: tvdias/[email protected]
with:
repo-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
tag: eventbridge-v${{ env.WINGLIB_VERSION }}
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
name: eventbridge v${{ env.WINGLIB_VERSION }}
tag_name: eventbridge-v${{ env.WINGLIB_VERSION }}
files: "*.tgz"
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/lock-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
paths:
- lock/**
jobs:
build:
build-lock:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/lock-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
- main
paths:
- lock/**
- "!lock/package-lock.json"
jobs:
build:
build-lock:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -16,7 +17,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
Expand All @@ -29,9 +30,25 @@ jobs:
- name: Pack
run: wing pack
working-directory: lock
- name: Get package version
run: echo WINGLIB_VERSION=$(node -p "require('./package.json').version") >>
"$GITHUB_ENV"
working-directory: lock
- name: Publish
run: npm publish --access=public --registry https://registry.npmjs.org --tag
latest *.tgz
working-directory: lock
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag commit
uses: tvdias/[email protected]
with:
repo-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
tag: lock-v${{ env.WINGLIB_VERSION }}
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
name: lock v${{ env.WINGLIB_VERSION }}
tag_name: lock-v${{ env.WINGLIB_VERSION }}
files: "*.tgz"
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
12 changes: 12 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ pull_request_rules:
- -check-failure=build-containers
- -check-pending=build-containers
- -check-stale=build-containers
- -check-failure=build-eventbridge
- -check-pending=build-eventbridge
- -check-stale=build-eventbridge
- -check-failure=build-fifoqueue
- -check-pending=build-fifoqueue
- -check-stale=build-fifoqueue
- -check-failure=build-github
- -check-pending=build-github
- -check-stale=build-github
- -check-failure=build-lock
- -check-pending=build-lock
- -check-stale=build-lock
- -check-failure=build-ngrok
- -check-pending=build-ngrok
- -check-stale=build-ngrok
Expand Down Expand Up @@ -95,12 +101,18 @@ pull_request_rules:
- -check-failure=build-containers
- -check-pending=build-containers
- -check-stale=build-containers
- -check-failure=build-eventbridge
- -check-pending=build-eventbridge
- -check-stale=build-eventbridge
- -check-failure=build-fifoqueue
- -check-pending=build-fifoqueue
- -check-stale=build-fifoqueue
- -check-failure=build-github
- -check-pending=build-github
- -check-stale=build-github
- -check-failure=build-lock
- -check-pending=build-lock
- -check-stale=build-lock
- -check-failure=build-ngrok
- -check-pending=build-ngrok
- -check-stale=build-ngrok
Expand Down
12 changes: 9 additions & 3 deletions eventbridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,36 @@ bring eventbridge;

let bus = new eventbridge.Bus(name: "my-bus");

bus.subscribeFunction("github.pull-request.created", inflight (event) => {
bus.onEvent("github.pull-request.created", inflight (event) => {
log("subscribed event received {Json.stringify(event)}");
}, {
"detail-type": [{"prefix": "pull-request."}],
"source": ["github.com"],
});

new cloud.Function(inflight () => {
bus.putEvents([{
bus.putEvents({
detailType: "pull-request.created",
resources: ["test"],
source: "github.com",
version: "0",
detail: {
"test": "test",
},
}]);
});
});
```

## Parameters

* eventBridgeName - `str` - Optional. Name of an existing EventBridge to reference.

#### Usage

```sh
wing compile -t @winglang/platform-awscdk -v eventBridgeName="my-bus" main.w
```

## License

This library is licensed under the [MIT License](./LICENSE).
10 changes: 5 additions & 5 deletions eventbridge/lib.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class InboundGithubEvents {
this.bucket = new cloud.Bucket();
let counter = new cloud.Counter();

eventBridge.subscribeFunction("github.pull-request.created", inflight (event) => {
eventBridge.onEvent("github.pull-request.created", inflight (event) => {
log("subscribed event received {Json.stringify(event)}");
this.bucket.put("test-{counter.inc()}", Json.stringify(event));
}, {
Expand Down Expand Up @@ -46,15 +46,15 @@ let env = new Environments();

test "publish to eventbridge" {
log("publishing to eventbridge");
eventBridge.putEvents([{
eventBridge.putEvents({
detailType: "pull-request.created",
resources: ["test"],
source: "github.com",
version: "0",
detail: {
"test": "test",
},
}]);
});

log("published");

Expand All @@ -73,15 +73,15 @@ test "publish to eventbridge" {

expect.equal(0, env.bucket.list().length);

eventBridge.putEvents([{
eventBridge.putEvents({
detailType: "myTest.check",
resources: ["test"],
source: "myTest",
version: "0",
detail: {
"fake": "env",
},
}]);
});

log("published 2nd event");

Expand Down
8 changes: 4 additions & 4 deletions eventbridge/lib.w
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bring "./platform/awscdk" as awscdk;
pub class Bus impl types.IBus {
inner: types.IBus;

new(props: types.BusProps) {
new(props: types.BusProps?) {
let target = util.env("WING_TARGET");
if target == "sim" {
this.inner = new sim.Bus(props) as "sim";
Expand All @@ -24,12 +24,12 @@ pub class Bus impl types.IBus {
}
}

pub inflight putEvents(events: Array<types.PublishEvent>): void {
pub inflight putEvents(...events: Array<types.PublishEvent>): void {
this.inner.putEvents(events);
}

pub subscribeFunction(name: str, handler: inflight (types.Event): void, pattern: Json): void {
this.inner.subscribeFunction(name, handler, pattern);
pub onEvent(name: str, handler: inflight (types.Event): void, pattern: Json): void {
this.inner.onEvent(name, handler, pattern);
}
pub subscribeQueue(name: str, queue: cloud.Queue, pattern: Json): void {
this.inner.subscribeQueue(name, queue, pattern);
Expand Down
4 changes: 2 additions & 2 deletions eventbridge/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eventbridge/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@winglibs/eventbridge",
"description": "Amazon EventBridge library for Wing",
"version": "0.0.2",
"version": "0.0.3",
"repository": {
"type": "git",
"url": "https://github.com/winglang/winglibs.git",
Expand Down
6 changes: 3 additions & 3 deletions eventbridge/platform/awscdk/eventbridge.w
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ pub class Bus impl types.IBus {

eventBridge: cdk.aws_events.IEventBus;

new(props: types.BusProps) {
new(props: types.BusProps?) {
let app = nodeof(this).app;
// TODO: use typed properties when its available
if let eventBridgeName = unsafeCast(app)?.platformParameters?.getParameterValue("eventBridgeName") {
this.eventBridge = cdk.aws_events.EventBus.fromEventBusName(this, "EventBridge", eventBridgeName);
} else {
this.eventBridge = new cdk.aws_events.EventBus(eventBusName: props.name) as "EventBridge";
this.eventBridge = new cdk.aws_events.EventBus(eventBusName: props?.name ?? "eventbridge-{this.node.addr.substring(0, 8)}") as "EventBridge";
}
}

pub subscribeFunction(name: str, handler: inflight (types.Event): void, pattern: Json): void {
pub onEvent(name: str, handler: inflight (types.Event): void, pattern: Json): void {
// event will be json of type `types.Event`
let funk = new cloud.Function(inflight (event) => {
// since wing structs don't supoort custom serialization we need to do it manually
Expand Down
2 changes: 1 addition & 1 deletion eventbridge/platform/sim/bus.w
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub class EventBridgeBus {
topic: cloud.Topic;
var handlerCount: num;

new(props: types.BusProps) {
new(props: types.BusProps?) {
this.topic = new cloud.Topic() as "EventBridge";

this.handlerCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions eventbridge/platform/sim/eventbridge.w
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ bring "./bus.w" as bus;
pub class Bus impl types.IBus {
bus: bus.EventBridgeBus;

new(props: types.BusProps) {
new(props: types.BusProps?) {
this.bus = new bus.EventBridgeBus(props);
}

pub subscribeFunction(name: str, handler: inflight (types.Event): void, pattern: Json): void {
pub onEvent(name: str, handler: inflight (types.Event): void, pattern: Json): void {
class FnRule {
new(bus: bus.EventBridgeBus) {
let onMessageHandler = bus.subscribe(inflight (event) => {
Expand Down
Loading
Loading