Skip to content

CI: share TestKit build artifacts between jobs #177

CI: share TestKit build artifacts between jobs

CI: share TestKit build artifacts between jobs #177

Workflow file for this run

name: Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lints:
name: Linting
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Install nightly toolchain for cargo-check-external-types
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly-2024-06-30
- name: Install latest nightly toolchain for rustfmt
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Versions
run: |
set -x
rustup show
cargo --version
cargo +nightly --version
cargo clippy --version
- name: cargo fmt
run: cargo +nightly fmt --all -- --check
- name: clippy all
run: cargo clippy --all --all-features -- -D warnings
- name: clippy driver
run: cargo clippy -p neo4j -- -D warnings
- name: Check exported dependencies
run: |
set -x
pushd neo4j
cargo install --locked cargo-check-external-types@0.1.13
cargo +nightly-2024-06-30 check-external-types
popd
- name: API stability check
run: cargo test --workspace --features _internal_public_api public_api
tests:
name: Testing
runs-on: "ubuntu-latest"
strategy:
matrix:
rust-version: [ "1.70", "stable" ]
steps:
- name: Pull neo4j docker image
run: docker pull neo4j:5.26-enterprise
- name: Make neo4j logs directory
run: mkdir -p neo4j/logs
- name: Start neo4j
id: start_neo4j
run: docker run
-d --name neo4j
-v ${{ github.workspace }}/neo4j/logs:/logs
-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.26-enterprise &
- uses: actions/checkout@v4
with:
path: driver
- name: Put Cargo.lock in place
working-directory: driver
run: cp .github/Cargo.lock Cargo.lock
- name: Install ${{ matrix.rust-version }} toolchain to test against
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: clippy
- name: Versions
run: |
rustup show
cargo --version
cargo clippy --version
- name: cargo check
working-directory: driver
env:
RUSTFLAGS: -D warnings
run: cargo check
- name: Docs build
working-directory: driver
run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps
- name: Tests
working-directory: driver
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.26
run: cargo test --workspace --all-targets
- name: Doc tests
working-directory: driver
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.26
run: cargo test --workspace --doc
- name: Stop neo4j
if: ${{ !cancelled() && steps.start_neo4j.conclusion == 'success' }}
run: |
docker stop neo4j
docker logs neo4j > neo4j/neo4j_docker.log 2>&1
docker rm neo4j
- name: Upload artifacts (neo4j logs)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: tests-${{ matrix.rust-version }}-neo4j-logs
path: neo4j
build-testkit:
name: Build TestKit Backend and Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout driver
uses: actions/checkout@v4
with:
path: driver
- name: Checkout TestKit test CA certs folders
uses: actions/checkout@v4
with:
repository: robsdedude/testkit
ref: rust
# ref: ${{ steps.testkit_vars.outputs.testkit_version_ref }}
path: testkit
sparse-checkout: |
tests/tls/certs/driver/trusted
tests/tls/certs/driver/custom
sparse-checkout-cone-mode: false
- name: Move TestKit test CA certs into place
run: |
mv testkit/tests/tls/certs/driver/trusted/ driver/testkit/CAs
mv testkit/tests/tls/certs/driver/custom/ driver/testkit/CustomCAs
rm -rf testkit
- name: tree
run: tree
- name: Put Cargo.lock in place
working-directory: driver
run: cp .github/Cargo.lock Cargo.lock
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export TestKit Docker image
uses: docker/build-push-action@v6
with:
tags: drivers-rust:local
context: driver/testkit
outputs: type=docker,dest=${{ runner.temp }}/testkit-backend-image.tar
- name: Load TestKit Docker image
run: docker load --input ${{ runner.temp }}/testkit-backend-image.tar
- name: Create cargo cache directory
run: mkdir -p ~/.cargo
- name: Build backend
run: |
docker run --rm \
-v ${{ github.workspace }}/driver:/driver \
-v `realpath ~/.cargo`:/root/.cargo \
--workdir="/driver" \
drivers-rust:local \
python3 testkit/build.py
- name: Fix permissions
run: |
sudo chown -R $USER: ~/.cargo
sudo chown -R $USER: driver/target
- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: testkit-backend-image
path: ${{ runner.temp }}/testkit-backend-image.tar
- name: Upload TestKit backend build & build cache
uses: actions/upload-artifact@v4
with:
name: testkit-backend-build-artifacts
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
driver/target/
testkit:
name: TestKit
needs: [ tests, lints, build-testkit ]
runs-on: ubuntu-latest
strategy:
matrix:
tests: [ TESTKIT_TESTS ]
# [bolt-version-bump] search tag when changing bolt version support
config:
- 4.4-community-bolt
- 4.4-community-neo4j
- 4.4-enterprise-bolt
- 4.4-enterprise-neo4j
- 4.4-enterprise-cluster-neo4j
- 5.1-enterprise-cluster-neo4j
- 5.5-enterprise-cluster-neo4j
- 5.7-enterprise-cluster-neo4j
- 5.9-enterprise-cluster-neo4j
- 5.13-enterprise-cluster-neo4j
- 5.23-enterprise-cluster-neo4j
include:
- tests: STUB_TESTS
config: ""
- tests: TLS_TESTS
config: ""
steps:
- name: Checkout driver
uses: actions/checkout@v4
with:
path: driver
- name: Put Cargo.lock in place
working-directory: driver
run: cp .github/Cargo.lock Cargo.lock
# - 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 }}
- name: Download TestKit Docker image artifact
uses: actions/download-artifact@v4
with:
name: testkit-backend-image
path: ${{ runner.temp }}
- name: Load TestKit Docker image
run: |
docker load --input ${{ runner.temp }}/testkit-backend-image.tar
docker image ls -a
- name: Download TestKit backend build artifacts
uses: actions/download-artifact@v4
with:
name: testkit-backend-build-artifacts
path: ${{ github.workspace }}/driver
- name: tree
run: tree
- name: Run TestKit
env:
TEST_DRIVER_NAME: rust
TEST_DRIVER_REPO: ${{ github.workspace }}/driver
TEST_RUN_ALL_TESTS: "true"
run: |
cd testkit
python3 main.py --tests ${{ matrix.tests }} \
${{ matrix.config && format('--config {0}', matrix.config) || ''}}
- name: Upload artifacts (TestKit logs)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: testkit-${{ matrix.tests }}${{ matrix.config && format('-{0}', matrix.config) || ''}}-artifacts
path: testkit/artifacts
compression-level: 9
ci-end:
name: CI End
if: ${{ cancelled() || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') }}
needs: [ tests, lints, testkit ]
runs-on: ubuntu-latest
steps:
- run: |
echo "Some workflows have failed!"
exit 1