Skip to content

Commit

Permalink
CI/CD workflow update
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelnikonorov committed Jun 24, 2024
1 parent 27bab17 commit d656d3b
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 13 deletions.
105 changes: 96 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,107 @@ jobs:
build:

runs-on: ubuntu-latest
container:
image: ubuntu:20.04
env:
OPENSSL_DIR: /usr/include/openssl
OPENSSL_LIB_DIR: /usr/lib/x86_64-linux-gnu
OPENSSL_INCLUDE_DIR: /usr/include/openssl

steps:
- uses: actions/checkout@v2

- name: Cache Rust dependencies
uses: actions/cache@v2
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Cache Rust build output
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-build-

- name: Cache Node.js dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-

- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Cache Funnel dependencies
uses: actions/cache@v2
with:
path: ~/funnel/build
key: ${{ runner.os }}-funnel-${{ hashFiles('**/funnel/*') }}
restore-keys: ${{ runner.os }}-funnel-

- name: Install Rust
run: rustup update stable
run: |
apt-get update
apt-get install -y curl git build-essential libssl-dev
if ! command -v rustup &> /dev/null # might not be installed while executing using `act`
then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
fi
rustup update stable
- name: Install Node.js # required for build-models.sh
run: |
REQUIRED_NODE_VERSION=22
if command -v node &> /dev/null; then
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt-get install -y nodejs
fi
- name: Set up JDK 11 # required for build-models.sh
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Install Go
uses: actions/setup-go@v2
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@v2 # checkout the repository
- name: Build models
run: ./build-models.sh
run: |
. $HOME/.cargo/env
bash ./build-models.sh
- name: Build
run: cargo build --verbose
- name: Run custom tests
run: ./run-tests.sh
run: |
. $HOME/.cargo/env
cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: |
. $HOME/.cargo/env
bash ./run-tests.sh
- name: Lint
run: cargo clippy -- -D warnings
run: |
. $HOME/.cargo/env
cargo clippy -- -D warnings
- name: Format
run: cargo fmt -- --check
run: |
. $HOME/.cargo/env
cargo fmt -- --check
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ target/
lib/src/**/models/
*.log
funnel-work-dir/

funnel/
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ cargo build

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 with:
Once you have installed Funnel, you can run the tests with (it will automatically run Funnel as well):

```
bash ./run-test.sh
```

To test out the CI/CD workflow locally, install `act` and run the following command:
```
act -j build --container-architecture linux/amd64 -P ubuntu-latest=ubuntu:20.04 --reuse
```
10 changes: 8 additions & 2 deletions build-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ generate_openapi_models() {
# 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
for file in $(find "$TEMP_OUTPUT_DIR" -name '*.rs'); do
# sed -i '' "s/use crate::models;/use crate::$API_NAME::models;/" "$file"
sed -i '' "s/use crate::models;/#![allow(unused_imports)]\nuse crate::$API_NAME::models;/" "$file"
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS (BSD) sed syntax
sed -i '' "s/use crate::models;/#![allow(unused_imports)]\nuse crate::$API_NAME::models;/" "$file"
else
# Linux (GNU) sed syntax
sed -i "s/use crate::models;/#![allow(unused_imports)]\nuse crate::$API_NAME::models;/" "$file"
fi
done

rm -rf "$DESTINATION_DIR/models"
Expand Down

0 comments on commit d656d3b

Please sign in to comment.