-
Notifications
You must be signed in to change notification settings - Fork 2
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
Convert to TS project #81
Conversation
Codecov Report
@@ Coverage Diff @@
## main #81 +/- ##
========================================
Coverage ? 100.00%
========================================
Files ? 2
Lines ? 31
Branches ? 3
========================================
Hits ? 31
Misses ? 0
Partials ? 0 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
If you don't want to do the song and dance to validate the committed https://github.com/JasonEtco/build-and-tag-action name: Publish
on:
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.tag_name }}
- name: Install deps and build
run: npm ci && npm run build
- uses: JasonEtco/build-and-tag-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
I haven't used it (I haven't made a JS action myself) but it seems interesting! |
I'm checking that |
@jcbhmr FYI if you want to test this action before I merge this rewrite. I don't really have time to test it out right now. |
BTW feel free to make PRs targeting the |
} | ||
}, | ||
// https://webinstall.dev/ | ||
"postCreateCommand": "curl -sS https://webi.sh/shfmt | sh && curl -sS https://webi.sh/shellcheck | sh" | ||
"postCreateCommand": ".devcontainer/postCreate.sh", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "postCreateCommand": ".devcontainer/postCreate.sh",
+ "postCreateCommand": "pnpm install",
It is just one command after all 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a bit of future-proofing for when more post-create commands need to be added. Plus, it's a cheat to add a bit more language diversity to this project 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I (personally since I wrote it 😁) think that the idea of using gh repo clone
into a tmp folder and using $GIT_DIR
and $GIT_WORK_TREE
is better than trying to finagle the git clone
into the working tree.
Pros of gh repo clone user/repo.wiki /tmp/123abc
:
- You don't deal with #72
- You don't need to worry about the .git folder in the $PWD subtree affecting anything else (git submodule weirdness detection)
- You can clone the remote repo directly instead of git init and fetch
Remember I am biased. 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this PR is an attempt to translate to a different language without much change to the implementation. This is partly my obsession with "clean" git histories, but I'd want this rewrite to have few to no significant side effects. But I'm definitely open to changing the implementation after this PR 🙂
@@ -0,0 +1,76 @@ | |||
import * as core from "@actions/core"; | |||
import { exec } from "@actions/exec"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 😎 library that makes it much easier to do shell stuff: https://github.com/google/zx#readme
You don't have to use it, I'm just letting you know this cool thing exists 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never bothered researching this, but I've always wondered why @actions/exec
exists when there are already other popular implementations for calling commands (another one is execa). Like, is there something about @actions/exec
that optimizes it for actions? All I've found is actions/toolkit#315
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"format": "prettier --write .", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "format": "prettier --write .",
+ "format": "prettier --ignore-path .gitignore -w .",
This would make it so you don't need a .prettierignore since your .gitignore would double as your .prettier ignore.
Though then again this might conflict with the fact that there's minified JS in dist/ in source control 🤦♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, prettifying built files is an annoyance that I'd like to avoid.
.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to use https://github.com/github/gitignore/blob/main/Node.gitignore since it's "official" but that's just me 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, besides the fact that it ignores dist/
by default AFAIK, there's no reason I'm not using it besides being to lazy to fetch that file 😆
src/has-wiki.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default gh repo clone octocat/project.wiki
has a good enough error message, right? 🤔
$ gh repo clone nodejs/node.wiki
The 'nodejs/node' repository does not have a wiki
I think just letting that gh repo clone
command fail and print its own error message is OK. 🤷♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that gh
has an explicit check if you're cloning a wiki 😆
While gh
is an awesome tool, one of the things I want to do is drop dependency on gh
and implement as much with pure TS as possible.
const baseOptions = { cwd }; | ||
await exec("git", ["init"], baseOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember! This still has the issue with the existing .git
folder from the main repo that was actions/checkout
-ed into here! #72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! This will be addressed in a subsequent change.
Just noticed that the test.yml file was removed 😬 I highly recommend that that e2e test stays in there! It's arguably the most important test of all and has saved me a couple of times. https://github.com/spenserblack/actions-wiki/actions/workflows/test.yml |
Closes #80