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

chore(console): console preview environment #3891

Merged
merged 77 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
77b9de1
wip
eladcon Aug 11, 2023
81f1593
wip
eladcon Aug 11, 2023
bd7d547
wip
eladcon Aug 11, 2023
8396aa3
wip
eladcon Aug 11, 2023
23f1731
wip
eladcon Aug 13, 2023
12ff614
wip
eladcon Aug 13, 2023
a114c4a
wip
eladcon Aug 13, 2023
d6a87be
wip
eladcon Aug 13, 2023
3dae570
wip
eladcon Aug 13, 2023
45b1eaf
wip
eladcon Aug 13, 2023
96499e9
wip
eladcon Aug 13, 2023
baac664
wip
eladcon Aug 13, 2023
4846ebd
wip
eladcon Aug 13, 2023
64f74e0
wip
eladcon Aug 13, 2023
6f477da
wip
eladcon Aug 13, 2023
ff81c5f
wip
eladcon Aug 13, 2023
ffbf938
wip
eladcon Aug 13, 2023
ebff561
wip
eladcon Aug 13, 2023
da3d85b
wip
eladcon Aug 13, 2023
1812643
wip
eladcon Aug 13, 2023
86f0906
wip
eladcon Aug 13, 2023
dc5fd9d
wip
eladcon Aug 13, 2023
1340697
wip
eladcon Aug 13, 2023
6db9888
wip
eladcon Aug 13, 2023
8bd1259
wip
eladcon Aug 13, 2023
7092b35
wip
eladcon Aug 13, 2023
e006146
wip
eladcon Aug 13, 2023
62cb630
wip
eladcon Aug 13, 2023
c0ec223
wip
eladcon Aug 13, 2023
64b6c32
wip
eladcon Aug 13, 2023
b3cb486
wip
eladcon Aug 14, 2023
29cd1cf
wip
eladcon Aug 14, 2023
4eca33c
wip
eladcon Aug 14, 2023
d5a735d
wip
eladcon Aug 14, 2023
083e8a8
wip
eladcon Aug 14, 2023
828bd41
wip
eladcon Aug 14, 2023
bec4033
wip
eladcon Aug 14, 2023
a61ac4f
wip
eladcon Aug 14, 2023
661c211
wip
eladcon Aug 14, 2023
164c1a0
wip
eladcon Aug 14, 2023
562987b
wip
eladcon Aug 14, 2023
10c0307
wip
eladcon Aug 14, 2023
5369099
wip
eladcon Aug 15, 2023
ff56450
wip
eladcon Aug 15, 2023
5acb573
wip
eladcon Aug 15, 2023
1510a7b
wip
eladcon Aug 15, 2023
7d1cd7c
wip
eladcon Aug 15, 2023
53d4aba
Merge pull request #2 from eladcon/test-docker
eladcon Aug 15, 2023
13d549b
wip (#3)
eladcon Aug 15, 2023
0a9ad14
wip
eladcon Aug 20, 2023
0024859
wip
eladcon Aug 20, 2023
30c5295
wip
eladcon Aug 20, 2023
f6ee028
pr comments
eladcon Aug 21, 2023
827569b
pr comments
eladcon Aug 22, 2023
ea80459
wip
eladcon Aug 23, 2023
114e472
wip
eladcon Aug 23, 2023
a567822
wip
eladcon Aug 23, 2023
92f1d59
wip
eladcon Aug 23, 2023
2f49616
wip
eladcon Aug 23, 2023
984dd99
wip
eladcon Aug 23, 2023
65d18a2
wip
eladcon Aug 23, 2023
3698b48
wip
eladcon Aug 23, 2023
37e6502
wip
eladcon Aug 23, 2023
77190d6
wip
eladcon Aug 23, 2023
330cf8b
wip
eladcon Aug 23, 2023
f00b552
wip
eladcon Aug 28, 2023
5d0ab47
wip
eladcon Aug 28, 2023
cfaebe4
wip
eladcon Aug 29, 2023
cd7c9f4
wip
eladcon Aug 29, 2023
654b4cb
wip
eladcon Aug 29, 2023
253637c
pr comments
eladcon Aug 29, 2023
5def202
fix type
eladcon Aug 29, 2023
65ae8e2
wip
eladcon Aug 29, 2023
bb32fee
remove checkout step
eladcon Aug 29, 2023
59d6cbf
Update .github/workflows/build.yml
eladcon Aug 30, 2023
716688a
Merge branch 'main' into preview-console
MarkMcCulloh Aug 30, 2023
a9d559f
Update delete-console-preview.yml
eladcon Aug 30, 2023
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
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,55 @@ jobs:
name: ${{ steps.diff.outputs.diff_name }}
path: ${{ steps.diff.outputs.diff_name }}

console-preview:
name: "Console Preview"
runs-on: ubuntu-latest
needs:
- build
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_VERSION: "0.1.80"
APP_NAME: wing-console-pr-${{github.event.number}}
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Download Dist Artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Install flyctl
uses: superfly/flyctl-actions/[email protected]
with:
version: ${{env.FLY_VERSION}}

- name: Deploy to Fly.io
id: deploy-fly
run: |
if ! flyctl status --app "$APP_NAME"; then
pushd ./apps/wing-console/console/app/preview
flyctl launch --no-deploy --copy-config --name "$APP_NAME" --image-label latest
popd
fi
flyctl deploy . --config ./apps/wing-console/console/app/preview/fly.toml --app "$APP_NAME" --image-label latest --vm-memory 512 --strategy immediate
flyctl scale count 1 --yes --app "$APP_NAME"
echo "deploytime=$(TZ=UTC date +'%Y-%m-%d %H:%M')" >> $GITHUB_OUTPUT

- name: Post preview comment
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Console preview environment is available at https://${{env.APP_NAME}}.fly.dev :rocket:

*Updated (UTC): ${{steps.deploy-fly.outputs.deploytime }}*
comment_tag: Console preview environment
GITHUB_TOKEN: ${{secrets.PROJEN_GITHUB_TOKEN}}

quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/delete-console-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Delete Console Preview

on:
pull_request:
types:
- closed

env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_VERSION: "0.1.80"
APP_NAME: wing-console-pr-${{github.event.number}}

jobs:
destroy:
name: "Destroy"
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }}
steps:
- name: Install flyctl
uses: superfly/flyctl-actions/[email protected]
with:
version: ${{env.FLY_VERSION}}

- name: Delete preview environment
run: |
if flyctl status --app "$APP_NAME"; then
flyctl apps destroy "$APP_NAME" -y
fi
11 changes: 11 additions & 0 deletions apps/wing-console/console/app/preview/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:18.16.0-alpine

WORKDIR /app

COPY dist dist
COPY apps/wing-console/console/app/preview/index.mjs dist/
COPY apps/wing-console/console/app/demo demo

RUN npm init -y && npm install --no-package-lock ./dist/*-[0-9]*.[0-9]*.[0-9]*.tgz

ENTRYPOINT ["node", "dist/index.mjs"]
25 changes: 25 additions & 0 deletions apps/wing-console/console/app/preview/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
primary_region = "lhr"

[build]
dockerfile = "Dockerfile"
ignorefile = ".dockerignore"

[[services]]
protocol = "tcp"
internal_port = 3000
auto_stop_machines = false
auto_start_machines = false
min_machines_running = 1

[services.concurrency]
hard_limit = 250
soft_limit = 200
type = "connections"

[[services.ports]]
port = 80
handlers = ["http"]

[[services.ports]]
port = 443
handlers = ["tls", "http"]
7 changes: 7 additions & 0 deletions apps/wing-console/console/app/preview/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { fileURLToPath } from "node:url";
import { createConsoleApp } from "@wingconsole/app";

await createConsoleApp({
wingfile: fileURLToPath(new URL("../demo/index.w", import.meta.url)),
requestedPort: 3000,
});
4 changes: 3 additions & 1 deletion apps/wing-console/console/app/web/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ ReactDOM.createRoot(document.querySelector("#root")!).render(
<React.StrictMode>
<Console
trpcUrl="/trpc"
wsUrl={`ws://${location.host}/trpc`}
wsUrl={`${location.protocol === "http:" ? "ws://" : "wss://"}${
location.host
}/trpc`}
layout={Number(query.get("layout")) || 1} // default to 1 = vscode (2 = playground, 3 = tutorial)
theme={query.get("theme") as any}
color={query.get("color") as any}
Expand Down
Loading