Skip to content

Commit

Permalink
Merge branch 'master' into fix/analytics-config-file-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Souvikns authored Apr 20, 2024
2 parents c20b8f0 + b6702b2 commit ab371f0
Show file tree
Hide file tree
Showing 16 changed files with 3,080 additions and 11,327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:
body: `Hello, @${{ github.actor }}! 👋🏼
This PR is not up to date with the base branch and can't be merged.
Please update your branch manually with the latest version of the base branch.
PRO-TIP: Add a comment to your PR with the text: \`/au\` or \`/autoupdate\` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR.
PRO-TIP: To request an update from the upstream branch, simply comment \`/u\` or \`/update\` and our bot will handle the update operation promptly.
The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Also the update will not work if your fork is located in an organization, not under your personal profile.
Thanks 😄`
})
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
github_token: ${{ secrets.GH_TOKEN }}
committer_username: asyncapi-bot
committer_email: [email protected]
repos_to_ignore: spec,bindings,saunter
repos_to_ignore: spec,bindings,saunter,server-api
custom_id: "dependency update from asyncapi bot"
3 changes: 2 additions & 1 deletion .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
- \`/please-take-a-look\` or \`/ptal\` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
- \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
- \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
- \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.`
- \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)
- \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.`
})

create_help_comment_issue:
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/update-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# This workflow is centrally managed in https://github.com/asyncapi/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

# This workflow will run on every comment with /update or /u. And will create merge-commits for the PR.
# This also works with forks, not only with branches in the same repository/organization.
# Currently, does not work with forks in different organizations.

# This workflow will be distributed to all repositories in the AsyncAPI organization

name: Update PR branches from fork

on:
issue_comment:
types: [created]

jobs:
update-pr:
if: >
startsWith(github.repository, 'asyncapi/') &&
github.event.issue.pull_request &&
github.event.issue.state != 'closed' && (
contains(github.event.comment.body, '/update') ||
contains(github.event.comment.body, '/u')
)
runs-on: ubuntu-latest
steps:
- name: Get Pull Request Details
id: pr
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
previews: 'merge-info-preview' # https://docs.github.com/en/graphql/overview/schema-previews#merge-info-preview-more-detailed-information-about-a-pull-requests-merge-state-preview
script: |
const prNumber = context.payload.issue.number;
core.debug(`PR Number: ${prNumber}`);
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
// If the PR has conflicts, we don't want to update it
const updateable = ['behind', 'blocked', 'unknown', 'draft', 'clean'].includes(pr.mergeable_state);
console.log(`PR #${prNumber} is ${pr.mergeable_state} and is ${updateable ? 'updateable' : 'not updateable'}`);
core.setOutput('updateable', updateable);
core.debug(`Updating PR #${prNumber} with head ${pr.head.sha}`);
return {
id: pr.node_id,
number: prNumber,
head: pr.head.sha,
}
- name: Update the Pull Request
if: steps.pr.outputs.updateable == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const mutation = `mutation update($input: UpdatePullRequestBranchInput!) {
updatePullRequestBranch(input: $input) {
pullRequest {
mergeable
}
}
}`;
const pr_details = ${{ steps.pr.outputs.result }};
try {
const { data } = await github.graphql(mutation, {
input: {
pullRequestId: pr_details.id,
expectedHeadOid: pr_details.head,
}
});
} catch (GraphQLError) {
core.debug(GraphQLError);
if (
GraphQLError.name === 'GraphqlResponseError' &&
GraphQLError.errors.some(
error => error.type === 'FORBIDDEN' || error.type === 'UNAUTHORIZED'
)
) {
// Add comment to PR if the bot doesn't have permissions to update the PR
const comment = `Hi @${context.actor}. Update of PR has failed. It can be due to one of the following reasons:
- I don't have permissions to update this PR. To update your fork with upstream using bot you need to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in the PR.
- The fork is located in an organization, not under your personal profile. No solution for that. You are on your own with manual update.
- There may be a conflict in the PR. Please resolve the conflict and try again.`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
core.setFailed('Bot does not have permissions to update the PR');
} else {
core.setFailed(GraphQLError.message);
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ spec-examples.zip
# Coverage for testing

coverage

# Glee
assets/create-glee-app/templates/default/.glee
assets/create-glee-app/templates/tutorial/.glee
assets/create-glee-app/templates/default/docs
assets/create-glee-app/templates/tutorial/docs
16 changes: 15 additions & 1 deletion assets/create-glee-app/templates/default/README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ This is a [Glee](https://github.com/asyncapi/glee) project bootstrapped with the

## Getting Started

First, run the development server:
1) Install Dependencies:

```bash
npm install --ignore-scripts
```



2) run the development server:

```bash
npm run dev
```

3) send some text to the websocket server at `ws://0.0.0.0:3000/hello`

```bash
websocat ws://0.0.0.0:3000/hello
Hi!
```
You can start editing the API by modifying `functions/onHello.js` and `asyncapi.yaml`. The server auto-updates as you edit the file.

## Learn More
Expand Down
11 changes: 6 additions & 5 deletions assets/create-glee-app/templates/default/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ servers:
protocol: ws
channels:
hello:
address: hello
address: /hello
messages:
hello:
$ref: '#/components/messages/hello'
Expand All @@ -17,11 +17,12 @@ operations:
action: receive
channel:
$ref: '#/channels/hello'
reply:
channel:
$ref: '#/channels/hello'
sendHello:
action: send
channel:
$ref: '#/channels/hello'
components:
messages:
hello:
payload:
type: string
type: string
7 changes: 0 additions & 7 deletions assets/create-glee-app/templates/default/functions/onHello.js

This file was deleted.

11 changes: 11 additions & 0 deletions assets/create-glee-app/templates/default/functions/onHello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GleeFunctionReturn } from "@asyncapi/glee"

export default async function (event): Promise<GleeFunctionReturn> {
return {
send: [{
payload: `Hello from Glee! You said: '${event.payload}'.`,
channel: "hello",
server: "websockets"
}]
}
}
Loading

0 comments on commit ab371f0

Please sign in to comment.