Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add workflows #34

Merged
merged 8 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .github/workflows/ci.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: Code test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
format:
name: Running formating checks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: fmt

- name: Run fmt checks
run: |
cargo fmt -- --check

lint:
name: Running lint checks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy

- name: Run unit tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run linting?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captions updated to the format "Running .... checks"

run: |
cargo clippy -- -D warnings

spell-check:
name: Running spell check
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.9.0'

- name: Install cspell
run: npm install -g cspell

- name: Spell check
run: cspell "**/*"
...
101 changes: 101 additions & 0 deletions .github/workflows/code_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
name: Code test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
common-steps:
name: common setup steps
runs-on: ubuntu-latest
outputs:
rust-toolchain: ${{ steps.set-toolchain.outputs.version }}
steps:
- name: Stop existing Funnel container if running
run: |
docker stop $(docker ps -q --filter ancestor=ohsucompbio/funnel:latest) || true
shell: bash

- name: Start Funnel
run: |
docker run -d -p 8000:8000 ohsucompbio/funnel:latest \
server run --Server.HostName=localhost --Server.HTTPPort=8000
shell: bash

- name: Wait for Funnel to be healthy
run: |
until curl --fail http://localhost:8000/v1/tasks; do
echo "Waiting for Funnel to be healthy..."
sleep 3
done
shell: bash

integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
needs: common-steps
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

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

- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to Cargo.toml?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aah yes, didn't touch that as it wan't merged.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since it is a CLI tool it needs to be installed manually outside of the Cargo.toml, or maybe you can add it to the rust-toolchain file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? What's the difference? Aren't the deps in Cargo.toml installed via cargo install?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uniqueg deps in Cargo.toml are installed differently – into the project's build cache, while the cargo install is only for standalone CLI tools such as rustfmt and cargo-tarpaulin.

as for cargo-tarpaulin, it can be installed via components like clippy, but only with the 'nightly' toolchain. So I’d suggest keeping it as a separate installation step.

Adding a rust-toolchain might be beneficial, so I've added an issue #45 (comment)


- name: Run unit tests with coverage
run: cargo tarpaulin --tests --doc --out Xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tarpaulin-report.xml
flags: test_integration
name: codecov-umbrella
fail_ci_if_error: true
verbose: true

unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
needs: common-steps
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Run unit tests
run: cargo test --lib

- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin

- name: Run unit tests with coverage
run: cargo tarpaulin --tests --doc --out Xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tarpaulin-report.xml
flags: test_unit
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
...
98 changes: 0 additions & 98 deletions .github/workflows/local.yml

This file was deleted.

Loading