From 70ed022a055949984229c3a2e544f8bd4b6d9e3b Mon Sep 17 00:00:00 2001 From: Alex Stelea Date: Thu, 8 Dec 2022 12:50:08 +0100 Subject: [PATCH] ci: add environment variables for development and beta --- .env.beta | 2 + .env => .env.development | 2 +- .github/workflows/build.yml | 81 +++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 44 -------------------- build.sh | 4 +- gh_pages_build.sh | 4 +- package.json | 3 +- src/config.ts | 52 +++++++++++++++++++----- src/setup-tests.ts | 3 +- 9 files changed, 134 insertions(+), 61 deletions(-) create mode 100644 .env.beta rename .env => .env.development (78%) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/main.yml diff --git a/.env.beta b/.env.beta new file mode 100644 index 00000000..44afc1d5 --- /dev/null +++ b/.env.beta @@ -0,0 +1,2 @@ +VITE_APP_SIGNALING_SERVER_BASE_URL=wss://signaling-server-betanet.radixdlt.com +VITE_APP_LOG_LEVEL=debug \ No newline at end of file diff --git a/.env b/.env.development similarity index 78% rename from .env rename to .env.development index c82a50c9..5866f384 100644 --- a/.env +++ b/.env.development @@ -1,2 +1,2 @@ VITE_APP_SIGNALING_SERVER_BASE_URL=wss://signaling-server-dev.rdx-works-main.extratools.works -VITE_APP_LOG_LEVEL=debug +VITE_APP_LOG_LEVEL=debug \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3bea1fea --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,81 @@ +name: Build + +on: + push: + branches: ['**'] + workflow_dispatch: + +jobs: + build_dev: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install dependencies + run: yarn add --dev wrtc + + - name: Running lint + run: yarn lint + + - name: Running unit tests + run: yarn test + + - name: Build dev extension + run: yarn build:dev + + - uses: actions/upload-artifact@v3 + with: + name: dev_connector-extension.${{ github.sha }} + path: dist/ + + - name: Build dev extension with dev tools + run: yarn build:dev + env: + DEV_TOOLS: true + + - uses: actions/upload-artifact@v3 + with: + name: dev_connector-extension-dev-tools.${{ github.sha }} + path: dist/ + + build_beta: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install dependencies + run: yarn add --dev wrtc + + - name: Running lint + run: yarn lint + + - name: Running unit tests + run: yarn test + + - name: Build dev extension + run: yarn build:beta + + - uses: actions/upload-artifact@v3 + with: + name: beta_connector-extension.${{ github.sha }} + path: dist/ + + - name: Build dev extension with dev tools + run: yarn build:beta + env: + DEV_TOOLS: true + + - uses: actions/upload-artifact@v3 + with: + name: beta_connector-extension-dev-tools.${{ github.sha }} + path: dist/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index a3d6533a..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build - -on: - push: - branches: ['**'] - workflow_dispatch: - -jobs: - test_and_lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - - - name: Install dependencies - run: yarn add --dev wrtc - - - name: Running lint - run: yarn lint - - - name: Running unit tests - run: yarn test - - - name: Build extension - run: yarn build - - - uses: actions/upload-artifact@v3 - with: - name: connector-extension.${{ github.sha }} - path: dist/ - - - name: Build extension with dev tools - run: yarn build - env: - DEV_TOOLS: true - - - uses: actions/upload-artifact@v3 - with: - name: connector-extension-dev-tools.${{ github.sha }} - path: dist/ diff --git a/build.sh b/build.sh index 5d88cd61..22266275 100755 --- a/build.sh +++ b/build.sh @@ -7,10 +7,10 @@ rm -rf radix-connect radix-connect-dev radix-connect.zip radix-connect-dev.zip NAME="radix-connect" DEV_NAME="radix-connect-dev" -yarn build +yarn build:beta mv dist $NAME -DEV_TOOLS=true yarn build +DEV_TOOLS=true yarn build:beta mv dist $DEV_NAME zip --recurse-paths ${NAME}.zip ${NAME} diff --git a/gh_pages_build.sh b/gh_pages_build.sh index c0af1f25..61970f09 100755 --- a/gh_pages_build.sh +++ b/gh_pages_build.sh @@ -7,10 +7,10 @@ DEV_NAME="radix-connect-dev" LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) -yarn build +yarn build:beta mv dist $NAME -DEV_TOOLS=true yarn build +DEV_TOOLS=true yarn build:beta mv dist $DEV_NAME zip --recurse-paths ${NAME}-${LATEST_TAG}.zip ${NAME} diff --git a/package.json b/package.json index a0f40029..09faf085 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ }, "scripts": { "dev": "DEV_TOOLS=true vite", - "build": "tsc && vite build", + "build:dev": "tsc && vite build", + "build:beta": "tsc && vite build --mode beta", "preview": "vite preview", "prettier": "prettier --write src", "testrtc": "NODE_ENV=test karma start", diff --git a/src/config.ts b/src/config.ts index fcbd20df..abdcd8eb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,6 +2,47 @@ import { LogLevelDesc } from 'loglevel' import packageJson from '../package.json' const { version } = packageJson +const turnServers = { + test: [ + { + urls: 'turn:turn-dev-udp.rdx-works-main.extratools.works:80?transport=udp', + username: 'username', + credential: 'password', + }, + { + urls: 'turn:turn-dev-tcp.rdx-works-main.extratools.works:80?transport=tcp', + username: 'username', + credential: 'password', + }, + ], + development: [ + { + urls: 'turn:turn-dev-udp.rdx-works-main.extratools.works:80?transport=udp', + username: 'username', + credential: 'password', + }, + { + urls: 'turn:turn-dev-tcp.rdx-works-main.extratools.works:80?transport=tcp', + username: 'username', + credential: 'password', + }, + ], + beta: [ + { + urls: 'turn:turn-betanet-udp.radixdlt.com:80?transport=udp', + username: 'username', + credential: 'password', + }, + { + urls: 'turn:turn-betanet-tcp.radixdlt.com:80?transport=tcp', + username: 'username', + credential: 'password', + }, + ], +} as const + +const mode = import.meta.env.MODE as 'test' | 'development' | 'beta' + export const config = { environment: process.env.NODE_ENV, logLevel: import.meta.env.VITE_APP_LOG_LEVEL as LogLevelDesc, @@ -36,16 +77,7 @@ export const config = { { urls: 'stun:stun4.l.google.com:19302', }, - { - urls: 'turn:turn-dev-udp.rdx-works-main.extratools.works:80?transport=udp', - username: 'username', - credential: 'password', - }, - { - urls: 'turn:turn-dev-tcp.rdx-works-main.extratools.works:80?transport=tcp', - username: 'username', - credential: 'password', - }, + ...(turnServers[mode] || []), ], }, dataChannelConfig: { diff --git a/src/setup-tests.ts b/src/setup-tests.ts index b72fb9a7..7f4452bc 100644 --- a/src/setup-tests.ts +++ b/src/setup-tests.ts @@ -3,8 +3,9 @@ import dotenv from 'dotenv' import { randomUUID, webcrypto } from 'node:crypto' import { chrome } from 'jest-chrome' +import path from 'node:path' -dotenv.config() +dotenv.config({ path: path.join(__dirname, '../.env.development') }) global.chrome = chrome global.chrome.storage = {