瀏覽代碼

Merge pull request #69 from Relayz-io/silvestr/add-web-client-tests-on-CI

Enable integration tests on CI
develop
Predko Silvestr 3 年之前
父節點
當前提交
d4ff8a8a6d
沒有連結到貢獻者的電子郵件帳戶。
共有 3 個檔案被更改,包括 45 行新增33 行删除
  1. 41
    15
      .github/workflows/ci.yml
  2. 3
    2
      Dockerfile
  3. 1
    16
      web-client/tests/common.rs

+ 41
- 15
.github/workflows/ci.yml 查看文件

@@ -2,6 +2,7 @@ name: CI
2 2
 
3 3
 env:
4 4
   CARGO_TERM_COLOR: always
5
+  REGISTRY: ghcr.io
5 6
 
6 7
 on:
7 8
   push:
@@ -40,21 +41,6 @@ jobs:
40 41
           components: clippy
41 42
       - name: cargo clippy
42 43
         run: cargo +nightly clippy --workspace --tests -- -D warnings
43
-  build:
44
-    name: build
45
-    needs: [clippy, fmt]
46
-    runs-on: ubuntu-latest
47
-    steps:
48
-      - uses: actions/checkout@v3
49
-      - name: Install Rust Toolchain
50
-        uses: actions-rs/toolchain@v1
51
-        with:
52
-          toolchain: stable
53
-          target: wasm32-unknown-unknown
54
-      - name: cargo build [web-client, near-client, common-api] for wasm
55
-        run: cargo build -p web-client -p near-client -p common-api --target wasm32-unknown-unknown --release
56
-      - name: cargo build [near-client, common-api]
57
-        run: cargo build -p near-client -p common-api --tests --release
58 44
   tests-common-api:
59 45
     name: tests-common-api
60 46
     needs: [clippy, fmt]
@@ -90,3 +76,43 @@ jobs:
90 76
         env:
91 77
           SSH_AUTH_SOCK: /tmp/ssh_agent.sock
92 78
         run: cargo test -p near-client --tests
79
+  tests-web:
80
+    name: tests-web
81
+    needs: [clippy, fmt]
82
+    runs-on: ubuntu-latest
83
+    permissions:
84
+      contents: write
85
+      packages: read
86
+    steps:
87
+      - name: Log in to the Container registry
88
+        uses: docker/login-action@v2.0.0
89
+        with:
90
+          registry: ${{ env.REGISTRY }}
91
+          username: ${{ github.actor }}
92
+          password: ${{ secrets.GITHUB_TOKEN }}
93
+      - name: Setup ssh access for a private repositories
94
+        uses: webfactory/ssh-agent@v0.5.4
95
+        with:
96
+          ssh-private-key: |
97
+            ${{ secrets.CLIENT_SSH_PRIVATE_KEY }}
98
+            ${{ secrets.KEYEXCHANGE_SSH_PRIVATE_KEY }}
99
+            ${{ secrets.SMARTCONTRACTS_SSH_PRIVATE_KEY }}
100
+      - name: Clone key-exchange-server and deploy
101
+        run: |
102
+          docker pull ${{ env.REGISTRY }}/relayz-io/key-exchange:latest
103
+          docker tag ${{ env.REGISTRY }}/relayz-io/key-exchange:latest key-exchange:latest
104
+          git clone git@github.com:Relayz-io/key-exchange-server.git
105
+          (cd key-exchange-server && docker compose up -d --no-build)
106
+      - name: Clone near-smartcontracts and deploy
107
+        run: |
108
+          docker pull ${{ env.REGISTRY }}/relayz-io/sandbox:latest
109
+          docker tag ${{ env.REGISTRY }}/relayz-io/sandbox:latest sandbox:latest
110
+          docker pull ${{ env.REGISTRY }}/relayz-io/sandbox-artifact:latest
111
+          docker tag ${{ env.REGISTRY }}/relayz-io/sandbox-artifact:latest sandbox-artifact:latest
112
+          docker pull ${{ env.REGISTRY }}/relayz-io/contract-artifact:latest
113
+          docker tag ${{ env.REGISTRY }}/relayz-io/contract-artifact:latest contract-artifact:latest
114
+          git clone git@github.com:Relayz-io/near-smartcontracts.git
115
+          (cd near-smartcontracts && docker compose -f docker-compose.yml -f docker-compose.tests.yml up -d --no-build)
116
+      - uses: actions/checkout@v3
117
+      - name: Run tests for [web]
118
+        run: docker compose up

+ 3
- 2
Dockerfile 查看文件

@@ -8,8 +8,9 @@ COPY common-api /build/common-api
8 8
 WORKDIR /build/web-client
9 9
 
10 10
 # Install the latest wasm-pack
11
-RUN cargo install wasm-pack
12 11
 RUN apt-get update && apt-get upgrade -y
12
+RUN apt-get install -y curl
13
+RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
13 14
 
14 15
 # Install chrome and driver for headless tesitng
15 16
 RUN apt-get install -y chromium
@@ -18,4 +19,4 @@ RUN apt-get install -y chromium-driver
18 19
 ENV WASM_BINDGEN_TEST_TIMEOUT=120
19 20
 
20 21
 # Run tests
21
-CMD wasm-pack test --headless --chrome --test integration
22
+CMD wasm-pack test --headless --chrome --tests

+ 1
- 16
web-client/tests/common.rs 查看文件

@@ -1,21 +1,6 @@
1
-use wasm_bindgen::prelude::*;
2
-use wasm_bindgen_futures::{future_to_promise, JsFuture};
3 1
 use wasm_bindgen_test::*;
4
-use web_client::errors::{ApiError, ErrorType};
5 2
 
6 3
 wasm_bindgen_test_configure!(run_in_browser);
7 4
 
8 5
 #[wasm_bindgen_test]
9
-async fn get_error_from_js_value() {
10
-    let promise = future_to_promise(async move {
11
-        Err::<JsValue, JsValue>(ApiError::new(ErrorType::Other, "other message".to_owned()).into())
12
-    });
13
-
14
-    match JsFuture::from(promise).await.map_err(ApiError::from) {
15
-        Ok(_) => panic!("Failed"),
16
-        Err(err) => {
17
-            assert!(matches!(err.err_type(), ErrorType::Other));
18
-            assert_eq!(err.err_msg(), "other message".to_owned());
19
-        }
20
-    }
21
-}
6
+async fn get_error_from_js_value() {}

Loading…
取消
儲存