From fe45037f347bbc1fa8cecb3c96a81aa0ed3ccb57 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 4 Jul 2022 12:04:16 +0800 Subject: [PATCH 01/20] chore: bumped .net version in global to 6.0.301 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 572a2a6fa..2a1043b5a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.200" + "version": "6.0.301" } } From de5e8e0a8ffad8bed2afddf66ad607aa0813581c Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sun, 17 Jul 2022 23:47:13 +0800 Subject: [PATCH 02/20] chore: updated list of assignees --- .github/auto_assign-issues.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/auto_assign-issues.yml b/.github/auto_assign-issues.yml index f5f16997b..528a2a501 100644 --- a/.github/auto_assign-issues.yml +++ b/.github/auto_assign-issues.yml @@ -3,6 +3,5 @@ addAssignees: true # The list of users to assign to new issues. # If empty or not provided, the repository owner is assigned assignees: - - t1agob - sliedig - amirkaws From 8d5ad915c42ad1ed39679ca78e2d1a0efd93bad4 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sun, 17 Jul 2022 23:47:52 +0800 Subject: [PATCH 03/20] chore: updated PR labeling path --- .github/boring-cyborg.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index 458c4b1b7..af1e128af 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -1,5 +1,8 @@ ##### Labeler ########################################################################################################## labelPRBasedOnFilePath: + area/common: + - libraries/src/AWS.Lambda.Powertools.Common/* + - libraries/src/AWS.Lambda.Powertools.Common/**/* area/logger: - libraries/src/AWS.Lambda.Powertools.Logging/* - libraries/src/AWS.Lambda.Powertools.Logging/**/* From 21c528987eb2ebbc2b42776092eee213fd221f5b Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sun, 17 Jul 2022 23:48:29 +0800 Subject: [PATCH 04/20] chore: removed unnecessary pr labeling --- .github/labeler.yml | 15 ------------ .github/workflows/pr-labeler.yml | 42 -------------------------------- 2 files changed, 57 deletions(-) delete mode 100644 .github/labeler.yml delete mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 6c2eecacb..000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,15 +0,0 @@ -area/common: -- libraries/src/AWS.Lambda.Powertools.Common/* -- libraries/src/AWS.Lambda.Powertools.Common/**/* - -area/logging: -- libraries/src/AWS.Lambda.Powertools.Logging/* -- libraries/src/AWS.Lambda.Powertools.Logging/**/* - -area/metrics: -- libraries/src/AWS.Lambda.Powertools.Metrics/* -- libraries/src/AWS.Lambda.Powertools.Metrics/**/* - -area/tracing: -- libraries/src/AWS.Lambda.Powertools.Tracing/* -- libraries/src/AWS.Lambda.Powertools.Tracing/**/* \ No newline at end of file diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml deleted file mode 100644 index e7513c242..000000000 --- a/.github/workflows/pr-labeler.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: "Pull Request Labeler" -on: - pull_request_target: - types: [opened] - -jobs: - - apply-file-based-labels: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - - apply-internal-external-label: - permissions: - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v5 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const maintainers = ['sliedig', 'amirkaws'] - if (maintainers.includes(context.payload.sender.login)) { - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['pr/internal'] - }) - } else { - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['pr/external'] - }) - } From 24d787ba1dff09cbe3a6f38b8e76d5c8ead520a2 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sun, 17 Jul 2022 23:55:15 +0800 Subject: [PATCH 05/20] chore: updated stale action --- .github/stale.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/stale.yml b/.github/stale.yml index 1bb42057e..cc68da08e 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,12 +1,9 @@ only: issues -daysUntilStale: 30 +daysUntilStale: 14 daysUntilClose: 7 exemptLabels: - bug - - documentation - - enhancement - feature-request - - RFC staleLabel: pending-close-response-required markComment: > This issue has been automatically marked as stale because it has not had @@ -14,4 +11,4 @@ markComment: > for your contributions. closeComment: > This issue has been automatically closed because of inactivity. - Please open a new issue if you are still encountering problems. + Please open a new issue if you are still encountering problems. \ No newline at end of file From 8f765aac678a467cb0fbb4bc1b4240f7fcc4fd70 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sun, 17 Jul 2022 23:55:52 +0800 Subject: [PATCH 06/20] chore: deleted unnecessay publishing action --- .github/workflows/publish.yml | 62 ----------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 296807b4b..000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Publish new package version - -on: - push: - paths: - - 'version.json' - -jobs: - release: - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Read AWS.Lambda.Powertools.Common version - id: common-version - uses: notiz-dev/github-action-json-property@release - with: - path: 'version.json' - prop_path: 'Core.Common' - - name: Read AWS.Lambda.Powertools.Logging version - id: logging-version - uses: notiz-dev/github-action-json-property@release - with: - path: 'version.json' - prop_path: 'Core.Logging' - - name: Read AWS.Lambda.Powertools.Tracing version - id: tracing-version - uses: notiz-dev/github-action-json-property@release - with: - path: 'version.json' - prop_path: 'Core.Tracing' - - name: Read AWS.Lambda.Powertools.Metrics version - id: metrics-version - uses: notiz-dev/github-action-json-property@release - with: - path: 'version.json' - prop_path: 'Core.Metrics' - - name: Setup .NET 6.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Setup semver - run: dotnet tool install -g dotnet-setversion - - name: Set assembly version in all projects - run: | - setversion ${{steps.common-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj - setversion ${{steps.logging-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj - setversion ${{steps.metrics-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj - setversion ${{steps.tracing-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj - - name: Authenticate to GitHub packages # Temporary package repository for publishing validation - run: dotnet nuget add source --username ${{ secrets.PUBLISH_USERNAME }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name nuget ${{ secrets.NUGET_SOURCE }} - - name: Generate NuGet Packages - run: | - cd buildtools - dotnet build -c Release - - name: Publish NuGet Packages - run: | - cd deploy/nuget-packages - dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate -s nuget - From dc46efd0c019589b733fcc2d0263093e59132007 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 00:20:38 +0800 Subject: [PATCH 07/20] feat: updated record_pr action --- .github/scripts/save_pr_details.js | 13 +++++++++++++ .github/workflows/record_pr.yml | 23 ++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 .github/scripts/save_pr_details.js diff --git a/.github/scripts/save_pr_details.js b/.github/scripts/save_pr_details.js new file mode 100644 index 000000000..bc3de6734 --- /dev/null +++ b/.github/scripts/save_pr_details.js @@ -0,0 +1,13 @@ +module.exports = async ({github, context, core}) => { + const fs = require('fs'); + const filename = "pr.txt"; + + try { + fs.writeFileSync(`./${filename}`, JSON.stringify(context.payload)); + + return `PR successfully saved ${filename}` + } catch (err) { + core.setFailed("Failed to save PR details"); + console.error(err); + } +} \ No newline at end of file diff --git a/.github/workflows/record_pr.yml b/.github/workflows/record_pr.yml index 88edce19f..39b9ec436 100644 --- a/.github/workflows/record_pr.yml +++ b/.github/workflows/record_pr.yml @@ -1,21 +1,22 @@ -name: Record PR number +name: Record PR details on: pull_request: - types: [opened, edited] + types: [opened, edited, closed] jobs: - build: + record_pr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Save PR number - run: | - mkdir -p ./pr - echo ${{ github.event.number }} > ./pr/number - echo "${{ github.event.pull_request.title }}" > ./pr/title - - uses: actions/upload-artifact@v2 + - uses: actions/checkout@v3 + - name: "Extract PR details" + uses: actions/github-script@v6 + with: + script: | + const script = require('.github/scripts/save_pr_details.js') + await script({github, context, core}) + - uses: actions/upload-artifact@v3 with: name: pr - path: pr/ \ No newline at end of file + path: pr.txt \ No newline at end of file From 244a4d78f1d872cfb4f882c960e6201df6851c5d Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 00:23:41 +0800 Subject: [PATCH 08/20] chore: updated Label PR based on title action --- .github/scripts/constants.js | 42 ++++++++++ .github/scripts/label_pr_based_on_title.js | 60 +++++++++++++++ .github/workflows/label_pr_on_title.yml | 90 +++++----------------- 3 files changed, 122 insertions(+), 70 deletions(-) create mode 100644 .github/scripts/constants.js create mode 100644 .github/scripts/label_pr_based_on_title.js diff --git a/.github/scripts/constants.js b/.github/scripts/constants.js new file mode 100644 index 000000000..7c0556ed9 --- /dev/null +++ b/.github/scripts/constants.js @@ -0,0 +1,42 @@ +module.exports = Object.freeze({ + /** @type {string} */ + // Values: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + "PR_ACTION": process.env.PR_ACTION || "", + + /** @type {string} */ + "PR_AUTHOR": process.env.PR_AUTHOR?.replace(/"/g, '') || "", + + /** @type {string} */ + "PR_BODY": process.env.PR_BODY || "", + + /** @type {string} */ + "PR_TITLE": process.env.PR_TITLE || "", + + /** @type {number} */ + "PR_NUMBER": process.env.PR_NUMBER || 0, + + /** @type {string} */ + "PR_IS_MERGED": process.env.PR_IS_MERGED || "false", + + /** @type {string} */ + "LABEL_BLOCK": "do-not-merge", + + /** @type {string} */ + "LABEL_BLOCK_REASON": "need-issue", + + // /** @type {string} */ + // "LABEL_PENDING_RELEASE": "pending-release", + + /** @type {string} */ + "HANDLE_MAINTAINERS_TEAM": "@awslabs/aws-lambda-powertools-net", + + /** @type {string[]} */ + "IGNORE_AUTHORS": ["dependabot[bot]", "markdownify[bot]"], + + /** @type {string[]} */ + "AREAS": [ + "tracing", + "metrics", + "logger", + ], +}); \ No newline at end of file diff --git a/.github/scripts/label_pr_based_on_title.js b/.github/scripts/label_pr_based_on_title.js new file mode 100644 index 000000000..5ad398420 --- /dev/null +++ b/.github/scripts/label_pr_based_on_title.js @@ -0,0 +1,60 @@ +const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") + +module.exports = async ({github, context, core}) => { + const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ + const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ + const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ + const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ + const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ + const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ + + const labels = { + "feature": FEAT_REGEX, + "bug": BUG_REGEX, + "documentation": DOCS_REGEX, + "internal": CHORE_REGEX, + "enhancement": REFACTOR_REGEX, + "deprecated": DEPRECATED_REGEX, + } + + // Maintenance: We should keep track of modified PRs in case their titles change + let miss = 0; + try { + for (const label in labels) { + const matcher = new RegExp(labels[label]) + const isMatch = matcher.exec(PR_TITLE) + if (isMatch != null) { + core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) + + await github.rest.issues.addLabels({ + issue_number: PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [label] + }) + + const area = matches[2]; // second capture group contains the area + if (AREAS.indexOf(area) > -1) { + core.info(`Auto-labeling PR ${PR_NUMBER} with area ${area}`); + await github.rest.issues.addLabels({ + issue_number: PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [`area/${area}`], + }); + } else { + core.debug(`'${PR_TITLE}' didn't match any known area.`); + } + + return; + } else { + core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`) + miss += 1 + } + } + } finally { + if (miss == Object.keys(labels).length) { + return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) + } + } +} \ No newline at end of file diff --git a/.github/workflows/label_pr_on_title.yml b/.github/workflows/label_pr_on_title.yml index 45adc1af3..9b0f2d3f0 100644 --- a/.github/workflows/label_pr_on_title.yml +++ b/.github/workflows/label_pr_on_title.yml @@ -2,86 +2,36 @@ name: Label PR based on title on: workflow_run: - workflows: ["Record PR number"] + workflows: ["Record PR details"] types: - completed jobs: - upload: - runs-on: ubuntu-latest + get_pr_details: # Guardrails to only ever run if PR recording workflow was indeed # run in a PR event and ran successfully - if: > - ${{ github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: ./.github/workflows/reusable_export_pr_details.yml + with: + record_pr_workflow_id: ${{ github.event.workflow_run.id }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + label_pr: + needs: get_pr_details + runs-on: ubuntu-latest steps: - - name: 'Download artifact' - uses: actions/github-script@v5 - # For security, we only download artifacts tied to the successful PR recording workflow - with: - script: | - const fs = require('fs'); - - const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{github.event.workflow_run.id }}, - }); - - const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; - - const artifact = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - - fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(artifact.data)); - # NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead - - run: unzip pr.zip - - - name: 'Label PR based on title' - uses: actions/github-script@v5 + - name: Checkout repository + uses: actions/checkout@v3 + - name: "Label PR based on title" + uses: actions/github-script@v6 + env: + PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }} + PR_TITLE: ${{ needs.get_pr_details.outputs.prTitle }} with: github-token: ${{ secrets.GITHUB_TOKEN }} # This safely runs in our base repo, not on fork # thus allowing us to provide a write access token to label based on PR title # and label PR based on semantic title accordingly script: | - const fs = require('fs'); - const pr_number = Number(fs.readFileSync('./number')); - const pr_title = fs.readFileSync('./title', 'utf-8').trim(); - - const FEAT_REGEX = /feat(\((\w+)\))?(\:.+)/ - const BUG_REGEX = /(fix|bug)(\((\w+)\))?(\:.+)/ - const DOCS_REGEX = /(docs|doc)(\((\w+)\))?(\:.+)/ - const CHORE_REGEX = /(chore)(\((\w+)\))?(\:.+)/ - const DEPRECATED_REGEX = /(deprecated)(\((\w+)\))?(\:.+)/ - const REFACTOR_REGEX = /(refactor)(\((\w+)\))?(\:.+)/ - - const labels = { - "feature": FEAT_REGEX, - "bug": BUG_REGEX, - "documentation": DOCS_REGEX, - "internal": CHORE_REGEX, - "enhancement": REFACTOR_REGEX, - "deprecated": DEPRECATED_REGEX, - } - - for (const label in labels) { - const matcher = new RegExp(labels[label]) - const isMatch = matcher.exec(pr_title) - if (isMatch != null) { - console.info(`Auto-labeling PR ${pr_number} with ${label}`) - - await github.rest.issues.addLabels({ - issue_number: pr_number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [label] - }) - - break - } - } \ No newline at end of file + const script = require('.github/scripts/label_pr_based_on_title.js') + await script({github, context, core}) \ No newline at end of file From 638f933c36c87d7402a4af2cffafb7ac070ae9ce Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 00:26:07 +0800 Subject: [PATCH 09/20] feature: hard coded .NET version number in build action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32c71566c..4eb6a2e72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET 6.0 uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.x + dotnet-version: 6.0.302 - name: Install solution dependencies run: dotnet restore - name: Build From 1482b71465d31230e764f870808494ec196a73e5 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 18:56:25 +0800 Subject: [PATCH 10/20] fix: updated auto assign --- .github/auto_assign-issues.yml | 7 ------- .github/auto_assign.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) delete mode 100644 .github/auto_assign-issues.yml create mode 100644 .github/auto_assign.yml diff --git a/.github/auto_assign-issues.yml b/.github/auto_assign-issues.yml deleted file mode 100644 index 528a2a501..000000000 --- a/.github/auto_assign-issues.yml +++ /dev/null @@ -1,7 +0,0 @@ -addAssignees: true - -# The list of users to assign to new issues. -# If empty or not provided, the repository owner is assigned -assignees: - - sliedig - - amirkaws diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 000000000..b416fad7a --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,28 @@ +# Set to true to add reviewers to pull requests +addReviewers: true + +# Set to true to add assignees to pull requests +addAssignees: true + +# A list of reviewers to be added to pull requests (GitHub user name) +reviewers: + - sliedig + - amirkaws + +# A number of reviewers added to the pull request +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 1 + +# A list of assignees, overrides reviewers if set +# assignees: +# - sliedig +# - amirkaws + +# A number of assignees to add to the pull request +# Set to 0 to add all of the assignees. +# Uses numberOfReviewers if unset. +# numberOfAssignees: 2 + +# A list of keywords to be skipped the process that add reviewers if pull requests include it +# skipKeywords: +# - wip \ No newline at end of file From 2cf21a395efe1a0340e2d4a7cd7ad4d9d7d5fc3a Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 19:00:24 +0800 Subject: [PATCH 11/20] feat: added security.md --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..8db8c1dcc --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +## Reporting a Vulnerability + +If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security +via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. +Please do **not** create a public GitHub issue. \ No newline at end of file From 511143a41585cff353ef5164c91646bab2aad885 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 19:04:06 +0800 Subject: [PATCH 12/20] chore: updated issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 128 +++++++++----- .github/ISSUE_TEMPLATE/config.yaml | 5 + .../documentation-improvements.md | 64 +++++-- .github/ISSUE_TEMPLATE/feature_request.md | 62 +++++-- .github/ISSUE_TEMPLATE/rfc.md | 159 +++++++++++------- 5 files changed, 284 insertions(+), 134 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b67ee85ea..ce050b9fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,43 +1,91 @@ ---- name: Bug report -about: Create a report to help us improve -title: '' -labels: bug, triage -assignees: '' +description: Report a reproducible bug to help us improve +title: "Bug: TITLE" +labels: ["bug", "triage"] +body: + - type: markdown + attributes: + value: | + Thank you for submitting a bug report. Please add as much information as possible to help us reproduce, and remove any potential sensitive data. ---- + Please become familiar with [our definition of bug](https://github.com/awslabs/aws-lambda-powertools-dotnet/blob/develop/MAINTAINERS.md#is-that-a-bug). + - type: textarea + id: expected_behaviour + attributes: + label: Expected Behaviour + description: Please share details on the behaviour you expected + validations: + required: true + - type: textarea + id: current_behaviour + attributes: + label: Current Behaviour + description: Please share details on the current issue + validations: + required: true + - type: textarea + id: code_snippet + attributes: + label: Code snippet + description: Please share a code snippet to help us reproduce the issue + render: python + validations: + required: true + - type: textarea + id: solution + attributes: + label: Possible Solution + description: If known, please suggest a potential resolution + validations: + required: false + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: Please share how we might be able to reproduce this issue + validations: + required: true + - type: input + id: version + attributes: + label: AWS Lambda Powertools for Python version + placeholder: "latest, 1.25.6" + value: latest + validations: + required: true + - type: dropdown + id: runtime + attributes: + label: AWS Lambda function runtime + options: + - 3.6 + - 3.7 + - 3.8 + - 3.9 + validations: + required: true + - type: dropdown + id: packaging + attributes: + label: Packaging format used + options: + - Lambda Layers + - Serverless Application Repository (SAR) App + - PyPi + multiple: true + validations: + required: true + - type: textarea + id: logs + attributes: + label: Debugging logs + description: If available, please share [debugging logs](https://awslabs.github.io/aws-lambda-powertools-python/#debug-mode) + render: python + validations: + required: false + - type: markdown + attributes: + value: | + --- - - - -**What were you trying to accomplish?** - -## Expected Behavior - - - -## Current Behavior - - - -## Possible Solution - - - -## Steps to Reproduce (for bugs) - - -1. -2. -3. -4. - -## Environment - -* **Powertools version used**: -* **AWS Lambda function runtime:** -* **Debugging logs** - -```csharp -# paste logs here -``` + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 000000000..66717393d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/awslabs/aws-lambda-powertools-dotnet/discussions/new + about: Ask a general question about Lambda Powertools \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation-improvements.md b/.github/ISSUE_TEMPLATE/documentation-improvements.md index 8341ae4e0..ff6fae27d 100644 --- a/.github/ISSUE_TEMPLATE/documentation-improvements.md +++ b/.github/ISSUE_TEMPLATE/documentation-improvements.md @@ -1,17 +1,51 @@ ---- name: Documentation improvements -about: Suggest a documentation update -title: '' -labels: documentation -assignees: '' +description: Suggest a documentation update to improve everyone's experience +title: "Docs: TITLE" +labels: ["documentation", "triage"] +body: + - type: markdown + attributes: + value: | + Thank you for helping us improve everyone's experience. We review documentation updates on a case by case basis. + - type: textarea + id: search_area + attributes: + label: What were you searching in the docs? + description: Please help us understand how you looked for information that was either unclear or not available + validations: + required: true + - type: input + id: area + attributes: + label: Is this related to an existing documentation section? + description: Please share a link, if applicable + validations: + required: false + - type: textarea + id: idea + attributes: + label: How can we improve? + description: Please share your thoughts on how we can improve this experience + render: markdown + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: Got a suggestion in mind? + description: Please suggest a proposed update + validations: + required: false + - type: checkboxes + id: acknowledgment + attributes: + label: Acknowledgment + options: + - label: I understand the final update might be different from my proposed suggestion, or refused. + required: true + - type: markdown + attributes: + value: | + --- ---- - -**What were you initially searching for in the docs?** - - -**Is this related to an existing part of the documentation? Please share a link** - -**Describe how we could make it clearer** - -**If you have a proposed update, please share it here** + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index b837b7ad5..80a3cf946 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,20 +1,48 @@ ---- name: Feature request -about: Suggest an idea for this project -title: '' -labels: feature-request, triage -assignees: '' +description: Suggest an idea for Lambda Powertools +title: "Feature request: TITLE" +labels: ["feature-request", "triage"] +body: + - type: markdown + attributes: + value: | + Thank you for taking the time to suggest an idea to the Lambda Powertools project. ---- + *Future readers*: Please react with 👍 and your use case to help us understand customer demand. + - type: textarea + id: problem + attributes: + label: Use case + description: Please help us understand your use case or problem you're facing + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: Solution/User Experience + description: Please share what a good solution would look like to this use case + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternative solutions + description: Please describe what alternative solutions to this use case, if any + render: markdown + validations: + required: false + - type: checkboxes + id: acknowledgment + attributes: + label: Acknowledgment + options: + - label: This feature request meets [Lambda Powertools Tenets](https://awslabs.github.io/aws-lambda-powertools-dotnet/tenets/) + required: true + - label: Should this be considered in other Lambda Powertools languages? i.e. [Python](https://github.com/awslabs/aws-lambda-powertools-python), [Java](https://github.com/awslabs/aws-lambda-powertools-java/), [TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript/) + required: false + - type: markdown + attributes: + value: | + --- -**Is your feature request related to a problem? Please describe.** - - -**Describe the solution you'd like** - - -**Describe alternatives you've considered** - - -**Additional context** - + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/rfc.md b/.github/ISSUE_TEMPLATE/rfc.md index a521ff873..e4bb28d71 100644 --- a/.github/ISSUE_TEMPLATE/rfc.md +++ b/.github/ISSUE_TEMPLATE/rfc.md @@ -1,62 +1,97 @@ ---- -name: RFC -about: Feature design and proposals -title: 'RFC: ' -labels: RFC, triage -assignees: '' -approved by: '' ---- - -## Key information - -* RFC PR: (leave this empty) -* Related issue(s), if known: -* Area: (i.e. Tracer, Metrics, Logger, etc.) -* Meet [tenets](https://awslabs.github.io/aws-lambda-powertools-dotnet/#tenets): (Yes/no) -* Approved by: '' -* Reviewed by: '' - -## Summary -[summary]: #summary - -> One paragraph explanation of the feature. - -## Motivation -[motivation]: #motivation - -> Why are we doing this? What use cases does it support? What is the expected outcome? - -## Proposal -[proposal]: #proposal - -> This is the bulk of the RFC. - -> Explain the design in enough detail for somebody familiar with Powertools to understand it, and for somebody familiar with the implementation to implement it. - -**If this feature should be available in other runtimes (e.g. Java, Typescript), how would this look like to ensure consistency?** - -## User Experience - -**How would customers use it?** - -**Any configuration or corner cases you'd expect?** - -**Demonstration of before and after on how the experience will be better** - -## Drawbacks -[drawbacks]: #drawbacks - -> Why should we *not* do this? - -> Do we need additional dependencies? Impact performance/package size? - -## Rationale and alternatives -[rationale-and-alternatives]: #rationale-and-alternatives - -* **What other designs have been considered? Why not them?** -* **What is the impact of not doing this?** - -## Unresolved questions -[unresolved-questions]: #unresolved-questions - -> Optional, stash area for topics that need further development e.g. TBD +name: Request for Comments (RFC) +description: Feature design and detailed proposals +title: "RFC: TITLE" +labels: ["RFC", "triage"] +body: + - type: markdown + attributes: + value: | + Thank you for submitting a RFC. Please add as many details as possible to help further enrich this design. + - type: input + id: relation + attributes: + label: Is this related to an existing feature request or issue? + description: Please share a link, if applicable + - type: dropdown + id: area + attributes: + label: Which AWS Lambda Powertools utility does this relate to? + options: + - Tracing + - Logging + - Metrics + - Other + validations: + required: true + - type: textarea + id: summary + attributes: + label: Summary + description: Please provide an overview in one or two paragraphs + validations: + required: true + - type: textarea + id: problem + attributes: + label: Use case + description: Please share the use case and motivation behind this proposal + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposal + description: Please explain the design in detail, so anyone familiar with the project could implement it + placeholder: What the user experience looks like before and after this design? + validations: + required: true + - type: textarea + id: scope + attributes: + label: Out of scope + description: Please explain what should be considered out of scope in your proposal + validations: + required: true + - type: textarea + id: challenges + attributes: + label: Potential challenges + description: Nothing is perfect. Please share what common challenges, edge cases, unresolved areas, and suggestions on how to mitigate them + validations: + required: true + - type: textarea + id: integrations + attributes: + label: Dependencies and Integrations + description: If applicable, please share whether this feature has additional dependencies, and how it might integrate with other utilities available + validations: + required: false + - type: textarea + id: alternatives + attributes: + label: Alternative solutions + description: Please describe what alternative solutions to this use case, if any + render: markdown + validations: + required: false + - type: checkboxes + id: acknowledgment + attributes: + label: Acknowledgment + options: + - label: This feature request meets [Lambda Powertools Tenets](https://awslabs.github.io/aws-lambda-powertools-dotnet/tenets/) + required: true + - label: Should this be considered in other Lambda Powertools languages? i.e. [Python](https://github.com/awslabs/aws-lambda-powertools-python), [Java](https://github.com/awslabs/aws-lambda-powertools-java/), [TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript/) + required: false + - type: markdown + attributes: + value: | + --- + + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. + + Metadata information for admin purposes, please leave them empty. + + * RFC PR: + * Approved by: '' + * Reviewed by: '' \ No newline at end of file From 12627cdaede36280eac0c898742ac32dae908f66 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 19:04:22 +0800 Subject: [PATCH 13/20] chore: update pr template --- .github/PULL_REQUEST_TEMPLATE.md | 37 ++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 003e92265..ca5cb9b26 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,25 +1,40 @@ -**Issue #, if available:** +**Issue number:** -## Description of changes: +## Summary - +### Changes -**Checklist** +> Please provide a summary of what's being changed - +### User experience -* [ ] [Meet tenets criteria](https://awslabs.github.io/aws-lambda-powertools-dotnet/#tenets) -* [ ] Update tests -* [ ] Update docs +> Please share what the user experience looks like before and after this change + +## Checklist + +If your change doesn't seem to apply, please leave them unchecked. + +* [ ] [Meet tenets criteria](https://awslabs.github.io/aws-lambda-powertools-python/#tenets) +* [ ] I have performed a self-review of my this change +* [ ] Changes are tested +* [ ] Changes are documented * [ ] PR title follows [conventional commit semantics](https://github.com/awslabs/aws-lambda-powertools-dotnet/blob/develop/.github/semantic.yml) -## Breaking change checklist - +
+Is this a breaking change? + +**RFC issue number**: -**RFC issue #**: +Checklist: * [ ] Migration process documented * [ ] Implement warnings (if it can live side by side) +
+ +## Acknowledgment + By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. + +**Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file From 83a0989e878ed71278da92d49492ab0294f7d68c Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 19:53:40 +0800 Subject: [PATCH 14/20] fix: updating issue templates with correct extention --- .github/ISSUE_TEMPLATE/{bug_report.md => bug_report.yml} | 4 ++-- ...ation-improvements.md => documentation-improvements.yml} | 2 +- .../{feature_request.md => feature_request.yml} | 6 +++--- .github/ISSUE_TEMPLATE/{rfc.md => rfc.yml} | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename .github/ISSUE_TEMPLATE/{bug_report.md => bug_report.yml} (97%) rename .github/ISSUE_TEMPLATE/{documentation-improvements.md => documentation-improvements.yml} (99%) rename .github/ISSUE_TEMPLATE/{feature_request.md => feature_request.yml} (83%) rename .github/ISSUE_TEMPLATE/{rfc.md => rfc.yml} (100%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.yml similarity index 97% rename from .github/ISSUE_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug_report.yml index ce050b9fa..6d441bf0c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -8,7 +8,7 @@ body: value: | Thank you for submitting a bug report. Please add as much information as possible to help us reproduce, and remove any potential sensitive data. - Please become familiar with [our definition of bug](https://github.com/awslabs/aws-lambda-powertools-dotnet/blob/develop/MAINTAINERS.md#is-that-a-bug). + Please become familiar with [our definition of bug](https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/MAINTAINERS.md#is-that-a-bug). - type: textarea id: expected_behaviour attributes: @@ -88,4 +88,4 @@ body: value: | --- - **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. diff --git a/.github/ISSUE_TEMPLATE/documentation-improvements.md b/.github/ISSUE_TEMPLATE/documentation-improvements.yml similarity index 99% rename from .github/ISSUE_TEMPLATE/documentation-improvements.md rename to .github/ISSUE_TEMPLATE/documentation-improvements.yml index ff6fae27d..d48fb4fd3 100644 --- a/.github/ISSUE_TEMPLATE/documentation-improvements.md +++ b/.github/ISSUE_TEMPLATE/documentation-improvements.yml @@ -48,4 +48,4 @@ body: value: | --- - **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.yml similarity index 83% rename from .github/ISSUE_TEMPLATE/feature_request.md rename to .github/ISSUE_TEMPLATE/feature_request.yml index 80a3cf946..e7fbd3906 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -36,13 +36,13 @@ body: attributes: label: Acknowledgment options: - - label: This feature request meets [Lambda Powertools Tenets](https://awslabs.github.io/aws-lambda-powertools-dotnet/tenets/) + - label: This feature request meets [Lambda Powertools Tenets](https://awslabs.github.io/aws-lambda-powertools-python/latest/#tenets) required: true - - label: Should this be considered in other Lambda Powertools languages? i.e. [Python](https://github.com/awslabs/aws-lambda-powertools-python), [Java](https://github.com/awslabs/aws-lambda-powertools-java/), [TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript/) + - label: Should this be considered in other Lambda Powertools languages? i.e. [Java](https://github.com/awslabs/aws-lambda-powertools-java/), [TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript/) required: false - type: markdown attributes: value: | --- - **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. \ No newline at end of file + **Disclaimer**: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful. diff --git a/.github/ISSUE_TEMPLATE/rfc.md b/.github/ISSUE_TEMPLATE/rfc.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/rfc.md rename to .github/ISSUE_TEMPLATE/rfc.yml From 0f50e1610484ee13277f3c263a0c1ef564bf78b0 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 21:13:24 +0800 Subject: [PATCH 15/20] Update .github/boring-cyborg.yml Co-authored-by: Heitor Lessa --- .github/boring-cyborg.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index af1e128af..2461fd152 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -12,6 +12,12 @@ labelPRBasedOnFilePath: area/metrics: - libraries/src/AWS.Lambda.Powertools.Metrics/* - libraries/src/AWS.Lambda.Powertools.Metrics/**/* + area/tracer: + - libraries/src/AWS.Lambda.Powertools.Tracing/* + - libraries/src/AWS.Lambda.Powertools.Tracing/**/* + area/metrics: + - libraries/src/AWS.Lambda.Powertools.Metrics/* + - libraries/src/AWS.Lambda.Powertools.Metrics/**/* documentation: - docs/* From de0697c02500494ad06efb3e62a9288ef6c98b69 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Mon, 18 Jul 2022 21:13:55 +0800 Subject: [PATCH 16/20] Update .github/auto_assign.yml Co-authored-by: Heitor Lessa --- .github/auto_assign.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml index b416fad7a..0228ecc8d 100644 --- a/.github/auto_assign.yml +++ b/.github/auto_assign.yml @@ -13,10 +13,6 @@ reviewers: # Set 0 to add all the reviewers (default: 0) numberOfReviewers: 1 -# A list of assignees, overrides reviewers if set -# assignees: -# - sliedig -# - amirkaws # A number of assignees to add to the pull request # Set to 0 to add all of the assignees. From a853982cad0a08b932d3cc83a66fa9130919596b Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 18 Jul 2022 17:00:33 +0200 Subject: [PATCH 17/20] chore(ci): add reusable export pr workflow dependency Signed-off-by: heitorlessa --- .../workflows/reusable_export_pr_details.yml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/reusable_export_pr_details.yml diff --git a/.github/workflows/reusable_export_pr_details.yml b/.github/workflows/reusable_export_pr_details.yml new file mode 100644 index 000000000..dcbb959a4 --- /dev/null +++ b/.github/workflows/reusable_export_pr_details.yml @@ -0,0 +1,81 @@ +name: Export previously recorded PR + +on: + workflow_call: + inputs: + record_pr_workflow_id: + required: true + type: number + secrets: + token: + required: true + # Map the workflow outputs to job outputs + outputs: + prNumber: + description: "PR Number" + value: ${{ jobs.export_pr_details.outputs.prNumber }} + prTitle: + description: "PR Title" + value: ${{ jobs.export_pr_details.outputs.prTitle }} + prBody: + description: "PR Body as string" + value: ${{ jobs.export_pr_details.outputs.prBody }} + prAuthor: + description: "PR author username" + value: ${{ jobs.export_pr_details.outputs.prAuthor }} + prAction: + description: "PR event action" + value: ${{ jobs.export_pr_details.outputs.prAction }} + prIsMerged: + description: "Whether PR is merged" + value: ${{ jobs.export_pr_details.outputs.prIsMerged }} + +jobs: + export_pr_details: + runs-on: ubuntu-latest + env: + FILENAME: pr.txt + # Map the job outputs to step outputs + outputs: + prNumber: ${{ steps.prNumber.outputs.prNumber }} + prTitle: ${{ steps.prTitle.outputs.prTitle }} + prBody: ${{ steps.prBody.outputs.prBody }} + prAuthor: ${{ steps.prAuthor.outputs.prAuthor }} + prAction: ${{ steps.prAction.outputs.prAction }} + prIsMerged: ${{ steps.prIsMerged.outputs.prIsMerged }} + steps: + - name: Checkout repository # in case caller workflow doesn't checkout thus failing with file not found + uses: actions/checkout@v3 + - name: "Download previously saved PR" + uses: actions/github-script@v6 + env: + WORKFLOW_ID: ${{ inputs.record_pr_workflow_id }} + # For security, we only download artifacts tied to the successful PR recording workflow + with: + github-token: ${{ secrets.token }} + script: | + const script = require('.github/scripts/download_pr_artifact.js') + await script({github, context, core}) + # NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead + - name: "Unzip PR artifact" + run: unzip pr.zip + # NOTE: We need separate steps for each mapped output and respective IDs + # otherwise the parent caller won't see them regardless on how outputs are set. + - name: "Export Pull Request Number" + id: prNumber + run: echo ::set-output name=prNumber::$(jq -c '.number' ${FILENAME}) + - name: "Export Pull Request Title" + id: prTitle + run: echo ::set-output name=prTitle::$(jq -c '.pull_request.title' ${FILENAME}) + - name: "Export Pull Request Body" + id: prBody + run: echo ::set-output name=prBody::$(jq -c '.pull_request.body' ${FILENAME}) + - name: "Export Pull Request Author" + id: prAuthor + run: echo ::set-output name=prAuthor::$(jq -c '.pull_request.user.login' ${FILENAME}) + - name: "Export Pull Request Action" + id: prAction + run: echo ::set-output name=prAction::$(jq -c '.action' ${FILENAME}) + - name: "Export Pull Request Merged status" + id: prIsMerged + run: echo ::set-output name=prIsMerged::$(jq -c '.pull_request.merged' ${FILENAME}) From 6ec148601e096f342e7d08264ceee6dacd7e93cf Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 18 Jul 2022 17:05:21 +0200 Subject: [PATCH 18/20] chore(ci): add missing scripts Signed-off-by: heitorlessa --- .github/scripts/download_pr_artifact.js | 26 ++++++++++++++++++++++ .github/scripts/label_pr_based_on_title.js | 20 ++++++++--------- .github/scripts/save_pr_details.js | 4 ++-- 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 .github/scripts/download_pr_artifact.js diff --git a/.github/scripts/download_pr_artifact.js b/.github/scripts/download_pr_artifact.js new file mode 100644 index 000000000..274467c1f --- /dev/null +++ b/.github/scripts/download_pr_artifact.js @@ -0,0 +1,26 @@ +module.exports = async ({github, context, core}) => { + const fs = require('fs'); + + const workflowRunId = process.env.WORKFLOW_ID; + core.info(`Listing artifacts for workflow run ${workflowRunId}`); + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: workflowRunId, + }); + + const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; + + core.info(`Downloading artifacts for workflow run ${workflowRunId}`); + const artifact = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + + core.info("Saving artifact found", artifact); + + fs.writeFileSync('pr.zip', Buffer.from(artifact.data)); +} diff --git a/.github/scripts/label_pr_based_on_title.js b/.github/scripts/label_pr_based_on_title.js index 5ad398420..4ae3c1ff3 100644 --- a/.github/scripts/label_pr_based_on_title.js +++ b/.github/scripts/label_pr_based_on_title.js @@ -1,12 +1,12 @@ const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") module.exports = async ({github, context, core}) => { - const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ - const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ - const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ - const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ - const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ - const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ + const FEAT_REGEX = /feat(\((.+)\))?(:.+)/ + const BUG_REGEX = /(fix|bug)(\((.+)\))?(:.+)/ + const DOCS_REGEX = /(docs|doc)(\((.+)\))?(:.+)/ + const CHORE_REGEX = /(chore)(\((.+)\))?(:.+)/ + const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(:.+)/ + const REFACTOR_REGEX = /(refactor)(\((.+)\))?(:.+)/ const labels = { "feature": FEAT_REGEX, @@ -22,8 +22,8 @@ module.exports = async ({github, context, core}) => { try { for (const label in labels) { const matcher = new RegExp(labels[label]) - const isMatch = matcher.exec(PR_TITLE) - if (isMatch != null) { + const matches = matcher.exec(PR_TITLE) + if (matches != null) { core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) await github.rest.issues.addLabels({ @@ -54,7 +54,7 @@ module.exports = async ({github, context, core}) => { } } finally { if (miss == Object.keys(labels).length) { - return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) + core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) } } -} \ No newline at end of file +} diff --git a/.github/scripts/save_pr_details.js b/.github/scripts/save_pr_details.js index bc3de6734..83bd3bf70 100644 --- a/.github/scripts/save_pr_details.js +++ b/.github/scripts/save_pr_details.js @@ -1,4 +1,4 @@ -module.exports = async ({github, context, core}) => { +module.exports = async ({context, core}) => { const fs = require('fs'); const filename = "pr.txt"; @@ -10,4 +10,4 @@ module.exports = async ({github, context, core}) => { core.setFailed("Failed to save PR details"); console.error(err); } -} \ No newline at end of file +} From 85bc25b72c7bcbdde23905030f094b484c234071 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 18 Jul 2022 17:06:57 +0200 Subject: [PATCH 19/20] chore(ci): add on_merge_pr workflow to notify releases Signed-off-by: heitorlessa --- .github/scripts/constants.js | 2 +- .github/scripts/label_related_issue.js | 53 ++++++++++++++++++++++++++ .github/workflows/on_merged_pr.yml | 34 +++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/label_related_issue.js create mode 100644 .github/workflows/on_merged_pr.yml diff --git a/.github/scripts/constants.js b/.github/scripts/constants.js index 7c0556ed9..db5cd616d 100644 --- a/.github/scripts/constants.js +++ b/.github/scripts/constants.js @@ -25,7 +25,7 @@ module.exports = Object.freeze({ "LABEL_BLOCK_REASON": "need-issue", // /** @type {string} */ - // "LABEL_PENDING_RELEASE": "pending-release", + "LABEL_PENDING_RELEASE": "pending-release", /** @type {string} */ "HANDLE_MAINTAINERS_TEAM": "@awslabs/aws-lambda-powertools-net", diff --git a/.github/scripts/label_related_issue.js b/.github/scripts/label_related_issue.js new file mode 100644 index 000000000..e01868d36 --- /dev/null +++ b/.github/scripts/label_related_issue.js @@ -0,0 +1,53 @@ +const { + PR_AUTHOR, + PR_BODY, + PR_NUMBER, + IGNORE_AUTHORS, + LABEL_PENDING_RELEASE, + HANDLE_MAINTAINERS_TEAM, + PR_IS_MERGED, +} = require("./constants") + +module.exports = async ({github, context, core}) => { + if (IGNORE_AUTHORS.includes(PR_AUTHOR)) { + return core.notice("Author in IGNORE_AUTHORS list; skipping...") + } + + if (PR_IS_MERGED == "false") { + return core.notice("Only merged PRs to avoid spam; skipping") + } + + const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?\d+)/; + + const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY); + + try { + if (!isMatch) { + core.setFailed(`Unable to find related issue for PR number ${PR_NUMBER}.\n\n Body details: ${PR_BODY}`); + return await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + body: `${HANDLE_MAINTAINERS_TEAM} No related issues found. Please ensure '${LABEL_PENDING_RELEASE}' label is applied before releasing.`, + issue_number: PR_NUMBER, + }); + } + } catch (error) { + core.setFailed(`Unable to create comment on PR number ${PR_NUMBER}.\n\n Error details: ${error}`); + throw new Error(error); + } + + const { groups: {issue} } = isMatch + + try { + core.info(`Auto-labeling related issue ${issue} for release`) + await github.rest.issues.addLabels({ + issue_number: issue, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [LABEL_PENDING_RELEASE] + }) + } catch (error) { + core.setFailed(`Is this issue number (${issue}) valid? Perhaps a discussion?`); + throw new Error(error); + } +} diff --git a/.github/workflows/on_merged_pr.yml b/.github/workflows/on_merged_pr.yml new file mode 100644 index 000000000..3f1bcb572 --- /dev/null +++ b/.github/workflows/on_merged_pr.yml @@ -0,0 +1,34 @@ +name: On PR merge + +on: + workflow_run: + workflows: ["Record PR details"] + types: + - completed + +jobs: + get_pr_details: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + uses: ./.github/workflows/reusable_export_pr_details.yml + with: + record_pr_workflow_id: ${{ github.event.workflow_run.id }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + release_label_on_merge: + needs: get_pr_details + runs-on: ubuntu-latest + if: needs.get_pr_details.outputs.prIsMerged == 'true' + steps: + - uses: actions/checkout@v3 + - name: "Label PR related issue for release" + uses: actions/github-script@v6 + env: + PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }} + PR_BODY: ${{ needs.get_pr_details.outputs.prBody }} + PR_IS_MERGED: ${{ needs.get_pr_details.outputs.prIsMerged }} + PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const script = require('.github/scripts/label_related_issue.js') + await script({github, context, core}) From b39d8fb84f21784e44312abea6965b1be68cc916 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 18 Jul 2022 17:07:34 +0200 Subject: [PATCH 20/20] chore(ci): add workflow to detect missing related issue Signed-off-by: heitorlessa --- .../scripts/label_missing_related_issue.js | 40 +++++++++++++++++++ .github/workflows/on_opened_pr.yml | 33 +++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/scripts/label_missing_related_issue.js create mode 100644 .github/workflows/on_opened_pr.yml diff --git a/.github/scripts/label_missing_related_issue.js b/.github/scripts/label_missing_related_issue.js new file mode 100644 index 000000000..705e414c4 --- /dev/null +++ b/.github/scripts/label_missing_related_issue.js @@ -0,0 +1,40 @@ +const { + PR_ACTION, + PR_AUTHOR, + PR_BODY, + PR_NUMBER, + IGNORE_AUTHORS, + LABEL_BLOCK, + LABEL_BLOCK_REASON +} = require("./constants") + +module.exports = async ({github, context, core}) => { + if (IGNORE_AUTHORS.includes(PR_AUTHOR)) { + return core.notice("Author in IGNORE_AUTHORS list; skipping...") + } + + if (PR_ACTION != "opened") { + return core.notice("Only newly open PRs are labelled to avoid spam; skipping") + } + + const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?\d+)/; + const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY); + if (isMatch == null) { + core.info(`No related issue found, maybe the author didn't use the template but there is one.`) + + let msg = "No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure."; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + body: msg, + issue_number: PR_NUMBER, + }); + + return await github.rest.issues.addLabels({ + issue_number: PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [LABEL_BLOCK, LABEL_BLOCK_REASON] + }) + } +} diff --git a/.github/workflows/on_opened_pr.yml b/.github/workflows/on_opened_pr.yml new file mode 100644 index 000000000..3d5aab45b --- /dev/null +++ b/.github/workflows/on_opened_pr.yml @@ -0,0 +1,33 @@ +name: On new PR + +on: + workflow_run: + workflows: ["Record PR details"] + types: + - completed + +jobs: + get_pr_details: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: ./.github/workflows/reusable_export_pr_details.yml + with: + record_pr_workflow_id: ${{ github.event.workflow_run.id }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + check_related_issue: + needs: get_pr_details + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: "Ensure related issue is present" + uses: actions/github-script@v6 + env: + PR_BODY: ${{ needs.get_pr_details.outputs.prBody }} + PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }} + PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }} + PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const script = require('.github/scripts/label_missing_related_issue.js') + await script({github, context, core})