diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 177567f..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: GitHub CI/CD Workflow - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - container: - image: ubuntu:24.04 - env: - OPENSSL_DIR: /usr/include/openssl - OPENSSL_LIB_DIR: /usr/lib/x86_64-linux-gnu - OPENSSL_INCLUDE_DIR: /usr/include/openssl - - steps: - - name: Install dependencies - run: | - apt-get update - apt-get install -y curl git build-essential libssl-dev - - - uses: actions/checkout@v4 # checkout the repository - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Set up JDK 11 # required for build-models.sh - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: '11' - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '^1.22' - - name: Install Funnel - run: | - if [ -d "funnel" ]; then rm -Rf funnel; fi - git clone https://github.com/ohsu-comp-bio/funnel.git - cd funnel && make && make install && cd .. - - uses: actions/checkout@v4 # checkout the repository - - name: Build models - run: | - bash ./build-models.sh - - name: Build - run: | - cargo build --verbose - - name: Run tests - run: | - bash ./run-tests.sh - - name: Lint - run: | - cargo clippy -- -D warnings - - name: Format - run: | - cargo fmt -- ./lib/src/serviceinfo/models/*.rs # workaround to fix autogenerated code formatting - cargo fmt -- ./lib/src/tes/models/*.rs - cargo fmt -- --check \ No newline at end of file diff --git a/.github/workflows/code_quality.yaml b/.github/workflows/code_quality.yaml new file mode 100644 index 0000000..955488d --- /dev/null +++ b/.github/workflows/code_quality.yaml @@ -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 + 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 "**/*" +... diff --git a/.github/workflows/code_test.yaml b/.github/workflows/code_test.yaml new file mode 100644 index 0000000..c0ad90e --- /dev/null +++ b/.github/workflows/code_test.yaml @@ -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 + + - 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 +... diff --git a/.github/workflows/local.yml b/.github/workflows/local.yml deleted file mode 100644 index d0b039f..0000000 --- a/.github/workflows/local.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Local CI/CD Workflow - -on: workflow_dispatch - -jobs: - build: - - runs-on: ubuntu-latest - container: - image: ubuntu:24.04 - env: - OPENSSL_DIR: /usr/include/openssl - OPENSSL_LIB_DIR: /usr/lib/x86_64-linux-gnu - OPENSSL_INCLUDE_DIR: /usr/include/openssl - - steps: - - - name: Cache Rust dependencies - uses: actions/cache@v3 - with: - path: ~/.cargo - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - - name: Cache Rust build output - uses: actions/cache@v3 - with: - path: target - key: ${{ runner.os }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-build- - - - name: Cache Maven dependencies - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- - - - name: Cache Go modules - uses: actions/cache@v3 - with: - path: ~/.cache/go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go- - - - name: Cache Funnel dependencies - uses: actions/cache@v3 - with: - path: ~/funnel/build - key: ${{ runner.os }}-funnel-${{ hashFiles('**/funnel/*') }} - restore-keys: ${{ runner.os }}-funnel- - - - uses: actions/checkout@v4 # checkout the repository - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Set up JDK 11 # required for build-models.sh - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: '11' - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '^1.22' - - name: Install Funnel - run: | - if [ -d "funnel" ]; then rm -Rf funnel; fi - git clone https://github.com/ohsu-comp-bio/funnel.git - cd funnel && make && make install && cd .. - - uses: actions/checkout@v4 # checkout the repository - - name: Build models - run: | - . $HOME/.cargo/env - bash ./build-models.sh - - name: Build - run: | - . $HOME/.cargo/env - cargo build --verbose - - name: Run tests - run: | - . $HOME/.cargo/env - bash ./run-tests.sh - - name: Lint - run: | - . $HOME/.cargo/env - cargo clippy -- -D warnings - - name: Format - run: | - . $HOME/.cargo/env - # rustup install nightly – fails for some reason - # rustup default nightly - cargo fmt -- ./lib/src/serviceinfo/models/*.rs # workaround to fix autogenerated code formatting - cargo fmt -- ./lib/src/tes/models/*.rs - cargo fmt -- --check # --config-path ./rustfmt.toml \ No newline at end of file diff --git a/.github/workflows/pr_evaluation.yaml b/.github/workflows/pr_evaluation.yaml new file mode 100644 index 0000000..757cf1e --- /dev/null +++ b/.github/workflows/pr_evaluation.yaml @@ -0,0 +1,81 @@ +--- +name: PR evaluation + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, edited] + branches: ['main'] + +jobs: + detect-unresolved-conflicts: + name: Detect unresolved merge conflicts + runs-on: ubuntu-latest + needs: semantic_pr + steps: + - uses: actions/checkout@v3 + - name: List files with merge conflict markers + run: git --no-pager grep "<<<<<<<" ":(exclude).github/" || true + - name: Fail or succeed job if any files with merge conflict markers + run: exit $(git grep "<<<<<<<" ":(exclude).github/" | wc --lines) + + pre-commit: + name: Pre-commit checks + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Check all the pre-commit hooks passed + run: pre-commit run --all-files + + semantic-pr: + name: Semantic PR title + runs-on: ubuntu-latest + if: ${{ github.event.action != 'edited' || + github.event.changes.title != null }} + steps: + - name: Check if the PR title is semantic + uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + fix + feat + docs + style + refactor + perf + test + build + ci + chore + revert + subjectPattern: ^(?![A-Z])(?=.{1,50}$).+$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + doesn't start with an uppercase character & not have more than 50 + characters. + + - name: Check length of PR title + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + if [ ${#PR_TITLE} -gt 50 ]; then + echo "The PR title is too long. Please keep it under 50 characters." + exit 1 + fi + + binary-build: + name: Check if binary builds without error + 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 + + - name: Build the binary + run: cargo build --release +... diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..9d9ffa1 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,74 @@ +--- +default: true + +# Headings +MD001: + level: 1 # Require headings to increment by one level at a time +MD002: + level: 2 # Require that the first heading in a document is a level 2 heading +MD003: + style: atx # Enforce a consistent style for headings (e.g., atx style using #) + +# Unordered Lists +MD004: + style: dash # Enforce consistent marker style (e.g., - for list items) +MD005: true # Ensure list indentation is consistent +MD006: true # Require proper indentation for list items +MD007: + indent: 2 # Enforce a consistent indentation level for nested list items + +# Line Length +MD013: + line_length: 80 # Limit line length to 80 characters + code_blocks: false # Exclude code blocks from line length rule + tables: false # Exclude tables from line length rule + +# Trailing Spaces +MD009: + strict: true # Ensure no trailing spaces at the end of lines + +# Punctuation +MD026: + punctuation: ".,;:!" # Ensure proper punctuation in headings + +# Horizontal Rules +MD035: + style: "***" # Enforce a consistent style for horizontal rules + +# Links and Images +MD042: true # Require proper use of URLs in links +MD045: true # Ensure alt text is provided for images + +# General Formatting +MD010: true # No hard tabs +MD012: + maximum: 1 # No multiple consecutive blank lines +MD014: true # Dollar signs used before commands without showing output +MD018: true # No space after hash on atx style heading +MD019: true # Multiple spaces after hash on atx style heading +MD020: true # No space inside hashes on closed atx style heading +MD021: true # No multiple spaces inside hashes on closed atx style heading +MD022: true # Headings should be surrounded by blank lines +MD023: true # Headings must start at the beginning of the line +MD024: true # Multiple headings with the same content +MD025: true # Multiple top-level headings in the same document +MD027: true # Multiple spaces after blockquote symbol +MD028: true # Blank line inside blockquote +MD029: true # Ordered list item prefix +MD030: true # Spaces after list markers +MD031: true # Fenced code blocks should be surrounded by blank lines +MD032: true # Lists should be surrounded by blank lines +MD033: true # Inline HTML +MD034: true # Bare URL used +MD036: true # Emphasis used instead of a header +MD037: true # Spaces inside emphasis markers +MD038: true # Spaces inside code span elements +MD039: true # Spaces inside link elements +MD040: true # Fenced code blocks should have a language specified +MD041: false # First line need not be h1 +MD046: true # Code block style +MD047: true # Files should end with a single newline character +MD048: true # Code fence style +MD049: true # Required heading structure +MD050: true # Strong style should be consistent +... \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6bd4669 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,43 @@ +--- +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +# Common commands: +# pre-commit install +# pre-commit autoupdate +# pre-commit run --all-files --hook-stage commit +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=auto] + - id: trailing-whitespace + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 + hooks: + - id: markdownlint + args: ["--fix"] + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat + additional_dependencies: + - mdformat-config + - mdformat-black + - mdformat-frontmatter + args: [--wrap=80] + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint + - repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 + hooks: + - id: toml-sort-fix + args: [--in-place, --all, --trailing-comma-inline-array] + exclude: Cargo.lock +... \ No newline at end of file diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..9276f3a --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,13 @@ +--- +# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration +extends: default + +rules: + truthy: + ignore: + .github/**/*.yaml + document-start: + level: error + document-end: + level: error +... \ No newline at end of file