mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
Set up Github Actions (#1)
This commit is contained in:
parent
51d60037fb
commit
37556df3b7
5 changed files with 129 additions and 3 deletions
60
.github/workflows/build_test.yml
vendored
Normal file
60
.github/workflows/build_test.yml
vendored
Normal 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
.github/workflows/deploy.yml
vendored
Normal file
57
.github/workflows/deploy.yml
vendored
Normal 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
|
|
@ -1,5 +1,8 @@
|
|||
# youmubot
|
||||
|
||||

|
||||

|
||||
|
||||
A Discord bot made specifically for server "Dự tuyển Tổng Hợp". Written in Rust.
|
||||
|
||||
All PRs welcome.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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…
Add table
Reference in a new issue