From d1e9ed12f1bef2020680fe09904aaff5f5dfb1f4 Mon Sep 17 00:00:00 2001 From: "Zheng, Qi" Date: Mon, 27 Sep 2021 11:13:19 +0800 Subject: [PATCH] Add code coverage action test Signed-off-by: Zheng, Qi --- .github/workflows/code_coverage.yaml | 50 +++++++++++++++++++ .github/workflows/hw_mode_test.yml | 74 ---------------------------- 2 files changed, 50 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/code_coverage.yaml diff --git a/.github/workflows/code_coverage.yaml b/.github/workflows/code_coverage.yaml new file mode 100644 index 00000000..b8bb5213 --- /dev/null +++ b/.github/workflows/code_coverage.yaml @@ -0,0 +1,50 @@ +name: Code Coverage + +# Controls when the action will run. Triggers the workflow on push or pull request +on: [push, pull_request] + +env: + nap_time: 60 + +jobs: + Collect-code-coverage: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Get Occlum version + run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV; + + - name: Create container + run: docker run -itd --name=code_coverage -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:${{ env.OCCLUM_VERSION }}-ubuntu18.04 + + - name: Change download source of crates.io + run: | + docker exec code_coverage bash -c "cat <<- EOF >/root/.cargo/config + [source.crates-io] + registry = \"https://github.com/rust-lang/crates.io-index\" + replace-with = 'ustc' + [source.ustc] + registry = \"git://mirrors.ustc.edu.cn/crates.io-index\" + EOF" + + - name: Build dependencies + run: docker exec code_coverage bash -c "cargo uninstall sccache || true; cd /root/occlum; make submodule" + + - name: Build source + run: docker exec code_coverage bash -c "source /opt/intel/sgxsdk/environment; cd /root/occlum; OCCLUM_COV=1 make install" + + - name: Integration test + run: docker exec code_coverage bash -c "cd /root/occlum; SGX_MODE=SIM make test" + + - name: Integration test with Glibc + run: docker exec code_coverage bash -c "cd /root/occlum; SGX_MODE=SIM make test-glibc" + + - name: Upload coverage report + run: docker exec code_coverage bash -c "cd /root/occlum/build/internal/src/libos/cargo-target/debug/deps; export CODECOV_TOKEN="${{ secrets.COV_TOKEN }}"; bash <(curl -s https://codecov.io/bash)" + + - name: Clean the environment + if: ${{ always() }} + run: docker stop code_coverage diff --git a/.github/workflows/hw_mode_test.yml b/.github/workflows/hw_mode_test.yml index c85bd902..c5bb9edd 100644 --- a/.github/workflows/hw_mode_test.yml +++ b/.github/workflows/hw_mode_test.yml @@ -10,80 +10,6 @@ env: nap_time: 60 jobs: - Collect-code-coverage: - if: github.event_name == 'push' || ${{ contains(github.event.pull_request.labels.*.name, 'SGX-hardware-test-required') }} - runs-on: ${{ matrix.self_runner }} - strategy: - matrix: - self_runner: [[self-hosted, SGX1-HW], [self-hosted, SGX2-HW]] - - steps: - - name: Clean before running - run: | - sudo chown -R ${{ secrets.CI_ADMIN }} "${{ github.workspace }}" - - - name: Checkout code - if: github.event_name == 'push' - uses: actions/checkout@v2 - with: - submodules: true - - - name: Checkout code from fork - # This step is only needed when the pull request is labeled. - if: ${{ contains(github.event.pull_request.labels.*.name, 'SGX-hardware-test-required') }} - uses: actions/checkout@v2 - with: - # For pull request, we need to merge the commit from fork to the base - ref: refs/pull/${{ github.event.pull_request.number }}/merge - submodules: true - - - name: Get Occlum version - run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV; - - - name: Create container - run: | - if [[ "${{ matrix.self_runner[1] }}" == "SGX1-HW" ]]; then - occlum_test=$(docker run -itd --privileged --rm --env CARGO_HTTP_MULTIPLEXING=false --net host --device /dev/isgx -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:$OCCLUM_VERSION-ubuntu18.04); - elif [[ "${{ matrix.self_runner[1] }}" == "SGX2-HW" ]]; then - occlum_test=$(docker run -itd --privileged --rm --env CARGO_HTTP_MULTIPLEXING=false --net host -v /dev/sgx:/dev/sgx -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:$OCCLUM_VERSION-ubuntu18.04); - else - echo "Unsupported Hardware" - fi; - echo "occlum_test=$occlum_test" >> $GITHUB_ENV - - - name: Update PCCS server - run: docker exec $occlum_test bash -c "sed -r -i 's/PCCS_URL=https:\/\/localhost:8081\/sgx\/certification\/v3\//PCCS_URL=https:\/\/sgx-dcap-server.cn-shanghai.aliyuncs.com\/sgx\/certification\/v3\//g' /etc/sgx_default_qcnl.conf" - - - name: Change download source of crates.io - run: | - docker exec $occlum_test bash -c "cat <<- EOF >/root/.cargo/config - [source.crates-io] - registry = \"https://github.com/rust-lang/crates.io-index\" - replace-with = 'ustc' - [source.ustc] - registry = \"git://mirrors.ustc.edu.cn/crates.io-index\" - EOF" - - - name: Build dependencies - run: docker exec $occlum_test bash -c "cargo uninstall sccache || true; cd /root/occlum; make submodule" - - - name: Build source - run: docker exec $occlum_test bash -c "source /opt/intel/sgxsdk/environment; cd /root/occlum; OCCLUM_COV=1 make install" - - - name: Integration test - run: docker exec $occlum_test bash -c "cd /root/occlum; make test" - - - name: Integration test with Glibc - run: docker exec $occlum_test bash -c "cd /root/occlum; make test-glibc" - - - name: Upload coverage report - run: docker exec $occlum_test bash -c "cd /root/occlum/build/internal/src/libos/cargo-target/debug/deps; export CODECOV_TOKEN="${{ secrets.COV_TOKEN }}"; bash <(curl -s https://codecov.io/bash)" - - - name: Clean the environment - if: ${{ always() }} - run: docker stop $occlum_test - - Make-test-on-ubuntu: if: github.event_name == 'push' || ${{ contains(github.event.pull_request.labels.*.name, 'SGX-hardware-test-required') }} runs-on: ${{ matrix.self_runner }}