diff --git a/.github/ISSUE_TEMPLATE/general-purpose.md b/.github/ISSUE_TEMPLATE/general-purpose.md new file mode 100644 index 0000000..6e29c73 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/general-purpose.md @@ -0,0 +1,49 @@ +Your issue may already be reported! Please search on the +[issue tracker][issue-tracker] before creating one. + +## Expected behavior + + + + + +## Current behavior + + + + + +## Possible solution + + + + + +## Context + + + + + +## Steps to reproduce (FOR BUGS) + + + + + +1. + +## Your environment (FOR BUGS) + + + +- Version used: +- Browser Name and version: +- Operating System and version (desktop or mobile): +- Link to your project: + +[issue-tracker]: https://github.com/elixir-cloud-aai/ga4gh-sdk/issues diff --git a/.github/actions/ci.yml b/.github/actions/ci.yml new file mode 100644 index 0000000..177567f --- /dev/null +++ b/.github/actions/ci.yml @@ -0,0 +1,60 @@ +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/actions/local.yml b/.github/actions/local.yml new file mode 100644 index 0000000..aac5962 --- /dev/null +++ b/.github/actions/local.yml @@ -0,0 +1,98 @@ +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/actions/setup/poetry/action.yaml b/.github/actions/setup/poetry/action.yaml new file mode 100644 index 0000000..36c4690 --- /dev/null +++ b/.github/actions/setup/poetry/action.yaml @@ -0,0 +1,92 @@ +# --- +# name: Setup Python and Poetry Action +# description: Configure system, Python, Poetry and deps and cache management. + +# inputs: +# os: +# default: ubuntu-latest +# description: The operating system to use +# python-version: +# default: '3.11' +# description: The version of Python to use +# poetry-version: +# default: '1.8.2' +# description: The version of Poetry to install +# poetry-install-options: +# default: '' +# description: Additional options to pass to poetry install +# poetry-export-options: +# default: '' +# description: Options to pass to poetry export for hash generation for cache +# invalidation + +# runs: +# using: composite +# steps: +# - uses: 'actions/setup-python@v5' +# id: setup-python +# with: +# python-version: '${{ inputs.python-version }}' + +# - name: Setup pipx environment Variables +# id: pipx-env-setup +# # pipx default home and bin dir are not writable by the cache action +# # so override them here and add the bin dir to PATH for later steps. +# # This also ensures the pipx cache only contains poetry +# run: | +# SEP="${{ !startsWith(runner.os, 'windows') && '/' || '\\' }}" +# PIPX_CACHE="${{ github.workspace }}${SEP}pipx_cache" +# echo "pipx-cache-path=${PIPX_CACHE}" >> $GITHUB_OUTPUT +# echo "pipx-version=$(pipx --version)" >> $GITHUB_OUTPUT +# echo "PIPX_HOME=${PIPX_CACHE}${SEP}home" >> $GITHUB_ENV +# echo "PIPX_BIN_DIR=${PIPX_CACHE}${SEP}bin" >> $GITHUB_ENV +# echo "PIPX_MAN_DIR=${PIPX_CACHE}${SEP}man" >> $GITHUB_ENV +# echo "${PIPX_CACHE}${SEP}bin" >> $GITHUB_PATH +# shell: bash + +# - name: Pipx cache +# id: pipx-cache +# uses: actions/cache@v4 +# with: +# path: ${{ steps.pipx-env-setup.outputs.pipx-cache-path }} +# key: ${{ runner.os }}-python- +# ${{ steps.setup-python.outputs.python-version }}- +# pipx-${{ steps.pipx-env-setup.outputs.pipx-version }}- +# poetry-${{ inputs.poetry-version }} + +# - name: Install poetry +# if: steps.pipx-cache.outputs.cache-hit != 'true' +# id: install-poetry +# shell: bash +# run: | +# pipx install poetry \ +# --python "${{ steps.setup-python.outputs.python-path }}" + +# - name: Read poetry cache location +# id: poetry-cache-location +# shell: bash +# run: | +# echo "poetry-venv-location=$(poetry config virtualenvs.path)" \ +# >> $GITHUB_OUTPUT + +# - name: Generate hash only for required deps +# run: | +# poetry export ${{ inputs.poetry-export-options }} \ +# --format=requirements.txt --output=requirements.txt +# echo "DEP_HASH=$(sha256sum requirements.txt | cut -d ' ' -f 1)" \ +# >> $GITHUB_ENV +# shell: bash + +# - uses: actions/cache@v4 +# name: Poetry cache +# with: +# path: ${{ steps.poetry-cache-location.outputs.poetry-venv-location }} +# key: ${{ runner.os }}-[python- +# ${{ steps.setup-python.outputs.python-version }}]-[ +# ${{ env.DEP_HASH }}]-[${{ inputs.poetry-install-options }}] + +# - name: 'Poetry install' +# if: steps.poetry-cache.outputs.cache-hit != 'true' +# shell: bash +# run: poetry install ${{ inputs.poetry-install-options }} --no-interaction +# ... diff --git a/.github/workflows/code_quality.yaml b/.github/workflows/code_quality.yaml new file mode 100644 index 0000000..b074b48 --- /dev/null +++ b/.github/workflows/code_quality.yaml @@ -0,0 +1,77 @@ +--- +name: Code quality + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + cargo-path: ${{ steps.export-cargo-path.outputs.path }} + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + apt-get update + apt-get install -y curl git build-essential libssl-dev + + - name: Install Rust + id: install-rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Export cargo path + id: export-cargo-path + run: echo "path=$HOME/.cargo/bin" >> $GITHUB_OUTPUT + + lint: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Rust + run: echo "$GITHUB_PATH" >> $GITHUB_PATH + + - name: Lint + run: cargo clippy -- -D warnings + + format: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Rust + run: echo "$GITHUB_PATH" >> $GITHUB_PATH + + - 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 + + spell-check: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Rust + run: echo "$GITHUB_PATH" >> $GITHUB_PATH + + - name: Check spellings + run: cargo spellcheck +...