Skip to content

Commit

Permalink
add unit test & build & publish actions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe authored Oct 12, 2023
1 parent b1c394d commit 7309c47
Show file tree
Hide file tree
Showing 23 changed files with 1,968 additions and 4,354 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
**/dist/*
**/node_modules/*
**/coverage/*
**/node_modules/*
pnpm-lock.yaml
18 changes: 18 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Setup
description: Setup Node.js and pnpm

runs:
using: composite
steps:
- name: Install pnpm 🤏🏻
uses: pnpm/action-setup@v2.2.4
with:
version: latest

- name: Setup Node 💚
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: 'https://npm.pkg.github.com'
scope: '@agoraio-extensions'
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build
on:
pull_request:
workflow_dispatch:

jobs:
build-and-upload-artifact:
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read
packages: read
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Add SSH key to chekout a private repo
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.REPO_SSH_KEY }}

- name: Setup 🛠️
uses: ./.github/actions/setup

- name: Build 🔧

run: |
pnpm install
pnpm run lint
pnpm run test
pnpm run build
MY_PATH=$(ls packages/rtc/dist | awk -F/ '{print $NF}')
echo "MY_PATH=$MY_PATH" >> $GITHUB_ENV
- name: Upload Artifact ⬆️
uses: actions/upload-artifact@v3
with:
name: ${{ env.MY_PATH }}
path: ./packages/rtc/dist/${{ env.MY_PATH }}
19 changes: 19 additions & 0 deletions .github/workflows/gitleak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: gitleaks
on:
pull_request:
push:
workflow_dispatch:

jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
44 changes: 44 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on: ['pull_request']

name: Test PR

jobs:
build:
name: Test PR
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: write
pull-requests: write
packages: read
checks: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Add SSH key to chekout a private repo
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.REPO_SSH_KEY }}

- name: Setup 🛠️
uses: ./.github/actions/setup

- name: TEST 🔧

run: |
pnpm install
pnpm run lint
- name: Report Coverage for iris-web-rtc 🟢
uses: ArtiomTr/jest-coverage-report-action@v2
with:
custom-title: Coverage report for iris-web-rtc
package-manager: pnpm
working-directory: './packages/rtc'
97 changes: 97 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Publish

on:
workflow_dispatch:
inputs:
package:
type: choice
description: 'choose package'
default: 'iris-web-rtc'
required: true
options:
- iris-web-rtc
- iris-web-rtm
version:
description: 'x.x.x-semver.x, semver: dev,build'
required: true
default: 'patch'
type: string
releases:
description: 'create Releases, choose false if specify version'
default: true
type: boolean
cdn:
description: 'upload to cdn'
default: false
type: boolean
release_type:
description: 'The release type of CDN'
default: 'staging'
type: string
npm:
description: 'upload to npm'
default: false
type: boolean

jobs:
release-it:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup
uses: ./.github/actions/setup

- name: Setup Dependencies 💚
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: |
pnpm install
pnpm run lint
pnpm run build
MY_PATH=$(ls packages/rtc/dist | awk -F/ '{print $NF}')
echo "MY_PATH=$MY_PATH" >> $GITHUB_ENV
- name: Upload Artifact ⬆️
uses: actions/upload-artifact@v3
with:
name: iris-web-rtc
path: ./packages/rtc/dist/${{ env.MY_PATH }}

- name: CDN Publish
if: ${{ inputs.cdn }}
run: |
UPLOAD_CDN_INTERNAL_JENKINS_HOOK=${{ inputs.upload_cdn_internal_jenkins_hook }}
UPLOAD_URL=${{ inputs.url }}
RELEASE_TYPE=${{ inputs.release_type }}
curl -X POST ${UPLOAD_CDN_INTERNAL_JENKINS_HOOK} \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{ \"release\": { \"assets\": [ { \"browser_download_url\": \"${UPLOAD_URL}\", \"release_type\": \"${RELEASE_TYPE}\" } ] }}"
shell: bash

- name: Setup NPM auth token
if: ${{ inputs.npm }}
run: |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}
- name: Config Git
if: ${{ inputs.npm }}
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
- name: Update CHANGELOG.md
run: |
pnpm release ${{ inputs.version }} --ci --no-git.tag --no-github.release --npm.allowSameVersion
- name: Release and Publish
run: |
pnpm release ${{ steps.package-info.outputs.version }} --ci --npm.publish=${{ inputs.npm }} --github.update --github.assets=./packages/rtc/dist/${{ env.MY_PATH }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*.txt
*.pcm
coverage
**/coverage/*
*.log
sdk
tmp
Expand Down
6 changes: 6 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ----- BEGIN Agora AppId -----
[[rules]]
id = "agora-appid"
description = "Agora AppId"
regex = '''"[0-9a-f]{32}"'''
# ----- END Agora AppId -----
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/dist/*
**/coverage/*
**/node_modules/*
pnpm-lock.yaml
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# iris-web-rtc
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# iris_web

project srouce: [project/iris](/project/iris)
cross platform support in web

## build
## Environment Install

### Build for production
Run [build.sh](build.sh)
npm install -g pnpm

### Build for local dev
Run [build_local_dev.sh](build_local_dev.sh)
## QuickStart

pnpm start

this command can watch files and recompile whenever they change.

## Build

pnpm build

The output file will be placed in `packages/rtc/dist`

## installation of cross platform

prepare a [Live Server](https://github.com/ritwickdey/vscode-live-server-plus-plus)

add the `iris-web-rtc_x.x.x-x.x.js` to your html `srcipt`, e.g.,

Then add the `http://localhost:8080/lib-iris-web.js` to your html `srcipt`, e.g.,
```html
<script src="http://localhost:8080/lib-iris-web.js" type="application/javascript"></script>
<script
src="http://127.0.0.1:5500/lib-iris-web.js"
type="application/javascript"
></script>
```

## License
Expand Down
14 changes: 0 additions & 14 deletions build.sh

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"private": true,
"description": "iris web",
"scripts": {
"build": "pnpm -r run build",
"test": "pnpm -r run test",
"build": "pnpm -F iris-web-rtc run build",
"test": "pnpm -F iris-web-rtc run test",
"lint": "eslint --ext .ts,.tsx . && prettier --check .",
"lint:fix": "eslint --fix --ext .ts,.tsx . && prettier --write .",
"terra": "pnpm -F terra-generate run terra",
"start": "sh ./build_local_dev.sh"
"start": "sh ./scripts/build_local_dev.sh"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
2 changes: 1 addition & 1 deletion packages/rtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iris-web-rtc",
"version": "0.1.0",
"version": "0.1.1-dev.1",
"description": "wait",
"main": "./src/index.ts",
"scripts": {
Expand Down
3 changes: 0 additions & 3 deletions packages/rtc/src/engine/IrisRtcEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { IrisElement } from '../helper/DomHelper';
import { ImplHelper } from '../helper/ImplHelper';
import { TrackHelper } from '../helper/TrackHelper';
import { IrisGlobalState } from '../state/IrisGlobalState';
import { AgoraActionQueue } from '../util/AgoraActionQueue';
import { AgoraConsole } from '../util/AgoraConsole';
import IrisRtcErrorHandler from '../util/ErrorHandler';

Expand Down Expand Up @@ -74,7 +73,6 @@ export class IrisRtcEngine implements ApiInterceptor {

public globalState: IrisGlobalState = null;
public agoraEventHandler: IrisAgoraEventHandler = null;
public actionQueue: AgoraActionQueue = null;
public executor: CallApiExecutor = null;
public irisEventHandlerManager: IrisEventHandlerManager = null;
public irisElement: IrisElement = null;
Expand Down Expand Up @@ -111,7 +109,6 @@ export class IrisRtcEngine implements ApiInterceptor {
this.implDispatchesMap.set(key, value)
);

this.actionQueue = new AgoraActionQueue();
this.rtcEngineEventHandler = new IRtcEngineEventHandlerEx(this);
this.globalState = new IrisGlobalState();
this.irisElement = new IrisElement();
Expand Down
35 changes: 0 additions & 35 deletions packages/rtc/src/util/AgoraActionQueue.ts

This file was deleted.

Loading

0 comments on commit 7309c47

Please sign in to comment.