From 1ee77babfd7fc5de80c7a85762d0965d5d688aa0 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 17 Nov 2020 20:21:28 +0530 Subject: [PATCH] :arrow_up: Update koj-co/github-actions-starter --- .github/workflows/build.yml | 13 ++++- .github/workflows/cla.yml | 26 --------- .github/workflows/codeql.yml | 35 ++++++++++++ .github/workflows/dependabot.yml | 9 ++- .github/workflows/feature-pr.yml | 20 ------- .github/workflows/hotfix-pr.yml | 19 ------- .github/workflows/node.yml | 13 ++++- .github/workflows/pull-request.yml | 73 +++++++++++++++++++++++++ .github/workflows/release-scheduler.yml | 13 +++++ .github/workflows/release.yml | 13 ++++- .github/workflows/stale.yml | 19 +++++++ .github/workflows/test.yml | 2 +- .npmignore | 3 + jest.config.js | 4 ++ tsconfig.json | 8 ++- 15 files changed, 193 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/cla.yml create mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/feature-pr.yml delete mode 100644 .github/workflows/hotfix-pr.yml create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/release-scheduler.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .npmignore create mode 100644 jest.config.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a3f3b2..f36334e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.3.4 with: ref: ${{ github.head_ref }} token: ${{ secrets.GH_PAT }} @@ -18,6 +18,17 @@ jobs: uses: actions/setup-node@v2.1.2 with: node-version: 14 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: Install dependencies run: npm ci - name: Build TypeScript diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml deleted file mode 100644 index 387aae2..0000000 --- a/.github/workflows/cla.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: CLA Assistant -on: - issue_comment: - types: [created] - pull_request_target: - types: [opened, closed, synchronize] -jobs: - claAssistant: - runs-on: ubuntu-latest - steps: - - name: Check signed CLA - if: (github.event.comment.body == 'recheckcla' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - uses: cla-assistant/github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PAT }} - with: - path-to-signatures: cla-signatures.json - path-to-cla-document: https://github.com/koj-co/.github/blob/master/CLA.md - allowlist: dependabot-preview[bot], dependabot[bot], greenkeeper[bot], *bot, bot* - remote-organization-name: koj-co - remote-repository-name: .github - signed-commit-message: ":wrench: @$contributorName has signed the CLA in #$pullRequestNo" - create-file-commit-message: ":wrench: Creating a file for storing CLA signatures" - custom-allsigned-prcomment: "✍️ All contributors have signed the CLA" - custom-notsigned-prcomment: "Thanks for your submission! We ask that $you sign our [Contributor License Agreement]($pathToCLADocument) before we can accept your contribution. You can sign the CLA by adding a comment below using this text:" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..fd5d434 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,35 @@ +name: CodeQL CI +on: + schedule: + - cron: "0 0 * * 1" +jobs: + release: + name: Build and analyze + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + - name: Setup Node.js + uses: actions/setup-node@v2.1.2 + with: + node-version: 14 + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: javascript + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install dependencies + run: npm ci + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 0af1df7..ecb1772 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -1,7 +1,7 @@ name: Dependabot PR CI on: schedule: - - cron: "0 * * * *" + - cron: "0 */6 * * *" workflow_dispatch: jobs: label-approve: @@ -10,7 +10,6 @@ jobs: steps: - uses: koj-co/dependabot-pr-action@master with: - token: ${{ secrets.GITHUB_TOKEN }} - approve-minor: true - approve-patch: true - auto-label: true + token: ${{ secrets.GH_PAT }} + merge-minor: true + merge-patch: true diff --git a/.github/workflows/feature-pr.yml b/.github/workflows/feature-pr.yml deleted file mode 100644 index ced879d..0000000 --- a/.github/workflows/feature-pr.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Feature Branch Pull Request -on: - push: - branches-ignore: - - master - - production -jobs: - auto-pull-request: - name: PullRequestAction - runs-on: ubuntu-latest - steps: - - name: pull-request-action - uses: vsoch/pull-request-action@1.0.11 - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - BRANCH_PREFIX: "feature-" - PULL_REQUEST_BRANCH: "master" - PULL_REQUEST_BODY: "🚀 Opening a pull request for this branch" - PULL_REQUEST_REVIEWERS: "AnandChowdhary" - PULL_REQUEST_DRAFT: true diff --git a/.github/workflows/hotfix-pr.yml b/.github/workflows/hotfix-pr.yml deleted file mode 100644 index d16fd9d..0000000 --- a/.github/workflows/hotfix-pr.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Hotfix Branch Pull Request -on: - push: - branches-ignore: - - master - - production -jobs: - auto-pull-request: - name: PullRequestAction - runs-on: ubuntu-latest - steps: - - name: pull-request-action - uses: vsoch/pull-request-action@1.0.11 - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - BRANCH_PREFIX: "hotfix-" - PULL_REQUEST_BRANCH: "production" - PULL_REQUEST_BODY: "🚀 Opening a pull request for this branch" - PULL_REQUEST_REVIEWERS: "AnandChowdhary" diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 8159fec..1227b49 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -10,11 +10,22 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2.3.4 - name: Setup Node.js uses: actions/setup-node@v2.1.2 with: node-version: 12 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: Install dependencies run: npm ci - name: Build TypeScript diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..6bf3dd6 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,73 @@ +name: PR Generator CI +on: + push: + branches-ignore: + - master + - production +jobs: + auto-pull-request: + name: PullRequestAction + runs-on: ubuntu-latest + steps: + - name: Generate branch name + uses: actions/github-script@v3 + id: set-branch-name + with: + script: | + const capitalize = (name) => name.charAt(0).toUpperCase() + name.slice(1); + const emoji = context.payload.ref.startsWith("refs/heads/feature") + ? "✨ " + : context.payload.ref.startsWith("refs/heads/hotfix") + ? "🚑 " + : context.payload.ref.startsWith("refs/heads/bug") + ? "🐛 " + : ""; + return `${emoji}${capitalize( + context.payload.ref + .replace("refs/heads/", "") + .replace(/-/g, " ") + .replace("feature ", "") + .replace("bug ", "") + .replace("hotfix ", "") + )}`; + result-encoding: string + - name: Set branch name + run: echo "PULL_REQUEST_TITLE=${{steps.set-branch-name.outputs.result}}" >> $GITHUB_ENV + - name: Generate PR body + uses: actions/github-script@v3 + id: set-pr-body + with: + script: | + return `I'm opening this pull request for this branch, pushed by @${ + context.payload.head_commit.author.username + } with ${context.payload.commits.length} commit${ + context.payload.commits.length === 1 ? "" : "s" + }.`; + result-encoding: string + - name: Set PR body + run: echo "PULL_REQUEST_BODY=${{steps.set-pr-body.outputs.result}}" >> $GITHUB_ENV + - name: Generate PR draft + uses: actions/github-script@v3 + id: set-pr-draft + with: + script: | + return !context.payload.ref.startsWith("refs/heads/hotfix"); + - name: Set PR draft + run: echo "PULL_REQUEST_DRAFT=${{steps.set-pr-draft.outputs.result}}" >> $GITHUB_ENV + - name: Determine whether to merge + uses: actions/github-script@v3 + id: should-pr + with: + github-token: ${{ secrets.GH_PAT }} + script: | + return + context.payload.ref.startsWith("refs/heads/feature") || + context.payload.ref.startsWith("refs/heads/hotfix") || + context.payload.ref.startsWith("refs/heads/bug"); + - name: pull-request-action + uses: vsoch/pull-request-action@1.0.11 + if: always() && steps.should-pr.outputs.result + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + PULL_REQUEST_BRANCH: "master" + PULL_REQUEST_REVIEWERS: "AnandChowdhary" diff --git a/.github/workflows/release-scheduler.yml b/.github/workflows/release-scheduler.yml new file mode 100644 index 0000000..466e021 --- /dev/null +++ b/.github/workflows/release-scheduler.yml @@ -0,0 +1,13 @@ +name: Release Scheduler CI +on: + schedule: + - cron: "0 0 * * 1" + workflow_dispatch: +jobs: + releaseScheduler: + runs-on: ubuntu-latest + steps: + - name: Run release-scheduler + uses: koj-co/release-scheduler@master + env: + GH_PAT: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d8d18d..7d1e885 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: if: "contains(github.event.head_commit.message, 'Deploy new version')" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.3.4 with: ref: ${{ github.head_ref }} token: ${{ secrets.GH_PAT }} @@ -18,6 +18,17 @@ jobs: uses: actions/setup-node@v2.1.2 with: node-version: 14 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: Install dependencies run: npm ci - name: Release diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..dcd6e8b --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,19 @@ +name: "Stale Issues CI" +on: + schedule: + - cron: "0 0 * * *" +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GH_PAT }} + stale-issue-message: "⚠️ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week." + stale-pr-message: "⚠️ This PR has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week." + days-before-stale: 60 + days-before-close: 7 + stale-issue-label: "wontfix" + exempt-issue-labels: "wip" + stale-pr-label: "wontfix" + exempt-pr-labels: "wip" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49d1bc2..5a7251e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: if: "contains(github.event.head_commit.message, 'Deploy new version')" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.3.4 - uses: ./ with: milliseconds: 1000 diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..e0d3dd5 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +.vscode +.licenses +.github diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..a93551f --- /dev/null +++ b/jest.config.js @@ -0,0 +1,4 @@ +module.exports = { + preset: "ts-jest", + testEnvironment: "node", +}; diff --git a/tsconfig.json b/tsconfig.json index bc148a9..028d02c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,14 +5,16 @@ "module": "commonjs", "lib": ["dom", "esnext"], "strict": true, - "sourceMap": false, - "declaration": false, + "sourceMap": true, + "declaration": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "declarationDir": "./dist", "outDir": "./dist", "typeRoots": ["node_modules/@types", "@types"] }, - "include": ["src"], + "include": ["src", "tooling"], "exclude": ["node_modules"] }