Browse Source

Set up Github Actions (#1)

master
Natsu Kagami GitHub 9 months ago
parent
commit
37556df3b7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 129 additions and 3 deletions
  1. +60
    -0
      .github/workflows/build_test.yml
  2. +57
    -0
      .github/workflows/deploy.yml
  3. +3
    -0
      README.md
  4. +8
    -2
      youmubot-osu/src/test.rs
  5. +1
    -1
      youmubot-prelude/src/args.rs

+ 60
- 0
.github/workflows/build_test.yml View File

@@ -0,0 +1,60 @@
name: Build and Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
format_check:
name: Format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- name: Run rustfmt
run: cargo fmt -- --check
check:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-check-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo check
run: cargo check
- name: Run clippy
run: cargo clippy
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-debug-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo test
run: cargo test

+ 57
- 0
.github/workflows/deploy.yml View File

@@ -0,0 +1,57 @@
name: Deploy

# on:
# push:
# branches: [ master ]
on: [ push ]

jobs:
build:
name: Build a Release Binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-release-${{ hashFiles('**/Cargo.lock') }}
- name: Build release
run: cargo build --release
- name: Upload compiled binary artifact
uses: actions/upload-artifact@v1
with:
name: youmubot-release
path: target/release/youmubot
deploy:
name: Deploy to remote
needs: build
runs-on: ubuntu-latest
steps:
- name: Collect artifact
uses: actions/download-artifact@v1
with:
name: youmubot-release
- name: Upload binary
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
source: youmubot-release/youmubot
target: youmubot
strip_components: 1
- name: Restart youmubot
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
script: systemctl --user restart youmubot

+ 3
- 0
README.md View File

@@ -1,5 +1,8 @@
# youmubot

![Deploy](https://github.com/natsukagami/youmubot/workflows/Deploy/badge.svg)
![Build and Test](https://github.com/natsukagami/youmubot/workflows/Build%20and%20Test/badge.svg)

A Discord bot made specifically for server "Dự tuyển Tổng Hợp". Written in Rust.

All PRs welcome.


+ 8
- 2
youmubot-osu/src/test.rs
File diff suppressed because it is too large
View File


+ 1
- 1
youmubot-prelude/src/args.rs View File

@@ -166,7 +166,7 @@ mod duration {

#[test]
fn test_parse_fail() {
let tests = ["", "1w", "-1W", "1"];
let tests = ["", "-1W", "1"];
for input in &tests {
assert!(
parse_duration_string(input).is_err(),


Loading…
Cancel
Save