Skip to content

Commit

Permalink
Merge pull request #1 from kpcyrd/github-actions
Browse files Browse the repository at this point in the history
Add github actions CI
  • Loading branch information
kpcyrd authored Feb 19, 2024
2 parents 38c96e8 + 113164e commit bb70d9c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/wrangler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Wrangler

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 9 * * 1'

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-

- name: Install worker-build
run: command -v worker-build || cargo install worker-build

- name: Build
run: worker-build --release

- name: Upload worker binary
uses: actions/upload-artifact@v3
with:
name: worker
path: build/

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug-

- name: Run tests
run: cargo test --verbose

clippy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug-

- name: Run clippy
run: cargo clippy --verbose

fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Run cargo fmt
run: cargo fmt --all -- --check
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ async fn main(req: Request, env: Env, ctx: Context) -> Result<Response> {
console_debug!("Received request: {req:?}");
Response::ok("Hello, World!")
}

#[cfg(test)]
mod tests {
fn add(left: usize, right: usize) -> usize {
left + right
}

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

0 comments on commit bb70d9c

Please sign in to comment.