Skip to content

Commit 947c020

Browse files
authored
Merge pull request #21 from Dushistov/github-actions
Migrate to github actions
2 parents 01aab33 + d62d922 commit 947c020

File tree

3 files changed

+147
-84
lines changed

3 files changed

+147
-84
lines changed

.github/workflows/main.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
- cron: '00 01 * * *'
12+
env:
13+
RUST_BACKTRACE: 1
14+
jobs:
15+
test:
16+
name: Test
17+
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
22+
matrix:
23+
os: [ubuntu-latest, macos-latest]
24+
rust: [stable, beta]
25+
env:
26+
RUSTUP_MAX_RETRIES: 10
27+
CARGO_NET_RETRY: 10
28+
steps:
29+
30+
- uses: actions/checkout@v2
31+
with:
32+
submodules: 'recursive'
33+
34+
# We need to disable the existing toolchain to avoid updating rust-docs
35+
# which takes a long time. The fastest way to do this is to rename the
36+
# existing folder, as deleting it takes about as much time as not doing
37+
# anything and just updating rust-docs.
38+
- name: Rename existing rust toolchain (Windows)
39+
if: matrix.os == 'windows-latest'
40+
run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
41+
42+
- name: Install Rust toolchain
43+
uses: actions-rs/toolchain@v1
44+
with:
45+
toolchain: ${{ matrix.rust }}
46+
profile: minimal
47+
override: true
48+
- uses: actions/setup-python@v2
49+
with:
50+
python-version: '3.8.2'
51+
- uses: jwlawson/actions-setup-cmake@v1.0
52+
with:
53+
cmake-version: '3.9.6'
54+
github-api-token: ${{ secrets.GITHUB_TOKEN }}
55+
- name: Check versions
56+
run: |
57+
set -e
58+
cargo --version
59+
rustc --version
60+
python --version
61+
cmake --version
62+
echo "end of versions checking"
63+
shell: bash
64+
- name: Run tests
65+
run: |
66+
set -e
67+
cd $GITHUB_WORKSPACE
68+
python ci/build_and_run_tests.py
69+
shell: bash
70+
# Detect cases where documentation links don't resolve and such.
71+
doc:
72+
name: Docs
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v2
76+
with:
77+
submodules: 'recursive'
78+
- uses: actions-rs/toolchain@v1
79+
with:
80+
profile: minimal
81+
# Docs.rs uses nightly, which allows for easier syntax for linking to functions.
82+
toolchain: nightly
83+
override: true
84+
- uses: actions-rs/cargo@v1
85+
with:
86+
# Need to use `cargo rustdoc` to actually get it to respect -D
87+
# warnings... Note: this also requires nightly.
88+
command: rustdoc
89+
args: -p couchbase-lite -- -D warnings
90+
- uses: actions-rs/cargo@v1
91+
with:
92+
command: rustdoc
93+
args: -p couchbase-lite-core-sys -- -D warnings

azure-pipelines.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

ci/build_and_run_tests.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# For simplify migration between different CI
3+
4+
import os, time, sys
5+
from pathlib import Path
6+
from subprocess import check_call
7+
from multiprocessing import cpu_count
8+
9+
def show_timing(function):
10+
def _wrapper(*args, **kwargs):
11+
start = time.time()
12+
ret = function(*args, **kwargs)
13+
elapsed = (time.time() - start)
14+
print("%s elapsed time: %f" % (function.__name__, elapsed))
15+
return ret
16+
return _wrapper
17+
18+
def mkdir_if_not_exists(dir_path: str):
19+
if not os.path.exists(dir_path):
20+
os.makedirs(dir_path)
21+
22+
def get_src_root_path(my_path: str) -> str:
23+
my_path = os.path.dirname(os.path.realpath(my_path))
24+
return my_path
25+
26+
@show_timing
27+
def build_and_test_cpp_part(src_root: str):
28+
cmake_build_dir = os.path.join(src_root, "build-cmake")
29+
cmake_src_dir = os.path.join(src_root, "couchbase-lite-core-sys",
30+
"couchbase-lite-core")
31+
mkdir_if_not_exists(cmake_build_dir)
32+
print("Current path: %s" % os.environ["PATH"])
33+
check_call(["cmake", "-DCMAKE_BUILD_TYPE=RelWithDebInfo", cmake_src_dir],
34+
cwd = cmake_build_dir)
35+
check_call(["ls"], cwd = cmake_build_dir)
36+
check_call(["cmake", "--build", ".", "--", "-j%d" % (cpu_count() + 1)],
37+
cwd = cmake_build_dir)
38+
39+
@show_timing
40+
def build_and_test_rust_part(src_root: str):
41+
print("running tests in debug mode")
42+
check_call(["cargo", "test", "--all", "-vv"], cwd = src_root)
43+
print("running tests in release mode")
44+
check_call(["cargo", "test", "--all", "--release", "-vv"], cwd = src_root)
45+
46+
@show_timing
47+
def main():
48+
ci_dir = Path(get_src_root_path(sys.argv[0]))
49+
src_root = ci_dir.parent
50+
build_and_test_cpp_part(src_root)
51+
build_and_test_rust_part(src_root)
52+
53+
if __name__ == "__main__":
54+
main()

0 commit comments

Comments
 (0)