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

Drop nuxt, use veun #116

Merged
merged 38 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7724cae
WIP
stanistan Dec 8, 2023
d980042
WIP with debug routes
stanistan Feb 29, 2024
37cadc6
some updates to structure
stanistan Mar 1, 2024
ec83823
bump go-github and ghinstallation/v2
stanistan Mar 1, 2024
153836c
bump kong and assert/v2
stanistan Mar 1, 2024
a195648
hermit managing a standalone tailwindcss cli
stanistan Mar 1, 2024
9c75988
WIP tailwind
stanistan Mar 1, 2024
01fc3f5
tailwindcss hermit cleanup
stanistan Mar 5, 2024
25de783
server/dev does tailwind and go
stanistan Mar 7, 2024
f34cadc
more wip on getting the content working
stanistan Mar 7, 2024
7438482
we got markdown and syntax highlighting going with metadata and titles
stanistan Mar 25, 2024
c9b06db
w/ nav that does stuff
stanistan Mar 26, 2024
7e99c2b
we can render slides but are missing the js binding
stanistan Mar 26, 2024
08bf95b
lol js slides
stanistan Mar 26, 2024
2ee239d
we can play full screen
stanistan Mar 26, 2024
cd184e7
some layout refactoring
stanistan Mar 27, 2024
1fbbe97
update w/ css
stanistan Mar 27, 2024
2f875db
WIP home
stanistan Mar 27, 2024
0409680
updating tw, working on the homepage
stanistan Apr 2, 2024
731762c
bye frontend/
stanistan Apr 2, 2024
c0a4a41
continued after dropping frontend/
stanistan Apr 2, 2024
cbbd6b1
remove old server command
stanistan Apr 2, 2024
a233829
use bun instead of tailwindcss via hermit
stanistan Apr 2, 2024
25d2c3d
move lint yaml
stanistan Apr 3, 2024
420cc17
remove proxy/static SPA options
stanistan Apr 3, 2024
7ad847f
bump veun, tidy
stanistan Apr 3, 2024
de10eaa
option to print the version
stanistan Apr 3, 2024
9a44beb
can be built in Dockerfile
stanistan Apr 3, 2024
e305314
topbar color update
stanistan Apr 3, 2024
bcaf48b
factor out topbar layout params
stanistan Apr 3, 2024
c64a7e7
pr view
stanistan Apr 3, 2024
277949c
some serach stuff
stanistan Apr 3, 2024
8d8b0cc
working search?
stanistan Apr 4, 2024
d828fc9
update README
stanistan Jun 21, 2024
50c4c14
filtering and hax height on md
stanistan Jun 21, 2024
d647db3
fix dockerfile with serve
stanistan Jun 21, 2024
95b9809
w/ compose for development
stanistan Jun 21, 2024
33e5599
update gh worklfows
stanistan Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@
docker-compose.yml
*Dockerfile
Makefile
server/.env
.env
*.log*
.nuxt
.nitro
.cache
frontend/node_modules
frontend/.output
frontend/dist
frontend/version.json
frontend/.pnp.*
frontend/.yarn/*
!frontend/.yarn/patches
!frontend/.yarn/plugins
!frontend/.yarn/releases
!frontend/.yarn/sdks
!frontend/.yarn/versions
data
48 changes: 8 additions & 40 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,36 @@ name: Pull Request

on:
push:
branches:
- main
branches:
- main
pull_request:
branches:
branches:
- main

jobs:

# server:
# server:
# can we run the server, is the API alright?
#
# Priority is to fail fast, so first can we compile and build
# Priority is to fail fast, so first can we compile and build
# the server binary, then tests, and linting.
server:
defaults:
run:
working-directory: server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cashapp/activate-hermit@v1
- name: build-server
run: go build ./cmd/server
run: go build ./cmd/veun
- name: test
run: go test ./...
- name: lint
run: golangci-lint run

# frontend: describes the steps we take to
# ensure that the nuxt application is buildable.
#
# The priority here is to fail fast on critical things.
# 1. We can actually build the application
# 2. It typechecks & lints
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v3
- uses: cashapp/activate-hermit@v1
- name: yarn
run: yarn
- name: generate
run: yarn generate
- name: typecheck
run: yarn nuxi typecheck

lint-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cashapp/activate-hermit@v1
- run: cd frontend && yarn && yarn eslint .
name: lint

# prmectl: just make sure that it's going to be ok.
prmectl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cashapp/activate-hermit@v1
- name: shellcheck bin/prmectl
run: shellcheck bin/prmectl
- name: shellcheck ./dev
run: shellcheck ./prod
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.pem
.cache/*
.env
.hermit/node/lib/node_modules/*
.hermit/node/cache/*
server/static
node_modules/
static/styles.dev.css
static/styles.css
data/
File renamed without changes.
3 changes: 0 additions & 3 deletions .hermit/node/lastKnownGood.json

This file was deleted.

873 changes: 0 additions & 873 deletions .hermit/node/yarn/3.5.1/yarn.js

This file was deleted.

874 changes: 0 additions & 874 deletions .hermit/node/yarn/3.6.1/yarn.js

This file was deleted.

33 changes: 16 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
FROM node:20.1-alpine as frontend
RUN corepack enable

FROM oven/bun:1.1 as tw
WORKDIR /app
COPY frontend/.yarn .yarn/
COPY frontend/package.json frontend/yarn.lock frontend/.yarnrc.yml ./
RUN yarn
COPY frontend /app
COPY package.json bun.lockb .
RUN bun install --frozen-lockfile
COPY . .
RUN bun run tailwindcss -i ./static/input.css -o styles.css --minify

ARG VERSION_SHA
RUN echo "{ \"rev\": \"$VERSION_SHA\" }" > /app/version.json
RUN yarn run generate

FROM golang:1.21.0-alpine as server
FROM golang:1.22.0 as app
ENV GOARCH=amd64
ENV GOOS=linux
WORKDIR /app
COPY server/go.mod server/go.sum ./
COPY go.mod go.sum ./
RUN go mod download
COPY server /app
COPY . .

ARG VERSION_SHA
RUN go build -o server -ldflags="-X main.version=$VERSION_SHA" ./cmd/server
RUN go build -o server -ldflags="-X main.version=$VERSION_SHA" ./cmd/veun

FROM scratch as prod
COPY --from=server /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=server /app/server /app
COPY --from=frontend /app/.output/public /static
ENTRYPOINT ["/app"]
COPY --from=app /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=app /app/server /app
COPY --from=app /app/static /static
COPY --from=tw /app/styles.css /static/styles.css
ENTRYPOINT ["/app", "serve"]
77 changes: 35 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,98 +9,91 @@ See https://prme.stanistan.com for a demo.
## Why

Sometimes you make a PR that is too large for folks to read/parse top-to-bottom and it would be useful
to annotate it to desribe and show your team _how to read_ and parse the changeset.
to annotate it to desribe and show your team _how to read_ and parse the changeset.
What's important, what's superfluous, what's incidental to this change?

Present-me uses GitHub's Review Comments as a persistence layer (and write UI)
Present-me uses GitHub's Review Comments as a persistence layer (and write UI)
to generate something that can be, well, presented!

### How to use it

1. Create your PR as you would normally... [pr](https://github.com/stanistan/present-me/pull/56)
2. Start commenting on your own PR! But instead of individual comments, start a review!
3. Prefix your comments with a number to set the order that it'll show up
4. Grab the permalink of the review.
4. Grab the permalink of the review.
<img width="680" alt="image" src="https://github.com/stanistan/present-me/assets/66807/89033c9c-6486-4da0-8cf9-d269443f0290">
5. Go to https://prme.stanistan.com/
5. Go to https://prme.stanistan.com/
6. Paste the permalink into the box
7. Hit GO! [rendered](https://prme.stanistan.com/stanistan/present-me/pull/56/review-1419621494)

<img width="797" alt="image" src="https://github.com/stanistan/present-me/assets/66807/1c0a6209-a135-4fde-aa12-d93c5316a4e8">

## Development

This project uses [hermit](https://cashapp.github.io/hermit/) for dependency management.
This project uses [hermit](https://cashapp.github.io/hermit/) for dependency management.

### Bootstrap

```sh
prmectl bootstrap
# for go packages
go mod download

# for tailwindcss
bun install
```

Make sure you've run this before anything else!

#### `server/.env`
#### `.env`

This assumes you have a `.env` in the `server` directory.
This assumes you have a `.env` in the project directory.

```
PORT=8080
GH_APP_ID=0
GH_INSTALLATION_ID=0
LOG_OUTPUT=console
DISK_CACHE_ENABLED=true
DISK_CACHE_BASE_PATH=../data
DISK_CACHE_BASE_PATH=data
DISK_CACHE_MAX_SIZE=10000
```

N.B. Not having the ID, InstallationID, and PK file will use the public GH API and be subject
N.B. Not having the ID, InstallationID, and PK file will use the public GH API and be subject
to those rate limits. Enabling the `DISK_CACHE` helps alleviate those. You can check out
the cached files in `data/` to see what the responses look like.

Full options:
Full options:

```
go run ./cmd/server --help
Usage: server --serve="static" --log-output="json" --gh-app_id=INT-64 --gh-installation_id=INT-64
# go run ./cmd/veun --help
Usage: present-me --log-output="json" --gh-app_id=INT-64 --gh-installation_id=INT-64 <command>

Flags:
-h, --help Show context-sensitive help.
--port="8080" ($PORT)
--hostname="localhost" ($HOSTNAME)
-h, --help Show context-sensitive help.
--port="8080" ($PORT)
--hostname="localhost" ($HOSTNAME)
--server-read-timeout=5s
--server-write-timeout=10s
--serve="static"
--static-dir="./static"
--proxy-address="http://localhost:3000"
--log-output="json" ($LOG_OUTPUT)
--disk-cache-enabled ($DISK_CACHE_ENABLED)
--disk-cache-base-path=STRING ($DISK_CACHE_BASE_PATH)
--disk-cache-cache-max-size=1024 ($DISK_CACHE_MAX_SIZE_KB)
--gh-app_id=INT-64 ($GH_APP_ID)
--gh-installation_id=INT-64 ($GH_INSTALLATION_ID)
--gh-pk-file=STRING ($GH_PK_FILE)
--debug ($DEBUG)
--environment="dev" ($ENV)
--log-output="json" ($LOG_OUTPUT)
--disk-cache-enabled ($DISK_CACHE_ENABLED)
--disk-cache-base-path=STRING ($DISK_CACHE_BASE_PATH)
--disk-cache-cache-max-size=1024 ($DISK_CACHE_MAX_SIZE_KB)
--gh-app_id=INT-64 ($GH_APP_ID)
--gh-installation_id=INT-64 ($GH_INSTALLATION_ID)
--gh-pk-file=STRING ($GH_PK_FILE)

Commands:
version --log-output="json" --gh-app_id=INT-64 --gh-installation_id=INT-64

serve --log-output="json" --gh-app_id=INT-64 --gh-installation_id=INT-64
```

#### Development

```bash
prmectl dev
dev
```

This will start both the go server at port `8080` and
the nuxt client at port `3000`.

You can interact with both via port `8080` since the go
server will proxy directly to nuxt.

- <http://localhost:8080>

## Testing a production binary

```bash
prmectl local-prod
```

This will generate the static output from `nuxt` and run the server
in production mode (not a proxy to the nuxt dev-server).
File renamed without changes.
1 change: 1 addition & 0 deletions bin/.go-1.22.0.pkg
2 changes: 2 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
Expand Down
1 change: 1 addition & 0 deletions bin/bun
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
23 changes: 20 additions & 3 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HOME}/Library/Caches/hermit"
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/hermit"
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac
fi
Expand All @@ -20,7 +24,20 @@ export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
curl -fsSL "${HERMIT_DIST_URL}/install.sh" | /bin/bash 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
1 change: 1 addition & 0 deletions bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sources = [ "env:///", "https://github.com/cashapp/hermit-packages.git" ]
Binary file added bun.lockb
Binary file not shown.
Loading
Loading