Skip to content

Commit dd38076

Browse files
authored
ci: Bootstrap basic Rust CI (#13)
* ci: Bootstrap basic Rust CI Signed-off-by: tison <wander4096@gmail.com> * Address comments Signed-off-by: tison <wander4096@gmail.com> * Simplify find MSRV logic Signed-off-by: tison <wander4096@gmail.com> --------- Signed-off-by: tison <wander4096@gmail.com>
1 parent 44598b6 commit dd38076

File tree

16 files changed

+377
-76
lines changed

16 files changed

+377
-76
lines changed

.asf.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
root = true
19+
20+
[*]
21+
end_of_line = lf
22+
indent_style = space
23+
insert_final_newline = true
24+
trim_trailing_whitespace = true
25+
26+
[*.toml]
27+
indent_size = tab
28+
tab_width = 2

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one or more
32
# contributor license agreements. See the NOTICE file distributed with
43
# this work for additional information regarding copyright ownership.
@@ -13,7 +12,6 @@
1312
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1413
# See the License for the specific language governing permissions and
1514
# limitations under the License.
16-
#
1715

1816
# The default behavior, which overrides 'core.autocrlf', is to use Git's
1917
# built-in heuristics to determine whether a particular file is text or binary.

.github/semantic.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# The pull request's title should be fulfilled the following pattern:
19+
#
20+
# <type>[optional scope]: <description>
21+
#
22+
# ... where valid types and scopes can be found below; for example:
23+
#
24+
# build(maven): One level down for native profile
25+
#
26+
# More about configurations on https://github.com/Ezard/semantic-prs#configuration
27+
28+
enabled: true
29+
30+
titleOnly: true
31+
32+
types:
33+
- feat
34+
- fix
35+
- docs
36+
- style
37+
- refactor
38+
- perf
39+
- test
40+
- build
41+
- ci
42+
- chore
43+
- revert
44+
45+
targetUrl: https://github.com/apache/datasketches-rust/blob/main/.github/semantic.yml

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: CI
19+
on:
20+
pull_request:
21+
branches: [ main ]
22+
push:
23+
branches: [ main ]
24+
25+
# Concurrency strategy:
26+
# github.workflow: distinguish this workflow from others
27+
# github.event_name: distinguish `push` event from `pull_request` event
28+
# github.event.number: set to the number of the pull request if `pull_request` event
29+
# github.run_id: otherwise, it's a `push` event, only cancel if we rerun the workflow
30+
#
31+
# Reference:
32+
# https://docs.github.com/en/actions/using-jobs/using-concurrency
33+
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
36+
cancel-in-progress: true
37+
jobs:
38+
check:
39+
name: Check
40+
runs-on: ubuntu-24.04
41+
steps:
42+
- uses: actions/checkout@v6
43+
- name: Delete rust-toolchain.toml
44+
run: rm rust-toolchain.toml
45+
- name: Install toolchain
46+
uses: dtolnay/rust-toolchain@nightly
47+
with:
48+
components: rustfmt,clippy
49+
- uses: Swatinem/rust-cache@v2
50+
- uses: taiki-e/install-action@v2
51+
with:
52+
tool: typos-cli,taplo-cli,hawkeye
53+
- name: Check all
54+
run: |
55+
hawkeye check
56+
taplo format --check
57+
typos
58+
cargo +nightly fmt --all -- --check
59+
cargo +nightly clippy --all-targets --all-features -- -D warnings
60+
61+
msrv:
62+
name: Resolve MSRV
63+
runs-on: ubuntu-24.04
64+
outputs:
65+
rust-versions: ${{ steps.metadata.outputs.rust-versions }}
66+
steps:
67+
- uses: actions/checkout@v6
68+
- id: metadata
69+
run: |
70+
msrv=$(yq '.package.rust-version' Cargo.toml)
71+
echo "MSRV: $msrv"
72+
echo "rust-versions=[\"${msrv}\", \"stable\"]" >> "$GITHUB_OUTPUT"
73+
74+
test:
75+
name: Run tests
76+
needs: msrv
77+
strategy:
78+
matrix:
79+
os: [ ubuntu-24.04, macos-14, windows-2022 ]
80+
rust-version: ${{ fromJson(needs.msrv.outputs.rust-versions) }}
81+
runs-on: ${{ matrix.os }}
82+
steps:
83+
- uses: actions/checkout@v6
84+
- name: Delete rust-toolchain.toml
85+
run: rm rust-toolchain.toml
86+
- uses: Swatinem/rust-cache@v2
87+
- name: Install toolchain
88+
uses: dtolnay/rust-toolchain@master
89+
with:
90+
toolchain: ${{ matrix.rust-version }}
91+
- name: Build
92+
run: cargo build --workspace --all-features --bins --tests --examples --benches --lib
93+
- name: Run unit tests
94+
shell: bash
95+
run: cargo test --all-features -- --nocapture
96+
- name: Run examples
97+
shell: bash
98+
run: |
99+
set -x
100+
cargo run --example hll_usage
101+
102+
required:
103+
name: Required
104+
runs-on: ubuntu-24.04
105+
if: ${{ always() }}
106+
needs:
107+
- check
108+
- test
109+
steps:
110+
- name: Guardian
111+
run: |
112+
if [[ ! ( \
113+
"${{ needs.check.result }}" == "success" \
114+
&& "${{ needs.test.result }}" == "success" \
115+
) ]]; then
116+
echo "Required jobs haven't been completed successfully."
117+
exit -1
118+
fi

.gitignore

Lines changed: 19 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,38 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
18
#
2-
# Licensed to the Apache Software Foundation (ASF) under one or more
3-
# contributor license agreements. See the NOTICE file distributed with
4-
# this work for additional information regarding copyright ownership.
5-
# The ASF licenses this file to You under the Apache License, Version 2.0
6-
# (the "License"); you may not use this file except in compliance with
7-
# the License. You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
9+
# http://www.apache.org/licenses/LICENSE-2.0
1610
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
1717

1818
# Eclipse project files
1919
.classpath
2020
.project
21-
.settings/
21+
.settings
2222
.checkstyle
2323

2424
# IntelliJ project files
25-
*.idea
25+
.idea
2626
**/*.iml
2727
*.ipr
2828
*.iws
2929

3030
# VSCode project files
31-
**/.vscode/
32-
33-
# Additional tools
34-
.clover/
31+
.vscode
32+
!.vscode/settings.json
3533

3634
# OSX files
3735
**/.DS_Store
3836

39-
# Compiler output, class files
40-
*.class
41-
bin/
42-
43-
# Log file
44-
*.log
45-
46-
# BlueJ files
47-
*.ctxt
48-
49-
# Mobile Tools for Java (J2ME)
50-
.mtj.tmp/
51-
52-
# Package Files #
53-
*.jar
54-
*.war
55-
*.ear
56-
*.zip
57-
*.tar.gz
58-
*.rar
59-
60-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
61-
hs_err_pid*
62-
63-
#Test config and output
64-
test-output/
65-
local/
66-
reports/
67-
.pmd
68-
tmp/
69-
7037
# Build artifacts
71-
target/
72-
out/
73-
build/
74-
jarsIn/
75-
build.xml
76-
*.properties
77-
*.releaseBackup
78-
*.next
79-
*.tag
80-
doc/
81-
82-
# Jekyll
83-
_site/
84-
_*
85-
_*/
38+
**/target

CONTRIBUTING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Contributing
2+
3+
Thank you for contributing to Apache DataSketches!
4+
5+
The goal of this document is to provide everything you need to start contributing to this core Rust library.
6+
7+
## Your First Contribution
8+
9+
1. [Fork the DataSketches repository](https://github.com/apache/datasketches-rust/fork) in your own GitHub account.
10+
2. [Create a new Git branch](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository).
11+
3. Make your changes.
12+
4. [Submit the branch as a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to the upstream repo. A DataSketches team member should comment and/or review your pull request within a few days. Although, depending on the circumstances, it may take longer.
13+
14+
## Setup
15+
16+
This repo develops Apache® DataSketches™ Core Rust Library Component. To build this project, you will need to set up Rust development first. We highly recommend using [rustup](https://rustup.rs/) for the setup process.
17+
18+
For Linux or macOS users, use the following command:
19+
20+
```shell
21+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
22+
```
23+
24+
For Windows users, download `rustup-init.exe` from [here](https://win.rustup.rs/x86_64) instead.
25+
26+
Rustup will read the `rust-toolchain.toml` file and set up everything else automatically. To ensure that everything works correctly, run `cargo version` under the root directory:
27+
28+
```shell
29+
cargo version
30+
# cargo 1.85.0 (<hash> 2024-12-31)
31+
```
32+
33+
To keep code style consistent, we use the following tools:
34+
35+
* Nightly `rustfmt` for code formatting: `cargo +nightly fmt --all -- --check`
36+
* Nightly `clippy` for linting: `cargo +nightly clippy --all-targets --all-features -- -D warnings`
37+
* [`typos`](https://github.com/crate-ci/typos) for spell checking: `cargo install typos-cli` and then `typos`
38+
* [`taplo`](https://taplo.tamasfe.dev/) for checking `toml` files: `cargo install taplo-cli` and then `taplo check`
39+
* [`hawkeye`](https://github.com/korandoru/hawkeye) for checking license header: `cargo install hawkeye` and then `hawkeye check`
40+
41+
## Code of Conduct
42+
43+
We expect all community members to follow our [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).

Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,21 @@
1818
[package]
1919
name = "datasketches"
2020
version = "0.1.0"
21+
2122
edition = "2024"
23+
rust-version = "1.85.0"
24+
25+
categories = ["data-structures", "algorithms"]
26+
description = "A software library of stochastic streaming algorithms (a.k.a. sketches)"
27+
homepage = "https://datasketches.apache.org"
28+
keywords = ["sketch", "hyperloglog", "probabilistic"]
29+
license = "Apache-2.0"
30+
readme = "README.md"
31+
repository = "https://github.com/apache/datasketches-rust"
32+
33+
[package.metadata.docs.rs]
34+
all-features = true
35+
rustdoc-args = ["--cfg", "docsrs"]
2236

2337
[dependencies]
24-
mur3 = "0.1"
38+
mur3 = { version = "0.1.0" }

0 commit comments

Comments
 (0)