Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split into Action, App, CLI, Core and Switch to TypeScript #1204

Draft
wants to merge 81 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
4de0255
wip
jetersen Aug 2, 2022
6513dff
fix up: template tests and types
jetersen Aug 2, 2022
97e2846
include tests in tsc
jetersen Aug 3, 2022
0303270
cleanup import
jetersen Aug 3, 2022
904240b
fix eslint extensions
jetersen Aug 3, 2022
729da8e
use zod over joi
jetersen Aug 4, 2022
c96521b
update git ignore
jetersen Aug 6, 2022
d24b192
add .run to gitinore
jetersen Aug 6, 2022
6443ce3
fix lint stage
jetersen Aug 6, 2022
f891e3d
move _extends to schema package
jetersen Aug 6, 2022
decb93a
add commits, pagination, releases
jetersen Aug 7, 2022
9553aea
fix types and keylookup
jetersen Aug 7, 2022
3d5ed07
no declaration files for action
jetersen Aug 7, 2022
bc6c66b
types
jetersen Aug 7, 2022
42eb2d7
fix devcontainer
jetersen Aug 7, 2022
12ea511
simplify template logic
jetersen Aug 7, 2022
b2a437a
update gitignore
jetersen Aug 9, 2022
f7503be
reuse jest config and tsconfig
jetersen Aug 9, 2022
0e076d6
types and test coverage of pagination
jetersen Aug 9, 2022
9adc4c1
add jest to eslint and fix lint issues in tests
jetersen Aug 10, 2022
6e3c56f
fix lint-staged.config
jetersen Aug 10, 2022
7cde87c
remove main.d.ts
jetersen Aug 10, 2022
fda80d1
update tests ci
jetersen Aug 20, 2022
5feda54
update tests ci
jetersen Aug 20, 2022
989a35e
add tsconfig.test.json
jetersen Aug 20, 2022
ecd6ff0
add editorconfig
jetersen Aug 21, 2022
757b80d
add linguist ignore
jetersen Aug 21, 2022
e0a1296
implement GitHub Action
jetersen Aug 21, 2022
f525012
build src/index.ts
jetersen Aug 21, 2022
86e32bd
build src/index.ts
jetersen Aug 21, 2022
a4e0c27
fix throttle implementation
jetersen Aug 21, 2022
ab0dbe3
fix action defaults
jetersen Aug 21, 2022
7572ba5
associated pull requests can be null
jetersen Aug 21, 2022
f6411f9
fix summary
jetersen Aug 21, 2022
ae86ff2
use code block for summary
jetersen Aug 21, 2022
e516e48
assume `v$RESOLVED_VERSION` as default for tag template
jetersen Aug 21, 2022
903bdef
assume `v` as default for prefix tag
jetersen Aug 21, 2022
54758a9
use github emoji markdown
jetersen Aug 21, 2022
a32dec8
GitHub actions does not use GitHub flavored markdown
jetersen Aug 21, 2022
7966225
fix commit filter
jetersen Aug 21, 2022
22ffc42
fix config and empty categories
jetersen Aug 21, 2022
5a44e2a
run config through schema and refine uncategorized category
jetersen Aug 21, 2022
234eef7
assume nameTemplate default
jetersen Aug 21, 2022
bac8b93
fix summary body
jetersen Aug 21, 2022
58a83d7
fix octokit log
jetersen Aug 22, 2022
87015ff
reorder dependency usage
jetersen Aug 22, 2022
a6bb74b
implement Release Drafter CLI
jetersen Aug 23, 2022
ab70f9a
default target commitish to defaultBranch for cli
jetersen Aug 23, 2022
be139a8
bump github action dep
jetersen Aug 26, 2022
acf3a56
typescript packaging is hard 😅
jetersen Aug 26, 2022
c9e68cf
bump version
jetersen Aug 26, 2022
a4e6ee5
typescript packaging is really hard together with testing esm 😅
jetersen Aug 26, 2022
1610834
Okay jester, please behave 😅
jetersen Aug 26, 2022
978cc71
fix tests action
jetersen Aug 26, 2022
606ca50
update diff check
jetersen Aug 26, 2022
8a448c0
remove autolabeler from core
jetersen Aug 26, 2022
2d11459
add cli bin file
jetersen Aug 26, 2022
3d4a713
put version in all package.json
jetersen Aug 26, 2022
83a9edf
add bumpp
jetersen Aug 27, 2022
fcf6a20
cleanup package.json
jetersen Aug 27, 2022
29940a1
check for prerelease
jetersen Aug 27, 2022
e022599
fix @jest/globals mapping in jest
jetersen Aug 27, 2022
07fae30
add @octokit/types to root
jetersen Aug 27, 2022
fea753d
fix duplicate author
jetersen Aug 27, 2022
dcd1b0c
build: publish v6.0.0-beta.1
jetersen Aug 27, 2022
eff61ed
skip git checks when publishing
jetersen Aug 27, 2022
9046d74
gitignore .envrc
jetersen Aug 27, 2022
06a4a0a
remove boomper
jetersen Aug 27, 2022
1dbdc73
Prepare moving to main
jetersen Aug 27, 2022
ee6d5b8
build dist
jetersen Aug 27, 2022
7eb8c64
use renovate
jetersen Aug 27, 2022
a01b62a
continue to use kebab-case
jetersen Aug 28, 2022
ce45cc4
add nock
jetersen Aug 28, 2022
a40973b
fix schema tests
jetersen Aug 28, 2022
75da31f
use kebab case in config
jetersen Aug 28, 2022
3b0f0b7
faster tests
jetersen Aug 28, 2022
8eaee78
increase test coverage
jetersen Aug 28, 2022
cf4e1f4
swc/jest reads ESM just fine
jetersen Aug 28, 2022
bf1f94d
Apply suggestions from code review
jetersen Aug 29, 2022
4c98a9a
fix swc/jest source maps
jetersen Sep 29, 2022
f318514
add ownerRepo test
jetersen Sep 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Expand Up @@ -14,3 +14,8 @@ FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
ARG PNPM_VERSION="7.8.0"
# Install more global node modules
RUN sudo -u node npm install -g pnpm@${PNPM_VERSION}

ENV HUSKY=0
36 changes: 18 additions & 18 deletions .devcontainer/devcontainer.json
@@ -1,27 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/javascript-node
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"args": { "VARIANT": "16" }
},
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"args": { "VARIANT": "16" }
},

// Set *default* container specific settings.json values on container create.
"settings": {},
// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": ["dbaeumer.vscode-eslint"],
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "yarn install",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pnpm install",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -7,3 +7,4 @@ coverage
*.pem
.git
dist/
.pnpm-store
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{ts,tsx,js,jsx,json}]
indent_style = tab
3 changes: 2 additions & 1 deletion .eslintignore
@@ -1,3 +1,4 @@
coverage
coverage/
dist/
node_modules/
lib/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lib/
lib/

Missing EOL

30 changes: 15 additions & 15 deletions .eslintrc
@@ -1,17 +1,17 @@
{
"extends": ["eslint:recommended", "prettier", "plugin:unicorn/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 12
},
"env": { "node": true, "es6": true },
"rules": {
"prettier/prettier": "warn",
"no-console": "off",
"no-unused-vars": "warn",
"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/prefer-top-level-await": "off"
}
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:jest/recommended",
"plugin:jest/style"
],
"parserOptions": {
"ecmaVersion": 2022
},
"env": { "node": true }
}
3 changes: 3 additions & 0 deletions .gitattributes
@@ -1,3 +1,6 @@
* text=auto eol=lf
*.png binary
*.sketch binary

# GitHub linguist should ignore these file
/packages/action/dist/** linguist-generated=true
3 changes: 0 additions & 3 deletions .github/boomper.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/dependabot.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/no-unstaged-files.sh

This file was deleted.

21 changes: 15 additions & 6 deletions .github/release-drafter.yml
@@ -1,3 +1,4 @@
# yaml-language-server: $schema=../schema.json
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
Expand All @@ -9,20 +10,28 @@ template: |

categories:
- title: 'Breaking'
label: 'type: breaking'
labels:
- 'type: breaking'
- title: 'New'
label: 'type: feature'
labels:
- 'type: feature'
- title: 'Bug Fixes'
label: 'type: bug'
labels:
- 'type: bug'
- title: 'Maintenance'
label: 'type: maintenance'
labels:
- 'type: maintenance'
- title: 'Documentation'
label: 'type: docs'
labels:
- 'type: docs'
- title: 'Other changes'
- title: 'Dependency Updates'
label: 'type: dependencies'
labels:
- 'type: dependencies'
collapse-after: 5

no-changes-template: '* No changes'

version-resolver:
major:
labels:
Expand Down
34 changes: 34 additions & 0 deletions .github/renovate.json5
@@ -0,0 +1,34 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
labels: ['type: dependencies'],
extends: [
'config:base',
':maintainLockFilesWeekly',
':rebaseStalePrs',
':disableDependencyDashboard',
'docker:disableMajor',
'docker:pinDigests',
'group:linters',
'helpers:pinGitHubActionDigests',
'schedule:earlyMondays',
],
timezone: 'Europe/Copenhagen',
prConcurrentLimit: 10,
rebaseWhen: 'behind-base-branch',
configMigration: true,
assignees: ['jetersen'],
packageRules: [
{
description: 'v prefix workaround for action updates',
matchDepTypes: ['action'],
extractVersion: '^(?<version>v\\d+\\.\\d+\\.\\d+)$',
versioning: 'regex:^v(?<major>\\d+)(\\.(?<minor>\\d+)\\.(?<patch>\\d+))?$',
},
{
description: 'Group prettier packages',
matchPackageNames: ['prettier'],
matchPackagePatterns: ['^@prettier\\/', '^prettier-plugin-'],
groupName: 'prettier packages',
},
],
}
18 changes: 11 additions & 7 deletions .github/workflows/action-build.yml
Expand Up @@ -3,7 +3,7 @@ on:
pull_request_target:
types: [opened, synchronize, reopened]
branches:
- 'master'
- 'main'

env:
HUSKY: '0'
Expand All @@ -26,22 +26,26 @@ jobs:
run: |
gh pr checkout ${{ github.event.pull_request.number }}

- uses: pnpm/action-setup@v2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what are you reason(s) to switch to pnpm?
Asking as it may be interesting to use it too for (plugins.)jenkins.io

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm solves a problem with monorepo shared dependencies are hard links or symlinks vs yarn and npm duplicating the storage.
Also the fact that I can share dev dependencies across workspaces

with:
version: 7

- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache: 'pnpm'

- run: yarn install --frozen-lockfile
- run: pnpm install --frozen-lockfile

- run: yarn build
- run: pnpm build

- name: Commit and push if needed
run: |
git add .
if [ -z "$(git status --porcelain)" ]; then
echo "💾 no changes to dist/index.js"
if [ "$(git diff --ignore-space-at-eol | wc -l)" -eq "0" ]; then
echo "❎ no changes"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use ℹ️ instead of a (green) cross which would make me think twice before deciding if it's all good.

exit 0
fi
git add .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
git add .
git add dist/index.js

or change the commit and echo lines to say it might have added more than just this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I do not want to try and figure out which dist it is.

Cause this will host multiple actions.

So it would be ./packages/action/dist or ./packages/autolabeler-action/dist or even more with the planned ./packages/pr-label-checker/dist/

reason for ./packages/autolabeler-action is that ./packages/app wants to reuse autolabeler so a ./packages/autolabeler is needed.

git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Apply dist/index.js changes"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/draft.yml
Expand Up @@ -3,12 +3,12 @@ name: Release Drafter
on:
push:
branches:
- master
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@master
- uses: release-drafter/release-drafter@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 20 additions & 10 deletions .github/workflows/release.yml
Expand Up @@ -16,31 +16,35 @@ jobs:
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
cache: yarn
cache: 'pnpm'
registry-url: https://registry.npmjs.org

- name: yarn install
run: yarn install --frozen-lockfile
- name: pnpm install
run: pnpm install --frozen-lockfile

- name: yarn test
run: yarn test
- name: pnpm test
run: pnpm test

- name: Deploy to Heroku
env:
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
HEROKU_APP_NAME: release-drafter
run: |
git fetch origin master
git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/master:master --force
git fetch origin main
git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/main:master --force

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/main:master --force
git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/main:main --force

(not sure about this one)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to change it on heroku just yet, sounds scary to run heroku repo:reset -a APP-NAME


- name: yarn publish
- name: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
run: yarn publish --access public
run: pnpm publish --access public --no-git-checks

- name: version
id: version
Expand All @@ -51,10 +55,16 @@ jobs:
echo "::set-output name=tag::${tag}"
echo "::set-output name=version::${version}"
echo "::set-output name=major::${major}"
if [[ "${version}" == *"-"* ]]; then
echo "::set-output name=prerelease::true"
else
echo "::set-output name=prerelease::false"
fi

- uses: release-drafter/release-drafter@master
- uses: release-drafter/release-drafter@main
with:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/tests.yml
Expand Up @@ -3,7 +3,7 @@ name: Tests
on:
push:
branches:
- master
- main
pull_request:

env:
Expand All @@ -14,17 +14,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn test
- run: yarn lint --fix
- run: yarn prettier
- run: yarn build
- name: correct vercel/ncc crlf output
run: sed -i 's/\x0D$//' ./dist/index.js
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm test
- run: pnpm lint:fix
- run: pnpm prettier:fix
- run: pnpm build
- name: check for unstaged files
if: ${{ github.actor != 'dependabot[bot]' }}
run: .github/no-unstaged-files.sh
run: |
if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
echo "::error::💥 Unstaged changes detected. Locally try running: pnpm prettier:fix && pnpm lint:fix && pnpm build"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the instructions order here be the same as the instructions above?

Copy link
Member Author

@jetersen jetersen Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order doesn't matter between prettier and lint, prettier corrects other files such as yaml and markdown as well :)

ESlint is configured for prettier so order does not matter.

exit 1
fi