Skip to content

Commit

Permalink
Improve workspace usage (metaplex-foundation#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Jan 9, 2024
1 parent 9315f1a commit c572af9
Show file tree
Hide file tree
Showing 69 changed files with 1,395 additions and 12,553 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/build-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build das api components
# This workflow uses github runners.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# This may be adjusted to whatever suits best your runners config.
# Current config will build on manual trigger or pull-request (each push)
on:
# pull_request can be removed, to save minutes on github runners
pull_request:
workflow_dispatch:
push:
branches:
- 'main'

env:
CARGO_TERM_COLOR: always

jobs:
build-api:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
# This can be also be runned on self-hosted github runners
runs-on: ["${{ matrix.os }}"]

steps:
- name: checkout repo
uses: actions/checkout@v3
# This step can be omited, to save storage space on the organization account
# Build process will take longer
- name: set build cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
digital-asset-rpc-infrastructure/target/
key: ${{ matrix.os }}_digital-asset-rpc-infrastructure_${{ hashFiles('digital-asset-rpc-infrastructure/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}_digital-asset-rpc-infrastructure
- name: build digital asset rpc infra
run: cargo build --verbose --release

- name: rename binaries for ubuntu22 release
if: matrix.os == 'ubuntu-22.04'
run: |
mv target/release/nft_ingester target/release/nft_ingester22
mv target/release/fetch_trees target/release/fetch_trees22
mv target/release/migration target/release/migration22
mv target/release/das_api target/release/das_api22
# This steps can be omited to save space, are mostly in place to validate binaries (manually) and path to them
# Omiting this will save on storage consumption on the account
- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: nft_ingester22
path: target/release/nft_ingester22

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: das_api22
path: target/release/das_api22

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: migration22
path: target/release/migration22

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: fetch-trees22
path: target/release/fetch_trees22

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: nft_ingester
path: target/release/nft_ingester

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: das_api
path: target/release/das_api

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: migration
path: target/release/migration

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: fetch-trees
path: target/release/fetch_trees
108 changes: 18 additions & 90 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
name: Build das api components
# This workflow uses github runners.
name: Check lock file, fmt, clippy

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# This may be adjusted to whatever suits best your runners config.
# Current config will build on manual trigger or pull-request (each push)
on:
# pull_request can be removed, to save minutes on github runners
pull_request:
workflow_dispatch:
push:
branches:
- 'main'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build-api:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
# This can be also be runned on self-hosted github runners
runs-on: ["${{ matrix.os }}"]
test:
runs-on: ubuntu-22.04

steps:
- name: checkout repo
uses: actions/checkout@v3
# This step can be omited, to save storage space on the organization account
# Build process will take longer

- name: set build cache
uses: actions/cache@v3
with:
Expand All @@ -39,83 +31,19 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
digital-asset-rpc-infrastructure/target/
key: ${{ matrix.os }}_digital-asset-rpc-infrastructure_${{ hashFiles('digital-asset-rpc-infrastructure/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}_digital-asset-rpc-infrastructure
- name: build digital asset rpc infra
run: cargo build --verbose --release

- name: build das_api
working-directory: das_api
run: cargo build --verbose --release
key: cargo-${{ hashFiles('**/Cargo.lock') }}-0001

- name: build migration
working-directory: migration
run: cargo build --verbose --release

- name: rename binaries for ubuntu22 release
if: matrix.os == 'ubuntu-22.04'
# Cargo.lock
- name: Check lock file
run: |
mv target/release/nft_ingester target/release/nft_ingester22
mv target/release/fetch_trees target/release/fetch_trees22
mv das_api/target/release/das_api das_api/target/release/das_api22
mv migration/target/release/migration migration/target/release/migration22
cargo tree
git checkout Cargo.lock
cargo tree --frozen
# This steps can be omited to save space, are mostly in place to validate binaries (manually) and path to them
# Omiting this will save on storage consumption on the account
- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: nft_ingester22
path: target/release/nft_ingester22
# fmt
- name: Check fmt
run: cargo fmt --all -- --check

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: das_api22
path: das_api/target/release/das_api22

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: migration22
path: migration/target/release/migration22

- name: Publish artifact
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v3.1.1
with:
name: fetch-trees22
path: migration/target/release/fetch_trees22

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: nft_ingester
path: target/release/nft_ingester

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: das_api
path: das_api/target/release/das_api

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: migration
path: migration/target/release/migration

- name: Publish artifact
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3.1.1
with:
name: fetch-trees
path: target/release/fetch_trees
# clippy
- name: Check clippy
run: cargo clippy --all-targets --tests
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ programs
*.iml
skaffold-state.json
test-programs

# Rust build dirs
/das_api/target
/migration/target
/tests/*/target
/*/target
/target
Loading

0 comments on commit c572af9

Please sign in to comment.