Skip to content

Commit

Permalink
changing to cookiecutter like template
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Aug 4, 2024
1 parent c6644c4 commit 178d6ae
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/general-purpose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Your issue may already be reported! Please search on the
[issue tracker][issue-tracker] before creating one.

## Expected behavior

<!--- If you're describing a bug, tell us what should happen -->

<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current behavior

<!--- If describing a bug, tell us what happens instead of the expected
behavior -->

<!--- If suggesting a change/improvement, explain the difference from current
behavior -->

## Possible solution

<!--- Not obligatory, but suggest a fix/reason for the bug, -->

<!--- or ideas how to implement the addition or change -->

## Context

<!--- How has this issue affected you? What are you trying to accomplish? -->

<!--- Providing context helps us come up with a solution that is most useful in
the real world -->

## Steps to reproduce (FOR BUGS)

<!--- Provide a link to a live example, or an unambiguous set of steps to -->

<!--- reproduce this bug. Include code to reproduce, if relevant -->

1.

## Your environment (FOR BUGS)

<!--- Include as many relevant details about the environment you experienced the
bug in -->

- 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
60 changes: 60 additions & 0 deletions .github/actions/ci.yml
Original file line number Diff line number Diff line change
@@ -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
98 changes: 98 additions & 0 deletions .github/actions/local.yml
Original file line number Diff line number Diff line change
@@ -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
92 changes: 92 additions & 0 deletions .github/actions/setup/poetry/action.yaml
Original file line number Diff line number Diff line change
@@ -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
# ...
77 changes: 77 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -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
...

0 comments on commit 178d6ae

Please sign in to comment.