Skip to content

Commit

Permalink
adding go port, refactoring Dockerfile and adding release workflows (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
axrav authored May 5, 2023
1 parent 451cdae commit dfde63b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dfde63b

Please sign in to comment.