Skip to content

Commit

Permalink
Remove use of cf pages (#2110)
Browse files Browse the repository at this point in the history
* Update

* Update test deployment

* Up

* Update names

* Fix names

* Up names

* Revert "Up names"

This reverts commit c95b974.

* Up names

* Rem
  • Loading branch information
harsh-mn-yral authored Feb 13, 2024
1 parent 9dc4ee0 commit cddd90d
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 110 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/experiments-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Experiment app
name: ex:deploy
on:
push:
branches:
Expand All @@ -12,30 +12,19 @@ concurrency:
cancel-in-progress: true

jobs:
experiments-deploy-production:
fly-production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
shell: bash
run: npm install

- run: npm run ex:build
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
GA_TRACKING_ID: "G-PPE5XD2VKV"
- run: npm install

- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy production build
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_API_TOKEN }}
workingDirectory: "packages/experiments/"
command: pages deploy ".svelte-kit/cloudflare" --branch=${{ github.head_ref }} --project-name=hot-or-not-experiments --commit-dirty=true
run: flyctl deploy --config ./ex.prod.fly.toml
env:
CLOUDFLARE_ACCOUNT_ID: "a209c523d2d9646cc56227dbe6ce3ede"
FLY_API_TOKEN: ${{ secrets.FLYIO_KIT_DEPLOY_GH_ACTION }}
44 changes: 14 additions & 30 deletions .github/workflows/experiments-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test experiments app
name: ex:tests
on:
pull_request:
branches:
Expand All @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true

jobs:
experiments-test:
svelte-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -35,8 +35,11 @@ jobs:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
GA_TRACKING_ID: "G-PPE5XD2VKV"

experiments-deploy-staging:
needs: ["experiments-test"]
deploy-fly-staging:
needs: ["svelte-check"]
environment:
name: pr-${{ github.event.number }}-experiments
url: ${{ steps.deploy.outputs.url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -46,33 +49,14 @@ jobs:
node-version: 20
cache: "npm"

- name: Install dependencies
shell: bash
run: npm install
- run: npm install

- name: Creating static build
run: npm run ex:build:static
env:
GA_TRACKING_ID: "G-PPE5XD2VKV"

- name: Deploying build
- name: Deploy staging build
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_API_TOKEN }}
workingDirectory: "packages/experiments/"
command: pages deploy "./build" --branch=${{ github.head_ref }} --project-name=hot-or-not-experiments --commit-dirty=true
uses: superfly/[email protected]
env:
CLOUDFLARE_ACCOUNT_ID: "a209c523d2d9646cc56227dbe6ce3ede"

- name: Comment preview link on PR
if: github.actor != 'dependabot[bot]'
uses: actions/github-script@v7
FLY_API_TOKEN: ${{ secrets.FLYIO_KIT_DEPLOY_GH_ACTION }}
FLY_ORG: gobazzinga-inc-584
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Experiments preview build: ${{ steps.deploy.outputs.previewUrl }}'
})
name: pr-${{ github.event.number }}-experiments
config: "ex.staging.fly.toml"
32 changes: 21 additions & 11 deletions .github/workflows/webclient-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: Deploy Web-Client
name: wc:deploy
on:
push:
branches:
- main
paths:
- "packages/web-client/**"
- ".github/workflows/webclient-deploy.yml"
- ".github/workflows/webclient-setup/action.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
web-client-deploy-ic-production:
ic-production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm install
- run: npm run wc:build:static:prod
# Build without sentry
- run: |
Expand All @@ -33,15 +35,23 @@ jobs:
dfx identity use actions
- run: dfx deploy webclient --network ic --no-wallet -y

web-client-deploy-fly-production:
fly-production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- run: npm run wc:build:prod
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm install

- name: Touch .env
shell: bash
working-directory: "packages/web-client/"
run: |
touch .env
echo "SENTRY_AUTH_TOKEN=\"${{ secrets.SENTRY_AUTH_TOKEN }}\"" >> .env
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy production build
run: flyctl deploy --config ./wc.prod.fly.toml
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/webclient-setup/action.yml

This file was deleted.

26 changes: 11 additions & 15 deletions .github/workflows/webclient-test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Web-client tests
name: wc:tests
on:
pull_request:
branches:
- main
paths:
- "packages/web-client/**"
- ".github/workflows/webclient-deploy.yml"
- ".github/workflows/webclient-setup/action.yml"
- ".github/workflows/webclient-test.yml"
- ".github/workflows/webclient-test-deploy.yml"

Expand Down Expand Up @@ -34,19 +33,21 @@ jobs:
- name: Run svelte-check
run: npm run wc:check

web-client-deploy-fly-staging:
deploy-fly-staging:
needs: ["svelte-check"]
environment:
name: pr-${{ github.event.number }}
name: pr-${{ github.event.number }}-web-client
url: ${{ steps.deploy.outputs.url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set-up env
uses: ./.github/workflows/webclient-setup
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- run: npm run wc:build:prod
- run: npm install

- name: Deploy staging build
id: deploy
Expand All @@ -55,9 +56,10 @@ jobs:
FLY_API_TOKEN: ${{ secrets.FLYIO_KIT_DEPLOY_GH_ACTION }}
FLY_ORG: gobazzinga-inc-584
with:
name: pr-${{ github.event.number }}-web-client
config: "wc.staging.fly.toml"

tests-lighthouse-reports:
lighthouse-cypress-vitest:
needs: ["svelte-check"]
if: github.event.pull_request.draft == false
timeout-minutes: 40
Expand All @@ -73,10 +75,7 @@ jobs:
cache: "npm"

- name: Install dependencies
run: npm i

- name: Echo expression
run: echo ${{ (github.actor != 'dependabot[bot]' && 'wc:test:record') || 'wc:test' }}
run: npm install

- name: Add Rust wasm target
run: rustup target add wasm32-unknown-unknown
Expand Down Expand Up @@ -124,9 +123,6 @@ jobs:
# set -euxo pipefail
# npm run wc:test:vi

- name: Set-up env
uses: ./.github/workflows/webclient-setup

- name: Run Cypress tests
uses: cypress-io/github-action@v5
with:
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions ex.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.16.1
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Copy application code
COPY --link . .

# Install node modules
RUN npm install --include=dev

# Build application
RUN npm run ex:build

# Remove development dependencies
RUN npm prune --omit=dev

# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "ex:start" ]
24 changes: 24 additions & 0 deletions ex.prod.fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# fly.toml app configuration file generated for hot-or-not-kit on 2024-01-04T16:13:20+05:30
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "experiments-kit"
primary_region = "bos"

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

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024
24 changes: 24 additions & 0 deletions ex.staging.fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# fly.toml app configuration file generated for hot-or-not-kit on 2024-01-04T16:13:20+05:30
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "experiments-kit-staging"
primary_region = "bos"

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

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ex:build:static": "npm run build:static --w @hnn/experiments",
"ex:dev": "npm run dev --w @hnn/experiments",
"ex:preview": "npm run preview --w @hnn/experiments",
"ex:start": "npm run start --w @hnn/experiments",
"ex:sync": "npm run sync --w @hnn/experiments",
"serve:lhci": "npm run wc:preview",
"wc:check": "npm run wc:sync && npm run check --w @hnn/web-client",
Expand Down
1 change: 1 addition & 0 deletions packages/experiments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"check": "svelte-check --tsconfig ./tsconfig.json --ignore .svelte-kit,build,tests --threshold warning --diagnostic-sources \"js,ts,svelte\"",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"tsc": "tsc -b",
"start": "node build",
"sync": "svelte-kit sync",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
Expand Down
Loading

0 comments on commit cddd90d

Please sign in to comment.