Skip to content

RS-387: Java getting started #503

RS-387: Java getting started

RS-387: Java getting started #503

name: Test examples from documentation
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
test_examples:
runs-on: ubuntu-latest
name: Test examples
strategy:
matrix:
doc_version: [ next, 1.11.x, 1.10.x, 1.9.x ]
example: [ python, node, curl, cpp, rust, java, cli ]
include:
- doc_version: next
reduct_version: main
example_root: docs/examples
- doc_version: 1.11.x
reduct_version: latest
example_root: versioned_docs/version-1.11.x/examples/
- doc_version: 1.10.x
reduct_version: v1.10.1
example_root: versioned_docs/version-1.10.x/examples/
- doc_version: 1.9.x
reduct_version: v1.9.5
example_root: versioned_docs/version-1.9.x/examples/
- language: python
cmd: python3
path_prefix: py/src
- example: node
cmd: node
path_prefix: js/src
- example: curl
path_prefix: curl
cmd: sh
- example: cpp
path_prefix: cpp/build
cmd: sh -c
- example: rust
path_prefix: rs/build/bin
cmd: sh -c
- example: cli
path_prefix: cli
cmd: sh
- example: java
path_prefix: java/src/main/java/store/reduct/
cmd: ./java/example-runner.sh
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Prepare ReductStore instance
run: |
docker run -d --name reductstore -p 8383:8383 --env RS_API_TOKEN="my-token" --name reductstore reduct/store:${{ matrix.reduct_version }}
sleep 3
wget https://github.com/reductstore/reduct-cli/releases/latest/download/reduct-cli.linux-amd64.tar.gz
tar -xvf reduct-cli.linux-amd64.tar.gz
chmod +x reduct-cli
sudo mv reduct-cli /usr/local/bin
reduct-cli bucket create http://[email protected]:8383/bucket-to-remove
reduct-cli cp https://[email protected]/datasets http://[email protected]:8383/example-bucket --limit 100
reduct-cli replica create http://[email protected]:8383/example-replication example-bucket http://[email protected]:8383/bucket-to-remove
reduct-cli replica create http://[email protected]:8383/repl-to-remove example-bucket http://[email protected]:8383/bucket-to-remove
reduct-cli token create http://[email protected]:8383/token-to-remove
curl -X POST -H "Authorization: Bearer my-token" -d "" http://127.0.0.1:8383/api/v1/b/bucket-to-remove/example-entry?ts=1
- name: Install Python
uses: actions/setup-python@v5
if: matrix.example == 'python'
with:
python-version: 3.8
- name: Install Node.js
uses: actions/setup-node@v4
if: matrix.example == 'node'
with:
node-version: 20
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
if: matrix.example == 'rust'
with:
toolchain: 1.80.1
- name: Install Java
uses: actions/setup-java@v4
if: matrix.example == 'java'
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
if: matrix.example == 'java'
- name: Install Python dependencies
if: matrix.example == 'python'
run: |
pip install -r ${{ matrix.example_root }}/${{ matrix.path_prefix }}/../requirements.txt
- name: Install Node.js dependencies
if: matrix.example == 'node'
run: |
git clone https://github.com/reductstore/reduct-js.git
cd reduct-js
yarn install
yarn run tsc
cd ..
yarn add ./reduct-js # install reduct-js as a package
- name: Build C++ examples
if: matrix.example == 'cpp'
run: |
export EXAMPLE_DST_PATH="$PWD/${{ matrix.example_root }}/${{ matrix.path_prefix }}"
git clone https://github.com/reductstore/reduct-cpp.git
cd reduct-cpp
cmake -DCMAKE_BUILD_TYPE=Release .
sudo make install
mkdir -p "$EXAMPLE_DST_PATH"
cd "$EXAMPLE_DST_PATH"
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j
# remove non-executable files from build directory
find "$EXAMPLE_DST_PATH" -type f ! -name "*.cxx" | xargs rm -rf
- name: Build Rust examples
if: matrix.example == 'rust'
run: |
export EXAMPLE_DST_PATH="$PWD/${{ matrix.example_root }}/rs/build"
mkdir -p "$EXAMPLE_DST_PATH"
cd "$EXAMPLE_DST_PATH"
cargo install --examples --root . --path "$EXAMPLE_DST_PATH"/..
- name: Run examples
run: |
cd ${{ matrix.example_root }}
for example in $(find ./${{ matrix.path_prefix }} -type f );
do
echo "Run $example"
${{ matrix.cmd }} "$example"
sleep 1
# remove alias if it is cli example
if [ "${{ matrix.example }}" == "cli" ]; then
reduct-cli alias rm local || true
fi
reduct-cli bucket create http://[email protected]:8383/bucket-to-remove || true
curl -X POST -H "Authorization: Bearer my-token" -d "" http://127.0.0.1:8383/api/v1/b/bucket-to-remove/example-entry?ts=1 || true
done
- name: Print Docker logs
if: always()
run: |
docker logs reductstore
test_provisioning:
runs-on: ubuntu-latest
name: Test provisioning
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Run provisioning examples
run: |
for example in $(find docs/guides/examples/provisioning -type f );
do
docker-compose -f $example up -d
docker-compose -f $example down
done