Skip to content

Commit

Permalink
GitHub Actions + pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude committed Dec 25, 2023
1 parent f172118 commit 593863d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 20 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Tests
on:
push:
branches:
- ci
pull_request:
jobs:
tests:
name: Linting and Testing
runs-on: "ubuntu-latest"
strategy:
matrix:
rust-version: ["1.65", "stable"]
steps:
- name: Pull Neo4j Docker Image
run: docker pull neo4j:5.6-enterprise
- name: Start Neo4j
run: docker run
-d --rm --name neo4j
-p 7474:7474 -p 7687:7687
-e NEO4J_AUTH=neo4j/pass
-e NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
-e NEO4J_dbms_security_auth__minimum__password__length=1
neo4j:5.6-enterprise &
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: clippy
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: cargo check
env:
RUSTFLAGS: -D warnings
run: cargo check
- name: cargo fmt
run: cargo +nightly fmt --all -- --check
- name: tests
env:
TEST_NEO4J_SCHEME: neo4j
TEST_NEO4J_HOST: localhost
TEST_NEO4J_PORT: 7687
TEST_NEO4J_USER: neo4j
TEST_NEO4J_PASS: pass
TEST_NEO4J_EDITION: enterprise
TEST_NEO4J_VERSION: 5.6
run: cargo test
testkit:
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Checkout driver
uses: actions/checkout@v4
with:
path: driver

# - name: Read required TestKit version from driver repo
# id: testkit_vars
# run: echo ::set-output name=testkit_version_ref::$(cat driver/.testkit_version | xargs)

- name: Checkout TestKit
uses: actions/checkout@v4
with:
repository: robsdedude/testkit
path: testkit
ref: rust
# ref: ${{ steps.testkit_vars.outputs.testkit_version_ref }}

# Runs a single command using the runners shell
- name: Run TestKit
env:
# to learn what these variables do, see https://github.com/neo4j-drivers/testkit
TEST_DRIVER_NAME: rust
TEST_DRIVER_REPO: ${{ github.workspace }}/driver
TEST_RUN_ALL_TESTS: "true"
run: |
cd testkit
# everything from --run-only-selected is to reduce the number of tests run in this
# demonstation setup. In a real setup, you most likely don't want this.
python3 main.py --tests TESTKIT_TESTS STUB_TESTS TLS_TESTS
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
fail_fast: true
repos:
- repo: local
hooks:
- id: check
name: cargo check
entry: cargo check --
language: system
types: [rust]
pass_filenames: false
- id: fmt
name: cargo fmt
entry: cargo +nightly fmt --all -- --check
language: system
types: [rust]
- id: clippy
name: cargo clippy
entry: cargo clippy -- -D warnings
language: system
types: [rust]
pass_filenames: false
- id: unit
name: unit tests
entry: cargo test --tests --benches
language: system
types: [rust]
pass_filenames: false
36 changes: 17 additions & 19 deletions neo4j/src/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,21 +541,21 @@ impl ConnectionConfig {
/// # use rustls::RootCertStore;
/// # use rustls_pki_types::{TrustAnchor, Der};
///
/// # fn get_client_config() -> ClientConfig {
/// # fn get_custom_client_config() -> ClientConfig {
/// # ClientConfig::builder().with_root_certificates(
/// # RootCertStore {
/// # roots: vec![
/// # TrustAnchor {
/// # subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\"0 \x06\x03U\x04\n\x13\x19Google Trust Services LLC1\x140\x12\x06\x03U\x04\x03\x13\x0bGTS Root R4"),
/// # subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf3ts\xa7h\x8b`\xaeC\xb85\xc5\x810{KI\x9d\xfb\xc1a\xce\xe6\xdeF\xbdk\xd5a\x185\xae@\xdds\xf7\x89\x910Z\xeb<\xee\x85|\xa2@v;\xa9\xc6\xb8G\xd8*\xe7\x92\x91js\xe9\xb1r9\x9f)\x9f\xa2\x98\xd3_^X\x86e\x0f\xa1\x84e\x06\xd1\xdc\x8b\xc9\xc7s\xc8\x8cj/\xe5\xc4\xab\xd1\x1d\x8a"),
/// # subject: Der::from_slice(b""),
/// # subject_public_key_info: Der::from_slice(b""),
/// # name_constraints: None,
/// # },
/// # ],
/// # },
/// # ).with_no_client_auth()
/// # }
/// #
/// let client_config: ClientConfig = get_client_config();
/// let client_config: ClientConfig = get_custom_client_config();
/// let config = ConnectionConfig::new(("localhost", 7687).into())
/// .with_encryption_custom_tls_config(client_config);
/// ```
Expand Down Expand Up @@ -854,21 +854,19 @@ mod mockable {

impl NonVerifyingVerifier {
pub fn new() -> Self {
let default_verifier = WebPkiServerVerifier::builder(Arc::new(
RootCertStore {
roots: vec![
// any certificate will do as we only forward methods to the default
// verifier that do not care about the certificate
TrustAnchor {
subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\"0 \x06\x03U\x04\n\x13\x19Google Trust Services LLC1\x140\x12\x06\x03U\x04\x03\x13\x0bGTS Root R4"),
subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf3ts\xa7h\x8b`\xaeC\xb85\xc5\x810{KI\x9d\xfb\xc1a\xce\xe6\xdeF\xbdk\xd5a\x185\xae@\xdds\xf7\x89\x910Z\xeb<\xee\x85|\xa2@v;\xa9\xc6\xb8G\xd8*\xe7\x92\x91js\xe9\xb1r9\x9f)\x9f\xa2\x98\xd3_^X\x86e\x0f\xa1\x84e\x06\xd1\xdc\x8b\xc9\xc7s\xc8\x8cj/\xe5\xc4\xab\xd1\x1d\x8a"),
name_constraints: None
},
],
},
))
.build()
.unwrap();
let default_verifier = WebPkiServerVerifier::builder(Arc::new(RootCertStore {
roots: vec![
// any certificate will do as we only forward those methods to the default
// verifier which do not care about the certificate
TrustAnchor {
subject: Der::from_slice(b""),
subject_public_key_info: Der::from_slice(b""),
name_constraints: None,
},
],
}))
.build()
.unwrap();
let default_verifier = Arc::into_inner(default_verifier).unwrap();
Self { default_verifier }
}
Expand Down
1 change: 0 additions & 1 deletion neo4j/src/driver/io/bolt/packstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod serialize;
mod tests;

pub(crate) use deserialize::{PackStreamDeserializer, PackStreamDeserializerImpl};
pub use error::PackStreamDeserializeError;
pub use serialize::{
PackStreamSerializer, PackStreamSerializerDebugImpl, PackStreamSerializerImpl,
};

0 comments on commit 593863d

Please sign in to comment.