Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: SDK CI #2

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

version: 2.1

setup: true

orbs:
path-filtering: circleci/[email protected]
continuation: circleci/[email protected]

parameters:
GHA_Actor:
type: string
Expand Down Expand Up @@ -91,6 +97,20 @@ jobs:
--tag "${remote_image}" \
-f ./build/Dockerfiles/dataproxy.Dockerfile . \
--push
lint:
# Use machine executor for convenient data sharing between the host and docker-compose cluster
docker:
- image: secretflow/lint-ci:latest
resource_class: medium
shell: /bin/bash --login -eo pipefail
steps:
- checkout
- run:
name: Checkout devtools
command: git clone https://github.com/secretflow/devtools.git ../devtools
- run:
name: Whitespace check
command: bash ../devtools/lint-whitespace.sh

workflows:
build-deploy:
Expand All @@ -100,4 +120,20 @@ workflows:
tags:
only: /^v.*/
branches:
ignore: /.*/
ignore: /.*/
unittest-workflow:
when:
and:
- not: << pipeline.parameters.GHA_Event >>
- not: << pipeline.parameters.GHA_Action >>
- not: << pipeline.parameters.GHA_Meta >>
jobs:
- path-filtering/filter:
base-revision: main
config-path: .circleci/continue-config.yml
mapping: |
.circleci/continue-config.yml sdk-build-and-run true
dataproxy_sdk/.* sdk-build-and-run true
.bazelrc sdk-build-and-run true
WORKSPACE sdk-build-and-run true
- lint
103 changes: 103 additions & 0 deletions .circleci/continue-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright 2024 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.

version: 2.1

parameters:
sdk-build-and-run:
type: boolean
default: false

commands:
sdk_build_and_test:
parameters:
bazel_targets:
type: string
default: "//dataproxy_sdk/..."
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}"
- run:
name: Checkout devtools
command: git clone https://github.com/secretflow/devtools.git ../devtools
- run:
name: Setup GCS
command: |
echo ${gcs_content} > ../gcs.data
../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
- run:
name: "build"
command: |
bazel build <<parameters.bazel_targets>> -c opt
- run:
name: "test"
command: |
set +e
declare -i test_status
bazel test <<parameters.bazel_targets>> -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors | tee test_result.log; test_status=${PIPESTATUS[0]}

sh ../devtools/rename-junit-xml.sh
find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz

exit ${test_status}
- store_test_results:
path: test-results
- store_artifacts:
path: test_logs.tar.gz

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
sdk_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: secretflow/ubuntu-base-ci:latest
parameters:
resource_class:
type: string
resource_class: << parameters.resource_class >>
shell: /bin/bash --login -eo pipefail
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- sdk_build_and_test

sdk_macOS_ut:
macos:
xcode: 15.1.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
name: "Install homebrew dependencies"
command: brew install bazelisk cmake ninja libomp wget go md5sha1sum
- sdk_build_and_test

workflows:
unittest:
when: << pipeline.parameters.sdk-build-and-run >>
jobs:
- sdk_linux_ut:
matrix:
parameters:
resource_class: ["xlarge", "arm.xlarge"]
- sdk_macOS_ut
Loading