Merge branch 'master' into certInfrastructure

This commit is contained in:
Dapr Bot 2022-12-27 14:27:19 -08:00 committed by GitHub
commit 31b0ab842e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 52 deletions

View File

@ -53,7 +53,7 @@ module.exports = async ({ github, context }) => {
async function handleIssueCommentCreate({ github, context }) {
const payload = context.payload;
const issue = context.issue;
const username = context.actor;
const username = (context.actor || "").toLowerCase();
const isFromPulls = !!payload.issue.pull_request;
const commentBody = payload.comment.body;
@ -70,15 +70,12 @@ async function handleIssueCommentCreate({ github, context }) {
}
// Commands that can only be executed by owners.
if (owners.indexOf(username) < 0) {
if (owners.map((v) => v.toLowerCase()).indexOf(username) < 0) {
console.log(`[handleIssueCommentCreate] user ${username} is not an owner, exiting.`);
return;
}
switch (command) {
case "/make-me-laugh":
await cmdMakeMeLaugh(github, issue);
break;
case "/ok-to-test":
await cmdOkToTest(github, issue, isFromPulls);
break;
@ -108,7 +105,7 @@ async function handleIssueOrPrLabeled({ github, context }) {
// Only authorized users can add labels to issues.
if (label == "documentation required") {
// Open a new docs issue
await github.issues.create({
await github.rest.issues.create({
owner: "dapr",
repo: "docs",
title: `New content needed for dapr/components-contrib#${issueNumber}`,
@ -117,7 +114,7 @@ async function handleIssueOrPrLabeled({ github, context }) {
});
} else if (label == "new component") {
// Open a new dapr issue
await github.issues.create({
await github.rest.issues.create({
owner: "dapr",
repo: "dapr",
title: `Component registration for dapr/components-contrib#${issueNumber}`,
@ -145,7 +142,7 @@ async function cmdAssign(github, issue, username, isFromPulls) {
return;
}
await github.issues.addAssignees({
await github.rest.issues.addAssignees({
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
@ -153,27 +150,6 @@ async function cmdAssign(github, issue, username, isFromPulls) {
});
}
/**
* Comment a funny joke.
* @param {*} github GitHub object reference
* @param {*} issue GitHub issue object
*/
async function cmdMakeMeLaugh(github, issue) {
const result = await github.request("https://official-joke-api.appspot.com/random_joke");
jokedata = result.data;
joke = "I have a bad feeling about this.";
if (jokedata && jokedata.setup && jokedata.punchline) {
joke = `${jokedata.setup} - ${jokedata.punchline}`;
}
await github.issues.createComment({
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
body: joke,
});
}
/**
* Trigger e2e test for the pull request.
@ -188,7 +164,7 @@ async function cmdOkToTest(github, issue, isFromPulls) {
}
// Get pull request
const pull = await github.pulls.get({
const pull = await github.rest.pulls.get({
owner: issue.owner,
repo: issue.repo,
pull_number: issue.number
@ -204,7 +180,7 @@ async function cmdOkToTest(github, issue, isFromPulls) {
};
// Fire repository_dispatch event to trigger certification test
await github.repos.createDispatchEvent({
await github.rest.repos.createDispatchEvent({
owner: issue.owner,
repo: issue.repo,
event_type: "certification-test",
@ -212,7 +188,7 @@ async function cmdOkToTest(github, issue, isFromPulls) {
});
// Fire repository_dispatch event to trigger conformance test
await github.repos.createDispatchEvent({
await github.rest.repos.createDispatchEvent({
owner: issue.owner,
repo: issue.repo,
event_type: "conformance-test",

View File

@ -201,15 +201,25 @@ jobs:
creds: ${{ secrets.AZURE_CREDENTIALS }}
if: matrix.required-secrets != ''
# Set this GitHub secret to your KeyVault, and grant the KeyVault policy to your Service Principal:
# az keyvault set-policy -n $AZURE_KEYVAULT --secret-permissions get list --spn $SPN_CLIENT_ID
# Using az cli to query keyvault as Azure/get-keyvault-secrets@v1 is deprecated
- name: Setup secrets
uses: Azure/get-keyvault-secrets@v1
with:
# Set this GitHub secret to your KeyVault, and grant the KeyVault policy to your Service Principal:
# az keyvault set-policy -n $AZURE_KEYVAULT --secret-permissions get list --spn $SPN_CLIENT_ID
keyvault: ${{ secrets.AZURE_KEYVAULT }}
secrets: ${{ matrix.required-secrets }}
id: get-azure-secrets
if: matrix.required-secrets != ''
env:
VAULT_NAME: ${{ secrets.AZURE_KEYVAULT }}
run: |
secrets="${{ matrix.required-secrets }}"
for secretName in $(echo -n $secrets | tr ',' ' '); do
value=$(az keyvault secret show \
--name $secretName \
--vault-name $VAULT_NAME \
--query value \
--output tsv)
echo "::add-mask::$value"
echo "$secretName=$value" >> $GITHUB_OUTPUT
done
# Download the required certificates into files, and set env var pointing to their names
- name: Setup certs

View File

@ -227,15 +227,25 @@ jobs:
creds: ${{ secrets.AZURE_CREDENTIALS }}
if: matrix.required-secrets != ''
# Set this GitHub secret to your KeyVault, and grant the KeyVault policy to your Service Principal:
# az keyvault set-policy -n $AZURE_KEYVAULT --secret-permissions get list --spn $SPN_CLIENT_ID
# Using az cli to query keyvault as Azure/get-keyvault-secrets@v1 is deprecated
- name: Setup secrets
uses: Azure/get-keyvault-secrets@v1
with:
# Set this GitHub secret to your KeyVault, and grant the KeyVault policy to your Service Principal:
# az keyvault set-policy -n $AZURE_KEYVAULT --secret-permissions get list --spn $SPN_CLIENT_ID
keyvault: ${{ secrets.AZURE_KEYVAULT }}
secrets: ${{ matrix.required-secrets }}
id: get-azure-secrets
if: matrix.required-secrets != ''
env:
VAULT_NAME: ${{ secrets.AZURE_KEYVAULT }}
run: |
secrets="${{ matrix.required-secrets }}"
for secretName in $(echo -n $secrets | tr ',' ' '); do
value=$(az keyvault secret show \
--name $secretName \
--vault-name $VAULT_NAME \
--query value \
--output tsv)
echo "::add-mask::$value"
echo "$secretName=$value" >> $GITHUB_OUTPUT
done
- name: Start ngrok
if: contains(matrix.component, 'azure.eventgrid')

View File

@ -35,13 +35,14 @@ jobs:
prune_stale:
name: Prune Stale
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Prune Stale
uses: actions/stale@v3.0.14
uses: actions/stale@v7.0.0
with:
repo-token: ${{ secrets.DAPR_BOT_TOKEN }}
# Different amounts of days for issues/PRs are not currently supported but there is a PR
# open for it: https://github.com/actions/stale/issues/214
repo-token: ${{ github.token }}
days-before-stale: 30
days-before-close: 7
stale-issue-message: >

View File

@ -27,9 +27,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2 # required to make the script available for next step
uses: actions/checkout@v3 # required to make the script available for next step
- name: Issue analyzer
uses: actions/github-script@v4
uses: actions/github-script@v6
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |

View File

@ -31,6 +31,7 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"github.com/dapr/components-contrib/bindings"
@ -301,8 +302,8 @@ func decodeYaml(b []byte) (TestConfiguration, error) {
func (tc *TestConfiguration) loadComponentsAndProperties(t *testing.T, filepath string) (map[string]string, error) {
comps, err := LoadComponents(filepath)
assert.Nil(t, err)
assert.Equal(t, 1, len(comps)) // We only expect a single component per file
require.NoError(t, err)
require.Equal(t, 1, len(comps)) // We only expect a single component per file
c := comps[0]
props, err := ConvertMetadataToProperties(c.Spec.Metadata)