diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 81b821c93c..59c20a0416 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,46 +3,49 @@ name: Tests on: [push, pull_request] jobs: + check: name: Check - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Okay to just use one here steps: - - name: Checkout sources - uses: actions/checkout@v3 - + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable + - name: Checkout sources + uses: actions/checkout@v3 - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + uses: Swatinem/rust-cache@v2 + + - name: Configure sccache env var + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 - name: Run cargo check run: cargo check --tests --workspace --benches - test: + tests: name: Test Suite - # runs-on: ${{ matrix.os }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false - # matrix: - # os: [ ubuntu-latest, macos-latest, windows-latest ] + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] steps: - # Clean unnecessary files to save disk space + + # Clean unnecessary files to save disk space - name: clean unnecessary files to save space + if: runner.os == 'Linux' run: | docker rmi `docker images -q` sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d @@ -67,6 +70,7 @@ jobs: # Free up disk space on Ubuntu - name: Free Disk Space (Ubuntu) + if: runner.os == 'Linux' uses: jlumbroso/free-disk-space@main with: # This might remove tools that are actually needed, if set to "true" but frees about 6 GB @@ -78,38 +82,36 @@ jobs: large-packages: false swap-storage: true + - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Fix CRLF on Windows - if: runner.os == 'Windows' - run: git config --global core.autocrlf false - + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Set up cache + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Cache uses: Swatinem/rust-cache@v2 + + - name: Configure sccache env var + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 - name: Install cargo-nextest run: cargo install cargo-nextest - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Fix CRLF on Windows + if: runner.os == 'Windows' + run: git config --global core.autocrlf false - name: Run cargo build with devnet-prealloc feature run: cargo build --release --features devnet-prealloc --workspace --all --tests --benches @@ -125,6 +127,10 @@ jobs: - name: Run cargo doc tests with features=no-asm on kaspa-hashes run: cargo test --doc --release -p kaspa-hashes --features=no-asm + + - name: Run sccache stat for check + shell: bash + run: ${SCCACHE_PATH} --show-stats # test-release: # name: Test Suite Release @@ -177,31 +183,19 @@ jobs: lints: name: Lints - runs-on: ubuntu-latest + runs-on: ubuntu-latest # one os is okay for lints steps: - - name: Checkout sources - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Checkout sources + uses: actions/checkout@v3 - name: Run cargo fmt run: cargo fmt --all -- --check @@ -214,14 +208,18 @@ jobs: name: Check Wasm32 runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install llvm id: install_llvm continue-on-error: true @@ -244,26 +242,11 @@ jobs: sudo apt-get update sudo apt install -y gcc-multilib - - name: Install stable toolchain - if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success' - uses: dtolnay/rust-toolchain@stable - - name: Add wasm32 target run: rustup target add wasm32-unknown-unknown - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - # append here any new wasm32 crate not already covered by the existing checks - + - name: Run cargo check of kaspa-wrpc-wasm for wasm32 target run: cargo clippy -p kaspa-wrpc-wasm --target wasm32-unknown-unknown @@ -277,13 +260,25 @@ jobs: name: Build Wasm32 runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - name: Configure sccache env var + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 - name: Install llvm id: install_llvm @@ -307,56 +302,90 @@ jobs: sudo apt-get update sudo apt install -y gcc-multilib - - name: Install stable toolchain - if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success' - uses: dtolnay/rust-toolchain@stable - - name: Install wasm-pack run: cargo install wasm-pack - name: Add wasm32 target run: rustup target add wasm32-unknown-unknown - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build wasm pack for nodejs run: cd wasm && wasm-pack build --target nodejs --out-dir nodejs/kaspa --features full build-release: - name: Build Ubuntu Release - runs-on: ubuntu-latest + name: Release + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] steps: - - name: Checkout sources - uses: actions/checkout@v3 + # Clean unnecessary files to save disk space + - name: clean unnecessary files to save space + if: runner.os == 'Linux' + run: | + docker rmi `docker images -q` + sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d + sudo apt -y autoremove --purge + sudo apt -y autoclean + sudo apt clean + rm --recursive --force "$AGENT_TOOLSDIRECTORY" + df -h + + # remove large packages manually (all but llvm) + sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..." + sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..." + sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..." + sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..." + df -h + + # Free up disk space on Ubuntu + - name: Free Disk Space (Ubuntu) + if: runner.os == 'Linux' + uses: jlumbroso/free-disk-space@main + with: + # This might remove tools that are actually needed, if set to "true" but frees about 6 GB + tool-cache: false + + # large packages, except llvm, are removed manually during the previous step + # see: https://github.com/jlumbroso/free-disk-space/issues/6 + # TODO: use the discussed whitelist feature when available + large-packages: false + + swap-storage: true + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable - name: Install Protoc uses: arduino/setup-protoc@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable + - name: Checkout sources + uses: actions/checkout@v3 - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + uses: Swatinem/rust-cache@v2 + + - name: Configure sccache env var + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install zig if: runner.os == 'Linux' uses: goto-bus-stop/setup-zig@v2 # needed for cargo-zigbuild @@ -367,3 +396,15 @@ jobs: run: | cargo install cargo-zigbuild cargo --verbose zigbuild --bin kaspad --bin simpa --bin rothschild --release --target x86_64-unknown-linux-gnu.2.27 # Use an older glibc version + + - name: Build on MacOS + if: runner.os == 'MacOS' + run: cargo build --release + + - name: Build on Windows + if: runner.os == 'Windows' + run: cargo build --release + + - name: Run sccache stat for check + shell: bash + run: ${SCCACHE_PATH} --show-stats