A local-first personal finance app
Remove “needs votes” label from feature requests that have been implemented (#1001)
Jed Foxc9576d98e4f4
diff --git a/.github/actions/handle-feature-requests.js b/.github/actions/handle-feature-requests.jsnew file mode 100644index 0000000000..4bcce0e129--- /dev/null+++ b/.github/actions/handle-feature-requests.js@@ -0,0 +1,181 @@+#!/usr/bin/env node++// overview:+// 1. Fetch the issues that are linked to the PR+// 2. Filter out the issues that are not feature requests+// 3. For each feature request:+// 1. Remove the 'help wanted' & 'needs votes' labels+// 3. Find the automated comment, hide the comment as 'outdated'+// 5. Post a new comment saying that the feature request has been implemented, and will be released in the next version. Link to the PR.++async function makeAPIRequest(query, variables) {+ const res = await fetch('https://api.github.com/graphql', {+ method: 'POST',+ headers: {+ Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,+ 'Content-Type': 'application/json',+ Accept: 'application/json',+ },+ body: JSON.stringify({ query, variables }),+ });+ return res.json();+}++function group(name, body) {+ console.log(`::group::${name}`);+ const result = body();+ if (result instanceof Promise) {+ return result.finally(() => console.log(`::endgroup::`));+ }+ console.log(`::endgroup::`);+ return result;+}++async function main() {+ const featureRequests = await group('Pull Request API Response', async () => {+ const res = await makeAPIRequest(+ /* GraphQL */ `+ query FetchLinkedIssues($pr: Int!) {+ repository(owner: "actualbudget", name: "actual") {+ pullRequest(number: $pr) {+ closingIssuesReferences(first: 10) {+ nodes {+ id+ number+ labels(first: 10) {+ nodes {+ id+ name+ }+ }+ }+ }+ }+ }+ }+ `,+ { pr: parseInt(process.env.PR_NUMBER) },+ );++ console.log(JSON.stringify(res, null, 2));++ return res.data.repository.pullRequest.closingIssuesReferences.nodes.filter(+ issue => issue.labels.nodes.some(label => label.name === 'feature'),+ );+ });++ if (featureRequests.length === 0) {+ console.log('No linked feature requests found');+ return;+ }++ for (const { id, number, labels } of featureRequests) {+ await group(`Issue #${number}: Remove labels`, async () => {+ const toRemove = labels.nodes+ .filter(+ label => label.name === 'help wanted' || label.name === 'needs votes',+ )+ .map(label => label.id);+ const res = await makeAPIRequest(+ /* GraphQL */ `+ mutation RemoveLabels($issue: ID!, $labels: [ID!]!) {+ removeLabelsFromLabelable(+ input: {+ clientMutationId: "1"+ labelIds: $labels+ labelableId: $issue+ }+ ) {+ clientMutationId+ }+ }+ `,+ {+ issue: id,+ labels: toRemove,+ },+ );+ console.log(JSON.stringify(res, null, 2));+ });++ await group(`Issue #${number}: Collapse automatic comment`, async () => {+ const commentRes = await makeAPIRequest(+ /* GraphQL */ `+ query FetchComments($issue: Int!) {+ repository(owner: "actualbudget", name: "actual") {+ issue(number: $issue) {+ comments(first: 100) {+ nodes {+ id+ body+ author {+ login+ }+ }+ }+ }+ }+ }+ `,+ { issue: number },+ );+ console.log(JSON.stringify(commentRes, null, 2));++ const comments = commentRes.data.repository.issue.comments.nodes.filter(+ comment => comment.author.login === 'github-actions',+ );+ const commentToCollapse =+ comments.find(comment =>+ comment.body.includes('<!-- feature-auto-close-comment -->'),+ ) ||+ comments.find(comment =>+ comment.body.includes(+ ':sparkles: Thanks for sharing your idea! :sparkles:',+ ),+ );++ if (!commentToCollapse) {+ console.log('No comment to collapse found');+ process.exit(1);+ }++ const res = await makeAPIRequest(+ /* GraphQL */ `+ mutation CollapseComment($comment: ID!) {+ minimizeComment(+ input: { classifier: OUTDATED, subjectId: $comment }+ ) {+ clientMutationId+ }+ }+ `,+ { comment: commentToCollapse.id },+ );+ console.log(JSON.stringify(res, null, 2));+ });++ await group(`Issue #${number}: Post comment`, async () => {+ const res = await makeAPIRequest(+ /* GraphQL */ `+ mutation PostComment($issue: ID!, $body: String!) {+ addComment(+ input: { subjectId: $issue, body: $body, clientMutationId: "1" }+ ) {+ clientMutationId+ }+ }+ `,+ {+ issue: id,+ body: `:tada: This feature has been implemented in #${process.env.PR_NUMBER} and will be released in the next version. Thanks for sharing your idea! :tada:\n\n<!-- feature-implemented-comment -->`,+ },+ );+ console.log(JSON.stringify(res, null, 2));+ });+ }+}++main().catch(err => {+ console.error(err);+ process.exit(1);+});diff --git a/.github/workflows/check-release-notes.yml b/.github/workflows/check-release-notes.ymldeleted file mode 100644index 12b889dfd1..0000000000--- a/.github/workflows/check-release-notes.yml+++ /dev/null@@ -1,16 +0,0 @@-name: Check release notes--on:- pull_request:- branches:- - '*'- - '!release/*'--jobs:- check:- runs-on: ubuntu-latest- steps:- - name: Checkout- uses: actions/checkout@v3- - name: Check release notes- uses: actualbudget/actions/release-notes/check@maindiff --git a/.github/workflows/check.yml b/.github/workflows/check.ymlnew file mode 100644index 0000000000..20af0f52d5--- /dev/null+++ b/.github/workflows/check.yml@@ -0,0 +1,34 @@+name: Test++on:+ push:+ branches:+ - master+ pull_request:+ branches: '*'++jobs:+ lint:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v3+ - name: Set up environment+ uses: ./.github/actions/setup+ - name: Lint+ run: yarn lint+ typecheck:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v3+ - name: Set up environment+ uses: ./.github/actions/setup+ - name: Typecheck+ run: yarn typecheck+ test:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v3+ - name: Set up environment+ uses: ./.github/actions/setup+ - name: Test+ run: yarn testdiff --git a/.github/workflows/generate-release-notes.yml b/.github/workflows/generate-release-notes.ymldeleted file mode 100644index fcf3433302..0000000000--- a/.github/workflows/generate-release-notes.yml+++ /dev/null@@ -1,17 +0,0 @@-name: Generate Release Notes--on:- push:- branches:- - release/*--jobs:- generate:- runs-on: ubuntu-latest- steps:- - name: Checkout- uses: actions/checkout@v3- - name: Generate release notes- uses: actualbudget/actions/release-notes/generate@main- with:- github_token: ${{ secrets.GITHUB_TOKEN }}diff --git a/.github/workflows/opened-issues-triage.yml b/.github/workflows/issues-add-triage-label.ymlsimilarity index 83%rename from .github/workflows/opened-issues-triage.ymlrename to .github/workflows/issues-add-triage-label.ymlindex e373bc0f64..c82d1a5a7c 100644--- a/.github/workflows/opened-issues-triage.yml+++ b/.github/workflows/issues-add-triage-label.yml@@ -8,7 +8,7 @@ jobs:needs-triage:runs-on: ubuntu-lateststeps:- - uses: actions/checkout@v3- uses: actions-ecosystem/action-add-labels@v1+ if: github.event.issue.labels == nullwith:labels: needs triagediff --git a/.github/workflows/issues-close-feature-requests.yml b/.github/workflows/issues-close-feature-requests.ymlindex e08f535a99..18a0661ed5 100644--- a/.github/workflows/issues-close-feature-requests.yml+++ b/.github/workflows/issues-close-feature-requests.yml@@ -9,8 +9,6 @@ jobs:if: ${{ github.event.label.name == 'feature' }}runs-on: ubuntu-lateststeps:- - name: Checkout- uses: actions/checkout@v3- uses: actions-ecosystem/action-add-labels@v1with:labels: needs votes@@ -31,7 +29,9 @@ jobs:The enhancement backlog can be found here: https://github.com/actualbudget/actual/issues?q=label%3A%22needs+votes%22+sort%3Areactions-%2B1-desc+Don’t forget to upvote the top comment with 👍!++ <!-- feature-auto-close-comment -->- name: Close Issue- run: gh issue close "${{ github.event.issue.number }}"+ run: gh issue close "https://github.com/actualbudget/actual/issues/${{ github.event.issue.number }}"env:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}diff --git a/.github/workflows/issues-feature-implemented.yml b/.github/workflows/issues-feature-implemented.ymlnew file mode 100644index 0000000000..51ffaa8893--- /dev/null+++ b/.github/workflows/issues-feature-implemented.yml@@ -0,0 +1,20 @@+name: Handle completed feature requests++on:+ pull_request:+ types: [closed]++jobs:+ handle-feature-requests:+ if: github.event.pull_request.merged == true+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v3+ - uses: actions/setup-node@v2+ with:+ node-version: '19'+ - name: Handle feature requests+ run: node .github/actions/handle-feature-requests.js+ env:+ PR_NUMBER: ${{ github.event.pull_request.number }}+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}diff --git a/.github/workflows/issues-remove-help-wanted.yml b/.github/workflows/issues-remove-help-wanted.ymlnew file mode 100644index 0000000000..75d5f73e78--- /dev/null+++ b/.github/workflows/issues-remove-help-wanted.yml@@ -0,0 +1,14 @@+name: Remove 'help wanted' label from closed issues++on:+ issues:+ types: [closed]++jobs:+ remove-help-wanted:+ if: ${{ !contains(github.event.issue.labels.*.name, 'feature') && contains(github.event.issue.labels.*.name, 'help wanted') }}+ runs-on: ubuntu-latest+ steps:+ - uses: actions-ecosystem/action-remove-labels@v1+ with:+ labels: help wanteddiff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymldeleted file mode 100644index 6a1f7a79da..0000000000--- a/.github/workflows/lint.yml+++ /dev/null@@ -1,18 +0,0 @@-name: Linter--on:- push:- branches:- - master- pull_request:- branches: '*'--jobs:- lint:- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v3- - name: Set up environment- uses: ./.github/actions/setup- - name: Lint- run: yarn lintdiff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.ymlnew file mode 100644index 0000000000..20c752072f--- /dev/null+++ b/.github/workflows/release-notes.yml@@ -0,0 +1,18 @@+name: Release notes++on:+ pull_request:+ branches: '*'++jobs:+ release-notes:+ runs-on: ubuntu-latest+ steps:+ - name: Checkout+ uses: actions/checkout@v3+ - name: Check release notes+ if: startsWith(github.ref, 'refs/heads/release/') == false+ uses: actualbudget/actions/release-notes/check@main+ - name: Generate release notes+ if: startsWith(github.ref, 'refs/heads/release/') == true+ uses: actualbudget/actions/release-notes/generate@maindiff --git a/.github/workflows/stale.yml b/.github/workflows/stale.ymldeleted file mode 100644index 6db6893d90..0000000000--- a/.github/workflows/stale.yml+++ /dev/null@@ -1,20 +0,0 @@-name: Close inactive issues-on:- schedule:- - cron: "30 1 * * *"--jobs:- close-issues:- runs-on: ubuntu-latest- permissions:- issues: write- pull-requests: write- steps:- - uses: actions/stale@v7- with:- days-before-issue-stale: 90- days-before-issue-close: -1- stale-issue-label: "stale"- stale-issue-message: "🚧🚨 This issue is being marked as stale due to 90 days of inactivity. 🚧🚨"- only-labels: 'needs triage'- repo-token: ${{ secrets.GITHUB_TOKEN }}diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymldeleted file mode 100644index eec071eae4..0000000000--- a/.github/workflows/test.yml+++ /dev/null@@ -1,18 +0,0 @@-name: Test--on:- push:- branches:- - master- pull_request:- branches: '*'--jobs:- test:- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v3- - name: Set up environment- uses: ./.github/actions/setup- - name: Test- run: yarn testdiff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.ymldeleted file mode 100644index ae8aa18479..0000000000--- a/.github/workflows/typecheck.yml+++ /dev/null@@ -1,18 +0,0 @@-name: Typecheck--on:- push:- branches:- - master- pull_request:- branches: '*'--jobs:- typecheck:- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v3- - name: Set up environment- uses: ./.github/actions/setup- - name: Typecheck- run: yarn typecheckdiff --git a/upcoming-release-notes/1001.md b/upcoming-release-notes/1001.mdnew file mode 100644index 0000000000..d3a7bda0bd--- /dev/null+++ b/upcoming-release-notes/1001.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [j-f1]+---++Improve Actions setup, add more automation around issue management