Skip to content

Commit

Permalink
Updated README and CI\CD.
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kirilin <[email protected]>
  • Loading branch information
s3rius committed Jan 5, 2022
1 parent df96399 commit c0b7c09
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 43 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: cargo
# Look for `Cargo.toml` and `Cargo.lock` in the root directory
directory: "/"
# Check for updates every Monday
schedule:
interval: weekly
open-pull-requests-limit: 2
35 changes: 0 additions & 35 deletions .github/workflows/docker.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
on: push
on:
push:
tags-ignore:
- '**'

name: Lint check
jobs:
clippy_check:
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Release

on:
push:
tags:
- '*'

jobs:
publish:
name: Publishing for ${{ matrix.job.os }}
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
rust: [stable]
job:
- os: macos-latest
os-name: macos
target: x86_64-apple-darwin
architecture: x86_64
binary-postfix: ""
use-cross: false
- os: ubuntu-latest
os-name: linux
target: x86_64-unknown-linux-gnu
architecture: x86_64
binary-postfix: ""
use-cross: false
- os: windows-latest
os-name: windows
target: x86_64-pc-windows-msvc
architecture: x86_64
binary-postfix: ".exe"
use-cross: false
# - os: ubuntu-latest
# os-name: linux
# target: aarch64-unknown-linux-gnu
# architecture: arm64
# binary-postfix: ""
# use-cross: true
# - os: ubuntu-latest
# os-name: linux
# target: i686-unknown-linux-gnu
# architecture: i686
# binary-postfix: ""
# use-cross: true

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.job.use-cross }}
toolchain: ${{ matrix.rust }}
args: --release --features=all --target ${{ matrix.job.target }}

- name: install strip command
shell: bash
run: |
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
sudo apt update
sudo apt-get install -y binutils-aarch64-linux-gnu
fi
- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.job.target }}/release
####### reduce binary size by removing debug symbols #######
BINARY_NAME=rustus${{ matrix.job.binary-postfix }}
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
GCC_PREFIX="aarch64-linux-gnu-"
else
GCC_PREFIX=""
fi
"$GCC_PREFIX"strip $BINARY_NAME
########## create tar.gz ##########
RELEASE_NAME=rustus-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
########## create sha256 ##########
if [[ ${{ runner.os }} == 'Windows' ]]; then
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
else
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
fi
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.job.target }}/release/rustus-*.tar.gz
target/${{ matrix.job.target }}/release/rustus-*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Export version
run: echo "APP_VERSION=$(head -n 5 Cargo.toml | grep version | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
file: deploy/Dockerfile
tags: s3rius/rustus:latest,s3rius/rustus:${{env.APP_VERSION}}
53 changes: 46 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ from source using `cargo`.
cargo install --path .
```

Or you can build a docker image.
Or you can use a docker image.

```bash
docker build --tag="rustus:latest" --cache-from=s3rius/tuser:latest -f deploy/Dockerfile .
docker run --rm -it -p 1081:1081 s3rius/rustus:latest
```

Docker image and binaries will be available soon.
Expand All @@ -47,13 +47,52 @@ In order to modify original file rustus searches for information about
the file in information storage.

However, automatic migration between different information
storages is not supported.
storages is not supported yet.

## Info storages

## Configuration
The info storage is a database or directory. The main goal is to keep track
of uploads. Rustus stores information about download in json format inside
database.

File storage is a default one. You can customize the directory of an .info files
by providing `--info-dir` parameter.

```bash
rustus --info-dir "./info_dir"
```

If you want to choose different storage you have to specify its type and connection string.

```bash
# Redis info storage
rustus --info-storage redis-info-storage --info-db-dsn "redis://localhost"
# PostgreSQL info storage
rustus --info-storage db-info-storage --info-db-dsn "postgres://rustus:[email protected]:5440/rustus"
# SQLite3 info storage
rustus --info-storage db-info-storage --info-db-dsn "sqlite:////test.sqlite3"
# MySQL
rustus --info-storage db-info-storage --info-db-dsn "mysql://rustus:[email protected]:3306/rustus"
```

## Hooks

Rustus supports several event hooks, such as:
* File hooks;
* HTTP hooks;
* AMQP hooks.

You can combine them, but you have to be careful, since
AMQP hooks won't block uploading.

If you want to check the "Authorization" header value or validate some information,
you have to use webhooks or File hooks.

Hooks have priorities: file hooks are the most important, then goes webhooks and AMQP hooks have the least priority.
If pre-create hook failed, the upload would not start.
Of course, since AMQP is a protocol that doesn't allow you to track responses.
We can't validate anything to stop uploading.

You can configure rustus via command line or environment variables.
All options are listed in `rustus --help`.

### Roadmap

Expand All @@ -71,7 +110,7 @@ All options are listed in `rustus --help`.
* [x] Notification interface;
* [x] Notifications via http hooks;
* [x] Notifications via RabbitMQ;
* [ ] S3 as data storage store support;
* [ ] Executable files notifications;
* [ ] S3 as data storage store support;
* [ ] Rustus helm chart;
* [ ] Cloud native rustus operator.

0 comments on commit c0b7c09

Please sign in to comment.