diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74b7d38..ff364a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,12 +37,12 @@ jobs: - name: Install JS dependencies run: pnpm install - - name: Build UI assets - run: pnpm build - - name: Format UI assets run: pnpm fmt:check + - name: Build UI assets + run: pnpm build + - name: Install Rust uses: dtolnay/rust-toolchain@master with: @@ -57,10 +57,10 @@ jobs: name: assets path: src/html/assets.rs - check: - name: Build and test - + build: + name: Build runs-on: ubuntu-latest + strategy: matrix: rust: @@ -105,40 +105,66 @@ jobs: target key: cargo-build-${{ runner.os }}-${{ matrix.rust }} + - name: Build code + run: cargo build + + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: binary-${{ matrix.rust }} + path: target/debug/margo + + check: + name: Check + runs-on: ubuntu-latest + + needs: build + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download assets + uses: actions/download-artifact@v4 + with: + name: assets + path: src/html + + - name: Download binary + uses: actions/download-artifact@v4 + with: + name: binary-stable + path: margo + + - name: Register binary + run: | + echo "MARGO_BINARY=$(pwd)/margo" >> $GITHUB_ENV + chmod +x "${MARGO_BINARY}" + - name: Cargo cache (build conformance) uses: actions/cache@v4 with: path: |- conformance/target key: cargo-build-conformance-${{ runner.os }}-${{ matrix.rust }} - if: ${{ matrix.rust == 'stable' }} - - - name: Build code - run: cargo build - name: Format code run: cargo fmt --all -- --check - if: ${{ matrix.rust == 'stable' }} - name: Lint code run: cargo clippy -- -D warnings - if: ${{ matrix.rust == 'stable' }} - name: Test conformance run: cd conformance && cargo run - if: ${{ matrix.rust == 'stable' }} - name: Install Ruby uses: ruby/setup-ruby@v1 with: working-directory: integration-tests bundler-cache: true - if: ${{ matrix.rust == 'stable' }} - - - name: Test UI - run: cd integration-tests && bundle exec rspec - if: ${{ matrix.rust == 'stable' }} - name: Lint UI Tests run: cd integration-tests && bundle exec rubocop - if: ${{ matrix.rust == 'stable' }} + + - name: Test UI + run: cd integration-tests && bundle exec rspec diff --git a/conformance/src/main.rs b/conformance/src/main.rs index e395b46..4966595 100644 --- a/conformance/src/main.rs +++ b/conformance/src/main.rs @@ -4,14 +4,16 @@ use axum::Router; use registry_conformance::{CommandExt, CreatedCrate, Registry}; use snafu::prelude::*; -use std::{future::IntoFuture, io, net::SocketAddr, path::PathBuf, process::ExitCode}; +use std::{env, future::IntoFuture, io, net::SocketAddr, path::{Path, PathBuf}, process::ExitCode}; use tokio::{net::TcpListener, process::Command, task::JoinHandle}; use tokio_util::sync::CancellationToken; use tower_http::services::ServeDir; #[tokio::main] async fn main() -> Result { - Margo::build().await?; + if env::var_os("MARGO_BINARY").is_none() { + Margo::build().await?; + } Ok(registry_conformance::test_conformance::(std::env::args()).await) } @@ -109,7 +111,10 @@ impl Margo { } fn command(&self) -> Command { - let mut cmd = Command::new(Self::EXE_PATH); + let exe_path = env::var_os("MARGO_BINARY").map(PathBuf::from); + let exe_path = exe_path.as_deref().unwrap_or_else(|| Path::new(Self::EXE_PATH)); + + let mut cmd = Command::new(exe_path); cmd.kill_on_drop(true); diff --git a/integration-tests/spec/spec_helper.rb b/integration-tests/spec/spec_helper.rb index 6f9efad..5559115 100644 --- a/integration-tests/spec/spec_helper.rb +++ b/integration-tests/spec/spec_helper.rb @@ -30,13 +30,17 @@ config.order = :random Kernel.srand config.seed - config.before(:suite) do - system( - 'cargo', 'build', - exception: true, - ) + unless ENV.has_key?('MARGO_BINARY') + config.before(:suite) do + system( + 'cargo', 'build', + exception: true, + ) + end end end +MARGO_BINARY = ENV.fetch('MARGO_BINARY', '../target/debug/margo') + Capybara.default_driver = Capybara.javascript_driver = :selenium_headless Capybara.run_server = false diff --git a/integration-tests/spec/support/crate.rb b/integration-tests/spec/support/crate.rb index 45e22c2..f8d2cdc 100644 --- a/integration-tests/spec/support/crate.rb +++ b/integration-tests/spec/support/crate.rb @@ -41,7 +41,7 @@ def publish_to(registry) package = @root.join('target', 'package', "#{name}-#{version}.crate") system( - '../target/debug/margo', + MARGO_BINARY, 'add', '--registry', registry.root.to_s, diff --git a/integration-tests/spec/support/registry.rb b/integration-tests/spec/support/registry.rb index f1f3dfc..72e386f 100644 --- a/integration-tests/spec/support/registry.rb +++ b/integration-tests/spec/support/registry.rb @@ -13,7 +13,7 @@ def initialize(root) def start @server.start system( - '../target/debug/margo', + MARGO_BINARY, 'init', '--base-url', url,