-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat: adding config in CLI #39
Changes from all commits
7cf9dfd
0087881
4560fc4
4210498
61fcb7a
780e7ff
47e3ca5
df64e6d
b0ea439
b54b56f
4e5c8dc
ce11ae1
395b00a
b1c12fe
432ca96
57406a1
ab08a44
02685c0
cbba4ae
be2e486
e9ccf43
d4faee2
f1bd0c5
c9cdbfc
27bab17
d656d3b
afbe68c
da80b57
a655a90
6514f6e
e0bdcf5
a1cd3bf
97595e0
a6b63ac
431a831
e447b5a
bcce6ec
f08c9dc
d8ef075
49a702d
c110379
4d88c44
dda27a7
df1fc62
a25c499
3c92b70
bc07b65
0f7decc
19ece96
4e415a5
ac64bb3
1487961
976846b
c96b636
d613722
4f482d3
ebc9bec
e56a623
d37b000
7725298
bad81eb
c95ac80
198e0f8
206c6c4
2f2b6a8
4a41548
2d48bdd
a5b484e
598646f
1369f7e
8ec57cc
1913d3d
ee0948c
44a1d64
5a13d19
0e29df7
e02346c
dff1a21
bedf68f
4ee3302
b8ea658
2d24c43
f6ef231
5d9c4bf
0d8d25c
7fa6bd6
00b6367
84a86c8
7fe8709
a76ddd3
433dd90
1d80b7c
1ae659a
0011f39
87fb971
1b96865
d57bede
ce90baa
4bb1f59
215ae5a
6be3e10
a6d98b3
d44fa38
768b4cf
786a855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
target/ | ||
debug/ | ||
Cargo.lock | ||
openapitools.json | ||
*.log | ||
funnel-work-dir/ | ||
funnel/ | ||
lib/src/*/models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[workspace] | ||
members = [ | ||
"cli", | ||
"lib" | ||
] | ||
|
||
[workspace.package] | ||
version = "0.1.0" | ||
authors = ["Aarav Mehta <[email protected]> (Google Summer of Code Participant)", "Pavel Nikonorov <[email protected]> (Google Summer of Code Mentor; GENXT)", "ELIXIR Cloud & AAI <[email protected]> (ELIXIR Europe)"] | ||
edition = "2021" | ||
readme = "./README.md" | ||
license-file = "LICENSE.txt" | ||
repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk.git" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# A Generic SDK and CLI for GA4GH API services | ||
|
||
## Building | ||
|
||
First, clone the repository, and then run the following command to automatically generate models using OpenAPI specifications: | ||
``` | ||
bash ./build-models.sh | ||
``` | ||
|
||
To build the project: | ||
``` | ||
cargo build | ||
``` | ||
|
||
## Running the tests | ||
|
||
Before running the tests, you need to install Funnel, a task execution system that is compatible with the GA4GH TES API. Follow the instructions in the [Funnel Developer's Guide](https://ohsu-comp-bio.github.io/funnel/docs/development/developers/) to install Funnel. | ||
|
||
Once you have installed Funnel, you can run the tests. This will automatically run Funnel as well: | ||
|
||
``` | ||
bash ./run-tests.sh | ||
``` | ||
or, you can run using cargo nextest using | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (documentation): Repetition of the word 'using'. The phrase 'using cargo nextest using' should be rephrased to 'using cargo nextest'. |
||
``` | ||
cargo nextest run | ||
``` | ||
For checking the unit converage, you can run: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (documentation): Typo in the word 'converage'. The word 'converage' should be corrected to 'coverage'. |
||
``` | ||
cargo llvm-cov nextest | ||
``` | ||
|
||
To test the CI/CD workflow locally, install `act` and run the following command: | ||
``` | ||
act -j build --container-architecture linux/amd64 -P ubuntu-latest=ubuntu:24.04 --reuse | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Exit immediately if a command exits with a non-zero status. | ||
set -e | ||
|
||
# Ensure the OpenAPI Generator JAR file is set up | ||
mkdir -p ~/bin/openapitools | ||
OPENAPI_GENERATOR_JAR=~/bin/openapitools/openapi-generator-cli.jar | ||
if [ ! -f "$OPENAPI_GENERATOR_JAR" ]; then | ||
curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.7.0/openapi-generator-cli-7.7.0.jar -o "$OPENAPI_GENERATOR_JAR" | ||
fi | ||
|
||
get_git_repo_name() { | ||
# Extract the URL of the remote "origin" | ||
url=$(git config --get remote.origin.url) | ||
|
||
# Extract the repository name from the URL | ||
repo_name=$(basename -s .git "$url") | ||
|
||
echo "$repo_name" | ||
} | ||
|
||
SCRIPT_DIR="$(pwd)" | ||
|
||
generate_openapi_models() { | ||
# Parameters | ||
OPENAPI_SPEC_PATH="$1" | ||
API_NAME="$2" | ||
DESTINATION_DIR="$3" | ||
|
||
# Define the temporary output directory for the OpenAPI generator | ||
TEMP_OUTPUT_DIR=$(mktemp -d) | ||
|
||
# Remove the temporary directory at the end of the script | ||
trap 'rm -rf "$TEMP_OUTPUT_DIR"' EXIT | ||
|
||
# Run the OpenAPI generator CLI using the JAR file | ||
java -jar "$OPENAPI_GENERATOR_JAR" generate -g rust \ | ||
-i "$OPENAPI_SPEC_PATH" \ | ||
-o "$TEMP_OUTPUT_DIR" \ | ||
--additional-properties=useSingleRequestParameter=true | ||
|
||
# Check if the generation was successful | ||
if [ $? -ne 0 ]; then | ||
echo "OpenAPI generation failed. Check the verbose output for details." | ||
exit 1 | ||
fi | ||
|
||
# Remove the openapitools.json file | ||
rm -f ./openapitools.json | ||
|
||
echo "TEMP_OUTPUT_DIR is $TEMP_OUTPUT_DIR" | ||
|
||
# Modify the import statements in each generated file | ||
SED_RULE="s/use crate::models;/#![allow(unused_imports)]\n#![allow(clippy::empty_docs)]\nuse crate::$API_NAME::models;/" | ||
for file in $(find "$TEMP_OUTPUT_DIR" -name '*.rs'); do | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
# macOS (BSD) sed syntax | ||
sed -i '' "$SED_RULE" "$file" | ||
else | ||
# Linux (GNU) sed syntax | ||
sed -i "$SED_RULE" "$file" | ||
fi | ||
done | ||
|
||
rm -rf "$DESTINATION_DIR/models" | ||
mkdir -p "$DESTINATION_DIR" | ||
cp -r "$TEMP_OUTPUT_DIR/src/models" "$DESTINATION_DIR" | ||
|
||
echo "OpenAPI generation complete. Models copied to $DESTINATION_DIR" | ||
} | ||
|
||
generate_openapi_models \ | ||
"https://raw.githubusercontent.com/ga4gh-discovery/ga4gh-service-info/develop/service-info.yaml" \ | ||
"serviceinfo" "$SCRIPT_DIR/lib/src/serviceinfo/" | ||
|
||
generate_openapi_models \ | ||
"https://raw.githubusercontent.com/ga4gh/task-execution-schemas/develop/openapi/task_execution_service.openapi.yaml" \ | ||
"tes" "$SCRIPT_DIR/lib/src/tes/" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "cli" | ||
description = """ | ||
A cross-platform CLI tool written in Rust to use GA4GH-sdk | ||
""" | ||
repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk/tree/main/cli" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
readme.workspace = true | ||
license-file.workspace = true | ||
|
||
[dependencies] | ||
ga4gh-lib = { path = "../lib" } | ||
clap = "3.0" | ||
clap_complete = "3.0" | ||
tokio = { version = "1", features = ["full"] } | ||
serde_json = "^1.0" | ||
tempfile = "3.2" | ||
dirs = "5.0.1" | ||
|
||
[[bin]] | ||
name = "cli" | ||
path = "src/main.rs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (documentation): Consider capitalizing 'Services' for consistency.
To maintain a consistent title case format, consider changing 'services' to 'Services'.