-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vishwahiremat/generateBicepForSecretStores
- Loading branch information
Showing
131 changed files
with
2,371 additions
and
3,513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
Copyright 2023 The Radius Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
module.exports = async ({ github, context }) => { | ||
if (context.eventName === 'issue_comment' && context.payload.action === 'created') { | ||
await handleIssueCommentCreate({ github, context }); | ||
} | ||
} | ||
|
||
// Handle issue comment create event. | ||
async function handleIssueCommentCreate({ github, context }) { | ||
const payload = context.payload; | ||
const issue = context.issue; | ||
const isFromPulls = !!payload.issue.pull_request; | ||
const commentBody = payload.comment.body; | ||
const username = context.actor.toLowerCase(); | ||
|
||
if (!commentBody) { | ||
console.log('[handleIssueCommentCreate] comment body not found, exiting.'); | ||
return; | ||
} | ||
|
||
const commandParts = commentBody.split(/\s+/); | ||
const command = commandParts.shift(); | ||
|
||
switch (command) { | ||
case '/ok-to-test': | ||
await cmdOkToTest(github, issue, isFromPulls, username); | ||
break; | ||
default: | ||
console.log(`[handleIssueCommentCreate] command ${command} not found, exiting.`); | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* Trigger e2e test for the pull request. | ||
* @param {*} github GitHub object reference | ||
* @param {*} issue GitHub issue object | ||
* @param {boolean} isFromPulls is the workflow triggered by a pull request? | ||
*/ | ||
async function cmdOkToTest(github, issue, isFromPulls, userName) { | ||
if (!isFromPulls) { | ||
console.log('[cmdOkToTest] only pull requests supported, skipping command execution.'); | ||
return; | ||
} | ||
|
||
// Check if the user has permission to trigger e2e test with an issue comment | ||
const org = 'project-radius'; | ||
console.log(`Checking team membership for: ${userName}`); | ||
const isMember = await checkTeamMembership(github, org, process.env.TEAM_SLUG, userName); | ||
if (!isMember) { | ||
console.log(`${userName} is not a member of the ${teamSlug} team.`); | ||
return; | ||
} | ||
|
||
// Get pull request | ||
const pull = await github.pulls.get({ | ||
owner: issue.owner, | ||
repo: issue.repo, | ||
pull_number: issue.number, | ||
}); | ||
|
||
if (pull && pull.data) { | ||
// Get commit id and repo from pull head | ||
const testPayload = { | ||
pull_head_ref: pull.data.head.sha, | ||
pull_head_repo: pull.data.head.repo.full_name, | ||
command: 'ok-to-test', | ||
issue: issue, | ||
}; | ||
|
||
console.log('Creating repository dispatch event for e2e test'); | ||
|
||
// Fire repository_dispatch event to trigger e2e test | ||
await github.repos.createDispatchEvent({ | ||
owner: issue.owner, | ||
repo: issue.repo, | ||
event_type: 'functional-tests', | ||
client_payload: testPayload, | ||
}); | ||
|
||
console.log(`[cmdOkToTest] triggered E2E test for ${JSON.stringify(testPayload)}`); | ||
} | ||
} | ||
|
||
async function checkTeamMembership(github, org, teamSlug, userName) { | ||
try { | ||
const response = await github.teams.getMembershipForUserInOrg({ | ||
org: org, | ||
team_slug: teamSlug, | ||
username: userName, | ||
}); | ||
return response.data.state === 'active'; | ||
} catch (error) { | ||
console.log(`error: ${error}`) | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: radius-bot | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
radius-bot: | ||
name: Run Radius Bot script | ||
runs-on: [self-hosted, 1ES.Pool=1ES-Radius ] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Comment analyzer | ||
uses: actions/github-script@v4 | ||
env: | ||
TEAM_SLUG: 'Radius-Eng' | ||
with: | ||
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }} | ||
script: | | ||
const script = require('./.github/scripts/radius-bot.js') | ||
await script({github, context}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
apiVersion: v2 | ||
description: Radius provides a declarative way to manage your infrastructure and applications. | ||
name: radius | ||
description: Radius controller for Kubernetes | ||
type: application | ||
# We automate versioning of the chart during publishing. | ||
# The value here is only used for a dev build. | ||
version: '42.42.42-dev' | ||
dependencies: | ||
- name: de | ||
version: '42.42.42-dev' | ||
repository: "file://de" | ||
- name: ucp | ||
version: '42.42.42-dev' | ||
repository: "file://ucp" | ||
- name: rp | ||
version: '42.42.42-dev' | ||
repository: "file://rp" | ||
# version is the chart version, which will be replaced when this chart is packaged. | ||
version: '0.42.42-dev' | ||
# appVersion is the version of Radius, which will be replaced when this chart is packaged. | ||
appVersion: 'latest' | ||
home: https://radapp.dev | ||
sources: | ||
- https://github.com/project-radius/radius/tree/main/deploy/Chart | ||
maintainers: | ||
- name: Radius Authors | ||
url: https://github.com/project-radius/radius | ||
icon: https://radapp.dev/images/logo.png | ||
keywords: | ||
- radius | ||
- iac | ||
- bicep |
Oops, something went wrong.