Skip to content

Commit

Permalink
Pipe through env vars to control versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Jul 4, 2024
1 parent 40be0b8 commit f77a0b3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests-mac-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
# x86-64 runner
runs-on: macos-13
env:
APOLLO_ROVER_DEV_ROUTER_VERSION: ${{ matrix.router-version }}
APOLLO_ROVER_DEV_COMPOSITION_VERSION: ${{ matrix.composition-version }}
TEST_ROUTER_VERSION: ${{ matrix.router-version }}
TEST_COMPOSITION_VERSION: ${{ matrix.composition-version }}
ROVER_BINARY: ../../artifact/rover
FLYBY_APOLLO_KEY: ${{ secrets.FLYBY_APOLLO_KEY }}
steps:
Expand All @@ -76,4 +76,4 @@ jobs:
- name: Run Integration tests
run: |
chmod +x ./artifact/{rover,xtask}
./artifact/xtask integration-test --binary_path ./artifact/rover
./artifact/xtask integration-test
17 changes: 16 additions & 1 deletion xtask/src/commands/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use anyhow::Result;
use camino::Utf8PathBuf;
use clap::Parser;
Expand Down Expand Up @@ -29,7 +31,20 @@ impl IntegrationTest {
crate::info!("skipping flyby tests, to run unset SKIP_NPM_TESTS",);
} else {
let npm_runner = NpmRunner::new()?;
npm_runner.flyby()?;
let mut env_map = HashMap::new();
if std::env::var("TEST_COMPOSITION_VERSION").is_some() {

Check failure on line 35 in xtask/src/commands/integration_test.rs

View workflow job for this annotation

GitHub Actions / tests-mac-x86 / Build Rover for macOS x86-64

no method named `is_some` found for enum `Result` in the current scope
env_map.insert(

Check failure on line 36 in xtask/src/commands/integration_test.rs

View workflow job for this annotation

GitHub Actions / tests-mac-x86 / Build Rover for macOS x86-64

mismatched types
"APOLLO_ROVER_DEV_COMPOSITION_VERSION",
std::env::var("COMPOSITION_VERSION").unwrap(),
)
}
if std::env::var("TEST_ROUTER_VERSION").is_some() {

Check failure on line 41 in xtask/src/commands/integration_test.rs

View workflow job for this annotation

GitHub Actions / tests-mac-x86 / Build Rover for macOS x86-64

no method named `is_some` found for enum `Result` in the current scope
env_map.insert(

Check failure on line 42 in xtask/src/commands/integration_test.rs

View workflow job for this annotation

GitHub Actions / tests-mac-x86 / Build Rover for macOS x86-64

mismatched types
"APOLLO_ROVER_DEV_ROUTER_VERSION",
std::env::var("ROUTER_VERSION").unwrap(),
)
}
npm_runner.flyby(Some(env_map))?;

Check failure on line 47 in xtask/src/commands/integration_test.rs

View workflow job for this annotation

GitHub Actions / tests-mac-x86 / Build Rover for macOS x86-64

mismatched types
}

if std::env::var_os("CAN_RUN_DOCKER").is_some() {
Expand Down
41 changes: 26 additions & 15 deletions xtask/src/tools/npm.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::collections::HashMap;
use std::{fs, str};

use anyhow::{anyhow, Context, Result};
use camino::Utf8PathBuf;
use rover_std::Fs;
use which::which;

use std::{fs, str};
use rover_std::Fs;

use crate::info;
use crate::{
Expand Down Expand Up @@ -107,21 +109,21 @@ impl NpmRunner {
}

// this command runs integration tests with a test account in Apollo Studio with the flyby demo
pub(crate) fn flyby(&self) -> Result<()> {
pub(crate) fn flyby(&self, env: Option<&HashMap<String, String>>) -> Result<()> {
let run_studio_tests = || -> Result<()> {
self.require_volta()?;
self.npm_exec(&["install"], &self.flyby_directory)?;
self.npm_exec(&["run", "compose:file"], &self.flyby_directory)?;
self.npm_exec(&["run", "compose:graphref"], &self.flyby_directory)?;
self.npm_exec(&["run", "compose:introspect"], &self.flyby_directory)?;
self.npm_exec(&["run", "compose:broken"], &self.flyby_directory)?;
self.npm_exec(&["run", "locations:check"], &self.flyby_directory)?;
self.npm_exec(&["run", "locations:publish"], &self.flyby_directory)?;
self.npm_exec(&["run", "locations:fetch"], &self.flyby_directory)?;
self.npm_exec(&["run", "reviews:check"], &self.flyby_directory)?;
self.npm_exec(&["run", "reviews:publish"], &self.flyby_directory)?;
self.npm_exec(&["run", "reviews:fetch"], &self.flyby_directory)?;
self.npm_exec(&["run", "broken:check"], &self.flyby_directory)?;
self.npm_exec_with_env(&["run", "compose:file"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "compose:graphref"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "compose:introspect"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "compose:broken"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "locations:check"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "locations:publish"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "locations:fetch"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "reviews:check"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "reviews:publish"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "reviews:fetch"], &self.flyby_directory, env)?;
self.npm_exec_with_env(&["run", "broken:check"], &self.flyby_directory, env)?;
Ok(())
};
if std::env::var_os("FLYBY_APOLLO_KEY").is_some()
Expand Down Expand Up @@ -181,7 +183,16 @@ impl NpmRunner {
}

fn npm_exec(&self, args: &[&str], directory: &Utf8PathBuf) -> Result<CommandOutput> {
self.runner.exec(args, directory, None)
self.npm_exec_with_env(args, directory, None)
}

fn npm_exec_with_env(
&self,
args: &[&str],
directory: &Utf8PathBuf,
env: Option<&HashMap<String, String>>,
) -> Result<CommandOutput> {
self.runner.exec(args, directory, env)
}
}

Expand Down

0 comments on commit f77a0b3

Please sign in to comment.