FE: Do not weigh unallocated cash if portfolio does not have liquidit… #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: ["master", "rc/**"] | |
pull_request: | |
branches: ["master", "rc/**"] | |
env: | |
CARGO_TERM_COLOR: always | |
DOCKER_REPO: leonardoarcari/dcapal | |
jobs: | |
backend-build-test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
components: clippy, rustfmt | |
- uses: Swatinem/rust-cache@v2 | |
- name: Toolchain info | |
run: | | |
cargo --version --verbose | |
rustc --version | |
cargo clippy --version | |
- name: Lint | |
run: | | |
cd dcapal-backend | |
cargo fmt -- --check | |
cargo clippy -- -D warnings | |
- name: Build and Test | |
run: | | |
cd dcapal-backend | |
RUST_LOG=dcapal-backend=debug cargo test -- --nocapture | |
optimizer-build-test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
components: clippy, rustfmt | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Toolchain info | |
run: | | |
cargo --version --verbose | |
rustc --version | |
cargo clippy --version | |
- name: Lint | |
run: | | |
cd dcapal-optimizer-wasm | |
cargo fmt -- --check | |
cargo clippy -- -D warnings | |
- name: Test | |
run: | | |
cd dcapal-optimizer-wasm | |
RUST_LOG=info cargo test -- --nocapture | |
wasm-pack test --headless --chrome | |
- name: Build | |
run: | | |
cd dcapal-optimizer-wasm | |
wasm-pack build | |
- name: Archive dcapal-optimizer-wasm pkg | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dcapal-optimizer-wasm-pkg | |
path: dcapal-optimizer-wasm/pkg | |
frontend-check: | |
runs-on: ubuntu-22.04 | |
needs: optimizer-build-test | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "npm" | |
cache-dependency-path: dcapal-frontend/package-lock.json | |
- name: Check formatting | |
run: | | |
cd dcapal-frontend | |
npm ci | |
npm run check | |
frontend-build-test: | |
runs-on: ubuntu-22.04 | |
needs: [frontend-check, optimizer-build-test] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "npm" | |
cache-dependency-path: dcapal-frontend/package-lock.json | |
- name: Download dcapal-optimizer-wasm pkg | |
uses: actions/download-artifact@v3 | |
with: | |
name: dcapal-optimizer-wasm-pkg | |
path: dcapal-optimizer-wasm/pkg | |
- name: Install dependencies | |
run: | | |
cd dcapal-frontend | |
npm ci | |
- name: Build | |
run: | | |
cd dcapal-frontend | |
npm run build | |
frontend-e2e-tests: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
needs: [frontend-check, optimizer-build-test] | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "npm" | |
cache-dependency-path: dcapal-frontend/package-lock.json | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: network=host | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
# Prebuild backend Docker image to leverage cached layers | |
- name: Build dcapal-backend image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./dcapal-backend/docker/Dockerfile | |
push: true | |
tags: localhost:5000/${{ env.DOCKER_REPO }}:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
- name: Configure dcapal.yml | |
run: | | |
cat > dcapal-backend/dcapal.yml << EOF | |
app: | |
providers: | |
priceProvider: kraken | |
cwApiKey: CW_API_KEY | |
ipApiKey: IP_API_KEY | |
log: | |
level: dcapal_backend=info,tower_http=debug | |
file: data/dcapal/dcapal.log | |
enableStdout: true | |
server: | |
web: | |
hostname: 0.0.0.0 | |
port: 8080 | |
metrics: | |
hostname: 0.0.0.0 | |
port: 9000 | |
redis: | |
hostname: redis | |
port: 6379 | |
user: dcapal | |
password: dcapal | |
EOF | |
- name: Use local registry image | |
run: | | |
cat > dcapal-backend/docker-compose.override.yml << EOF | |
version: "3.9" | |
services: | |
dcapal: | |
image: localhost:5000/${DOCKER_REPO}:latest | |
EOF | |
- name: Run dcapal-backend | |
run: | | |
cd dcapal-backend && \ | |
docker compose -f docker-compose.yml \ | |
-f ./docker/docker-compose.local.yml \ | |
-f docker-compose.override.yml \ | |
up --no-build --wait | |
- name: Download dcapal-optimizer-wasm pkg | |
uses: actions/download-artifact@v3 | |
with: | |
name: dcapal-optimizer-wasm-pkg | |
path: dcapal-optimizer-wasm/pkg | |
- name: Install dependencies | |
run: cd dcapal-frontend && npm ci | |
- name: Install Playwright Browsers | |
run: cd dcapal-frontend && npx playwright install --with-deps | |
- name: Run Playwright tests | |
run: cd dcapal-frontend && npx playwright test | |
- name: Stop dcapal-backend | |
run: | | |
cd dcapal-backend && \ | |
docker compose -f docker-compose.yml \ | |
-f ./docker/docker-compose.local.yml \ | |
-f docker-compose.override.yml \ | |
down | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: dcapal-frontend/playwright-report/ | |
retention-days: 30 | |
- # Temp fix: Docker cache layer | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |