From dfde63bd3e44d087676dfd1f12e81e4d4861f657 Mon Sep 17 00:00:00 2001 From: Aarav Arora Date: Sat, 6 May 2023 00:12:35 +0530 Subject: [PATCH] adding go port, refactoring Dockerfile and adding release workflows (#2) * refactor: using ADD instead of wget for dockerfile * feat: adding go port for AntispamAPI * feat: adding github workflows for build and release * fix: change in variable name * fix: workflow release bug --- .github/workflows/rust.yml | 45 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 5 ++--- README.md | 4 ++-- 3 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..3b5e3f1 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,45 @@ +name: build and release + +on: + push: + branches: [master] + release: + types: [created] + +env: + RUST_BACKTRACE: full + +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - name: Build + run: cargo build --release --verbose + + - name: Archive binary + uses: actions/upload-artifact@v2 + with: + name: tg_antispam_rs + path: target/release/tg_antispam_rs + + - name: Create release + uses: softprops/action-gh-release@v1 + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.SECRET_TOKEN }} + with: + files: target/release/tg_antispam_rs + tag_name: ${{ github.ref }} + name: Release ${{ github.ref }} + body: ${{ github.event.release.body }} + draft: false + prerelease: false diff --git a/Dockerfile b/Dockerfile index 012ef14..e63e9a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,7 @@ FROM debian:buster-slim COPY --from=rust-builder /usr/src/app/target/release/tg_antispam_rs /usr/local/bin/ WORKDIR /usr/local/bin -RUN apt-get update -RUN apt-get install wget -y -RUN wget "https://huggingface.co/datasets/thehamkercat/telegram-spam-ham/raw/main/dataset.csv" + +ADD https://huggingface.co/datasets/thehamkercat/telegram-spam-ham/raw/main/dataset.csv dataset.csv CMD ["tg_antispam_rs"] diff --git a/README.md b/README.md index 3f728a5..aee63b5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ - The dataset provided may contain some NSFW texts or personal info, it's not thoroughly checked. - I've included a docker-based example, but you can run it without docker as well. - `profanity` in response is only there to maintain backwards compatibility for ARQ users, it always returns `false` - ## Installation: I would suggest using docker compose for this, but it's upto you! ### With Docker compose @@ -51,8 +50,9 @@ content-type: application/json "spam_probability": 99 } ``` +### A Go port for the same API can be found [here](https://github.com/axrav/AntispamAPI) -## Usage example: +## Usage examples: ### Python ```python