diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..1de83e18 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,140 @@ +# Copyright 2023 Ant Group Co., Ltd. +# +# Licensed 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. + +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/2.0/configuration-reference/#jobs +jobs: + linux_ut: + # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor + docker: + - image: registry.hub.docker.com/secretflow/scql-ci:0.3 + resource_class: 2xlarge + # Add steps to the job + # See: https://circleci.com/docs/2.0/configuration-reference/#steps + steps: + # Kill the whole ci after 1hr + - run: + name: Cancel build after set time + background: true + command: | + sleep 3600 + echo "Canceling workflow as too much time has elapsed" + curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${BUILD_TIMER_TOKEN}" + - checkout + - restore_cache: + name: "Restore build cache" + key: scql-build-comp-{{ arch }}- + - run: + name: "build" + command: bazel build //engine/... -c opt --ui_event_filters=-info,-debug,-warning --disk_cache=~/.cache/scql_build_cache + - run: + name: "Engine Test" + command: | + set +e + declare -i test_status + bazel test //engine/... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors --disk_cache=~/.cache/scql_build_cache | tee test_result.log; test_status=${PIPESTATUS[0]} + sh .ci/rename-junit-xml.sh + find bazel-bin/ -executable -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz + find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz + exit ${test_status} + - run: + name: "SCDB Test" + command: | + set +e + mkdir -p $WORKSPACE/result + make + go mod tidy + go test -timeout=30m -v -coverprofile cover.out ./... | tee $WORKSPACE/result/test.log + cat $WORKSPACE/result/test.log | go-junit-report > $WORKSPACE/result/TEST-all.xml # --> junit-report + go tool cover -html=cover.out -o $WORKSPACE/result/coverage.html + go tool cover -func=cover.out -o $WORKSPACE/result/func.out + cat cover.out | gocover-cobertura > $WORKSPACE/result/cover.xml + echo test func-coverage $(tail -1 $WORKSPACE/result/func.out | awk '{print $3}') + - save_cache: + key: scql-build-comp-{{ arch }}-{{ .Environment.CIRCLE_BUILD_NUM }} + paths: + - /root/.cache/scql_build_cache + when: always + - store_test_results: + path: test-results + - store_artifacts: + path: test_binary.tar.gz + - store_artifacts: + path: test_logs.tar.gz + macOS_ut: + macos: + xcode: 14.2 + environment: + HOMEBREW_NO_AUTO_UPDATE: 1 + resource_class: macos.m1.large.gen1 + steps: + - checkout + - restore_cache: + name: "Restore build cache" + key: scql-build-comp-{{ arch }}- + - run: + name: "Install homebrew dependencies" + command: | + brew install bazel cmake ninja libomp wget go md5sha1sum + (cd /opt/homebrew/Cellar/bazel/*.*.*/libexec/bin && curl -fLO https://github.com/bazelbuild/bazel/releases/download/5.4.0/bazel-5.4.0-darwin-arm64 && chmod +x bazel-5.4.0-darwin-arm64) + - run: + name: "build" + command: bazel build //engine/... -c opt --ui_event_filters=-info,-debug,-warning --disk_cache=~/.cache/scql_build_cache + - run: + name: "Engine Test" + command: | + set +e + declare -i test_status + bazel test //engine/... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors --disk_cache=~/.cache/scql_build_cache | tee test_result.log; test_status=${PIPESTATUS[0]} + sh .ci/rename-junit-xml.sh + find bazel-bin/ -perm +111 -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz + find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz + exit ${test_status} + - run: + name: "SCDB Test" + command: | + set +e + mkdir -p $WORKSPACE/result + make + go mod tidy + go test -timeout=30m -v -coverprofile cover.out ./... | tee $WORKSPACE/result/test.log + cat $WORKSPACE/result/test.log | go-junit-report > $WORKSPACE/result/TEST-all.xml # --> junit-report + go tool cover -html=cover.out -o $WORKSPACE/result/coverage.html + go tool cover -func=cover.out -o $WORKSPACE/result/func.out + cat cover.out | gocover-cobertura > $WORKSPACE/result/cover.xml + echo test func-coverage $(tail -1 $WORKSPACE/result/func.out | awk '{print $3}') + - save_cache: + key: scql-build-comp-{{ arch }}-{{ .Environment.CIRCLE_BUILD_NUM }} + paths: + - ~/.cache/scql_build_cache + when: always + - store_test_results: + path: test-results + - store_artifacts: + path: test_binary.tar.gz + - store_artifacts: + path: test_logs.tar.gz + +# Invoke jobs via workflows +# See: https://circleci.com/docs/2.0/configuration-reference/#workflows +workflows: + ut: + jobs: + - linux_ut + - macOS_ut diff --git a/README.md b/README.md index 067c0096..5998371c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # SCQL +[![CircleCI](https://dl.circleci.com/status-badge/img/gh/secretflow/scql/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/secretflow/scql/tree/main) Secure Collaborative Query Language (SCQL) is a system that translates SQL statements into Secure Multiparty Computation (SMC) primitives and executes them on a federation of database systems.