You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2022/10/18 03:17:31 UTC

[incubator-teaclave] 02/02: Improve CI

This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 599460fea1dc826fab382c77cb40fa82e28f010f
Author: He Sun <su...@baidu.com>
AuthorDate: Thu Sep 22 10:53:01 2022 +0800

    Improve CI
    
    1. Run tests in a fine-grained way for performance
    2. Move the tvm example to test.sh
    3. Only run tests in ubuntu20.04 docker image regularly
    4. Update codeql and runner image
---
 .github/workflows/ci.yml                           | 107 ++---------------
 .github/workflows/codeql-analysis.yml              |   9 +-
 .../{codeql-analysis.yml => ubuntu1804-test.yml}   |  61 ++++------
 .github/workflows/ubuntu2004-test.yml              | 126 +++++++++++++++++++++
 cmake/scripts/build_in_ci.sh                       |  33 ++++++
 cmake/scripts/test.sh                              |  10 +-
 6 files changed, 206 insertions(+), 140 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2ca637a7..d075cf55 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,7 +16,7 @@
 # under the License.
 
 name: CI
-on: [push, pull_request]
+on: [push, pull_request, workflow_dispatch]
 defaults:
   run:
     shell: bash
@@ -43,84 +43,8 @@ jobs:
           cargo build --manifest-path sdk/rust/Cargo.toml --target aarch64-apple-ios
           cargo lipo --manifest-path sdk/rust/Cargo.toml
           cd sdk/swift/TeaclaveClientSDK && xcodebuild -scheme TeaclaveClientSDK
-  sim-debug-ubuntu-1804:
-    runs-on: ubuntu-18.04
-    container: teaclave/teaclave-build-ubuntu-1804-sgx-2.14:0.1.5
-    steps:
-      - uses: actions/checkout@v2
-      - name: Setting up $HOME
-        run: |
-          cp /root/.bashrc $HOME/.bashrc &&
-          ln -sf /root/.rustup ~/.rustup &&
-          ln -sf /root/.cargo ~/.cargo
-      - name: Preparing build system
-        run: |
-          . ~/.cargo/env &&
-          . /opt/sgxsdk/environment &&
-          mkdir -p build &&
-          cd build &&
-          cmake -DCMAKE_BUILD_TYPE=Debug -DSGX_SIM_MODE=ON -DTEST_MODE=ON ..
-      - name: Building
-        run: |
-          . /opt/sgxsdk/environment &&
-          . ~/.cargo/env &&
-          cd build &&
-          make VERBOSE=1
-      - name: Build TVM example
-        run: |
-          . ~/.cargo/env &&
-          cd ${GITHUB_WORKSPACE}/examples/python/wasm_tvm_mnist_payload &&
-          make
-      - name: Run tests and examples
-        run: |
-          export AS_SPID="00000000000000000000000000000000" &&
-          export AS_KEY="00000000000000000000000000000000" &&
-          export AS_ALGO="sgx_epid" &&
-          export AS_URL="https://api.trustedservices.intel.com:443" &&
-          . ~/.cargo/env &&
-          cd build &&
-          make run-tests
-
-  sim-debug-ubuntu-2004:
-    runs-on: ubuntu-20.04
-    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
-    steps:
-      - uses: actions/checkout@v2
-      - name: Setting up $HOME
-        run: |
-          cp /root/.bashrc $HOME/.bashrc &&
-          ln -sf /root/.rustup ~/.rustup &&
-          ln -sf /root/.cargo ~/.cargo
-      - name: Preparing build system
-        run: |
-          . ~/.cargo/env &&
-          . /opt/sgxsdk/environment &&
-          mkdir -p build &&
-          cd build &&
-          cmake -DCMAKE_BUILD_TYPE=Debug -DSGX_SIM_MODE=ON -DTEST_MODE=ON ..
-      - name: Building
-        run: |
-          . /opt/sgxsdk/environment &&
-          . ~/.cargo/env &&
-          cd build &&
-          make VERBOSE=1
-      - name: Build TVM example
-        run: |
-          . ~/.cargo/env &&
-          cd ${GITHUB_WORKSPACE}/examples/python/wasm_tvm_mnist_payload &&
-          make
-      - name: Run tests and examples
-        run: |
-          export AS_SPID="00000000000000000000000000000000" &&
-          export AS_KEY="00000000000000000000000000000000" &&
-          export AS_ALGO="sgx_epid" &&
-          export AS_URL="https://api.trustedservices.intel.com:443" &&
-          . ~/.cargo/env &&
-          cd build &&
-          make run-tests
-
   format:
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     container: teaclave/teaclave-build-ubuntu-1804-sgx-2.14:0.1.5
     steps:
       - uses: actions/checkout@v2
@@ -129,19 +53,15 @@ jobs:
           cp /root/.bashrc $HOME/.bashrc &&
           ln -sf /root/.rustup ~/.rustup &&
           ln -sf /root/.cargo ~/.cargo
-      - name: Preparing build system
-        run: |
-          . ~/.cargo/env &&
-          . /opt/sgxsdk/environment &&
-          mkdir -p build &&
-          cd build &&
-          cmake -DRUSTFLAGS="-D warnings" -DTEST_MODE=ON ..
       - name: Checking code format
         run: |
           . /root/.cargo/env &&
-          cd build && make check
+          . /opt/sgxsdk/environment &&
+          mkdir -p build && cd build &&
+          cmake -DRUSTFLAGS="-D warnings" -DTEST_MODE=ON .. &&
+          make check
   lint:
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     container: teaclave/teaclave-build-ubuntu-1804-sgx-2.14:0.1.5
     steps:
       - uses: actions/checkout@v2
@@ -150,20 +70,15 @@ jobs:
           cp /root/.bashrc $HOME/.bashrc &&
           ln -sf /root/.rustup ~/.rustup &&
           ln -sf /root/.cargo ~/.cargo
-      - name: Preparing build system
-        run: |
-          . ~/.cargo/env &&
-          . /opt/sgxsdk/environment &&
-          mkdir -p build &&
-          cd build &&
-          cmake -DRUSTFLAGS="-D warnings" -DTEST_MODE=ON ..
       - name: Code linting with Clippy
         run: |
           . /opt/sgxsdk/environment &&
           . /root/.cargo/env &&
-          cd build && make CLP=1
+          mkdir -p build && cd build &&
+          cmake -DRUSTFLAGS="-D warnings" -DTEST_MODE=ON .. &&
+          CLP=1 make -j
   license:
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     steps:
       - uses: actions/checkout@v2
       - name: Check License Header
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index b9c5ff02..b6723b0d 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -22,6 +22,7 @@ on:
   pull_request:
   schedule:
     - cron: '36 22 * * 3'
+  workflow_dispatch:
 
 jobs:
   analyze-cpp:
@@ -35,7 +36,7 @@ jobs:
         submodules: 'true'
 
     - name: Initialize CodeQL
-      uses: github/codeql-action/init@v1
+      uses: github/codeql-action/init@v2
       with:
         languages: cpp
 
@@ -43,7 +44,7 @@ jobs:
       run: cd examples/c && make
 
     - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
+      uses: github/codeql-action/analyze@v2
 
   analyze-python:
     name: Analyze python
@@ -54,9 +55,9 @@ jobs:
       uses: actions/checkout@v2
 
     - name: Initialize CodeQL
-      uses: github/codeql-action/init@v1
+      uses: github/codeql-action/init@v2
       with:
         languages: python
 
     - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
+      uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/ubuntu1804-test.yml
similarity index 51%
copy from .github/workflows/codeql-analysis.yml
copy to .github/workflows/ubuntu1804-test.yml
index b9c5ff02..c691f31a 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/ubuntu1804-test.yml
@@ -15,48 +15,31 @@
 # specific language governing permissions and limitations
 # under the License.
 
-name: "Code scanning"
-
+name: Test-ubuntu-18.04
 on:
-  push:
-  pull_request:
   schedule:
     - cron: '36 22 * * 3'
+  workflow_dispatch:
 
-jobs:
-  analyze-cpp:
-    name: Analyze cpp
-    runs-on: ubuntu-latest
-
-    steps:
-    - name: Checkout repository
-      uses: actions/checkout@v2
-      with:
-        submodules: 'true'
-
-    - name: Initialize CodeQL
-      uses: github/codeql-action/init@v1
-      with:
-        languages: cpp
-
-    - name: Build C projects
-      run: cd examples/c && make
-
-    - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
-
-  analyze-python:
-    name: Analyze python
-    runs-on: ubuntu-latest
+defaults:
+  run:
+    shell: bash
 
+jobs:
+  sim-debug-all:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-1804-sgx-2.14:0.1.5
     steps:
-    - name: Checkout repository
-      uses: actions/checkout@v2
-
-    - name: Initialize CodeQL
-      uses: github/codeql-action/init@v1
-      with:
-        languages: python
-
-    - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run tests and examples
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-tests
diff --git a/.github/workflows/ubuntu2004-test.yml b/.github/workflows/ubuntu2004-test.yml
new file mode 100644
index 00000000..22780fb7
--- /dev/null
+++ b/.github/workflows/ubuntu2004-test.yml
@@ -0,0 +1,126 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Test-ubuntu-20.04
+on: [push, pull_request, workflow_dispatch]
+defaults:
+  run:
+    shell: bash
+
+jobs:
+  sim-debug-unit:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run unit test
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-unit-tests
+  sim-debug-integration:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run integration test
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-integration-tests
+  sim-debug-functional:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run functional tests
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-functional-tests
+  sim-debug-sdk:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run sdk test
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-sdk-tests
+  sim-debug-example:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run examples
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-examples
+  sim-debug-cancel:
+    runs-on: ubuntu-20.04
+    container: teaclave/teaclave-build-ubuntu-2004-sgx-2.15.1:0.1.3
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build
+        run: |
+          . cmake/scripts/build_in_ci.sh
+      - name: Run cancel test
+        run: |
+          export AS_SPID="00000000000000000000000000000000" &&
+          export AS_KEY="00000000000000000000000000000000" &&
+          export AS_ALGO="sgx_epid" &&
+          export AS_URL="https://api.trustedservices.intel.com:443" &&
+          . ~/.cargo/env &&
+          cd build &&
+          make run-cancel-test
diff --git a/cmake/scripts/build_in_ci.sh b/cmake/scripts/build_in_ci.sh
new file mode 100755
index 00000000..bba67e07
--- /dev/null
+++ b/cmake/scripts/build_in_ci.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+# Setting up $HOME
+cp /root/.bashrc $HOME/.bashrc
+ln -sf /root/.rustup ~/.rustup
+ln -sf /root/.cargo ~/.cargo
+
+# Build
+. /opt/sgxsdk/environment &&
+. ~/.cargo/env &&
+mkdir -p build &&
+cd build &&
+cmake -DCMAKE_BUILD_TYPE=Debug -DSGX_SIM_MODE=ON -DTEST_MODE=ON .. &&
+VERBOSE=1 make -j
diff --git a/cmake/scripts/test.sh b/cmake/scripts/test.sh
index a8a57472..39c197a2 100755
--- a/cmake/scripts/test.sh
+++ b/cmake/scripts/test.sh
@@ -43,6 +43,7 @@ echo_title() {
 
 start_storage_server() {
   python3 ${TEACLAVE_PROJECT_ROOT}/tests/scripts/simple_http_server.py 6789 &
+  wait_port 6789
 }
 
 run_unit_tests() {
@@ -235,6 +236,13 @@ run_examples() {
   make
   popd
 
+  rust_toolchain=${RUSTUP_TOOLCHAIN}
+  unset RUSTUP_TOOLCHAIN
+  pushd ${TEACLAVE_PROJECT_ROOT}/examples/python/wasm_tvm_mnist_payload
+  make
+  popd
+  export RUSTUP_TOOLCHAIN=${rust_toolchain}
+
   pushd ${TEACLAVE_PROJECT_ROOT}/examples/python
   export PYTHONPATH=${TEACLAVE_PROJECT_ROOT}/sdk/python
   python3 builtin_echo.py
@@ -266,7 +274,7 @@ run_examples() {
   RUSTFLAGS=${RUSTFLAGS} cargo run
   popd
   popd
-  
+
   # kill all background services
   cleanup
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org