diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4d711e294..05ff3c13f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1099,47 +1099,16 @@ jobs: - uses: actions/download-artifact@v4 with: name: wasmer-cli-linux-x64 - - name: Cargo Registry Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/advisory-db - ~/.cargo/git - ~/.cargo/registry - key: cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - name: Cargo target cache - uses: actions/cache@v3 - with: - path: | - target/ - key: cargo-release-${{ hashFiles('**/Cargo.lock') }} + - uses: wasmerio/setup-wasmer@v2 + - uses: denoland/setup-deno@v1 - run: | - # install rust toolchain - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - . "$HOME/.cargo/env" - - # add wasmer cli to PATH tar -xzf build-wasmer.tar.gz - - docker build -t tmp . - docker run -v $PWD:/app -w /app tmp bash -c " \ - cp ./bin/wasmer /root/.wasmer/bin/wasmer &&\ - export MYSQL_HOST='${{ vars.INTEGRATION_TEST_MYSQL_HOST }}' &&\ - export MYSQL_DBNAME='${{ vars.INTEGRATION_TEST_MYSQL_DBNAME }}' &&\ - export MYSQL_USERNAME='${{ secrets.INTEGRATION_TEST_MYSQL_USERNAME }}' &&\ - export MYSQL_PASSWORD='${{ secrets.INTEGRATION_TEST_MYSQL_PASSWORD }}' &&\ - export MYSQL_PORT='${{ vars.INTEGRATION_TEST_MYSQL_PORT }}' &&\ - export MYSQL_CERT='${{ secrets.INTEGRATION_TEST_MYSQL_CERT }}' &&\ - export PG_HOST='${{ vars.INTEGRATION_TEST_PG_HOST }}' &&\ - export PG_DBNAME='${{ vars.INTEGRATION_TEST_PG_DBNAME }}' &&\ - export PG_USERNAME='${{ secrets.INTEGRATION_TEST_PG_USERNAME }}' &&\ - export PG_PASSWORD='${{ secrets.INTEGRATION_TEST_PG_PASSWORD }}' &&\ - export PG_PORT='${{ vars.INTEGRATION_TEST_PG_PORT }}' &&\ - wasmer config set registry.url https://registry.wasmer.io/graphql &&\ - wasmer login '${{ secrets.WAPM_PROD_TOKEN }}' &&\ - wasmer config set registry.url https://registry.wasmer.wtf/graphql &&\ - wasmer login '${{ secrets.WAPM_DEV_TOKEN }}' &&\ - cargo test --no-fail-fast" + cp ./bin/wasmer ~/.wasmer/bin/wasmer + - name: test + env: + WASMER_REGISTRY: https://registry.wasmer.wtf/graphql + WASMER_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }} + run: deno test --allow-all --parallel - name: notify failure in slack if: failure() run: | diff --git a/Cargo.lock b/Cargo.lock index 2557b1220..78ebc9526 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2372,7 +2372,7 @@ dependencies = [ "http", "hyper", "hyper-util", - "rustls 0.23.17", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -2901,7 +2901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -3978,7 +3978,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.0.0", - "rustls 0.23.17", + "rustls 0.23.19", "socket2", "thiserror 2.0.3", "tokio", @@ -3996,8 +3996,7 @@ dependencies = [ "rand", "ring", "rustc-hash 2.0.0", - "rustls 0.23.17", - "rustls-pki-types", + "rustls 0.23.19", "slab", "thiserror 2.0.3", "tinyvec", @@ -4246,7 +4245,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.17", + "rustls 0.23.19", "rustls-pemfile", "rustls-pki-types", "serde", @@ -4418,9 +4417,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.17" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -5388,7 +5387,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.17", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -5459,7 +5458,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.17", + "rustls 0.23.19", "rustls-native-certs", "rustls-pki-types", "tokio", @@ -5744,7 +5743,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.17", + "rustls 0.23.19", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -5998,7 +5997,7 @@ dependencies = [ "flate2", "log", "once_cell", - "rustls 0.23.17", + "rustls 0.23.19", "rustls-pki-types", "url", "webpki-roots", diff --git a/lib/config/src/package/named_package_ident.rs b/lib/config/src/package/named_package_ident.rs index d1c9fa6e2..151ec1faa 100644 --- a/lib/config/src/package/named_package_ident.rs +++ b/lib/config/src/package/named_package_ident.rs @@ -172,6 +172,24 @@ impl NamedPackageIdent { out } + + /// Returns true if this ident matches the given package id. + /// + /// Semver constraints are matched against the package id's version. + pub fn matches_id(&self, id: &NamedPackageId) -> bool { + if self.full_name() == id.full_name { + if let Some(tag) = &self.tag { + match tag { + Tag::Named(n) => n == &id.version.to_string(), + Tag::VersionReq(v) => v.matches(&id.version), + } + } else { + true + } + } else { + false + } + } } impl From for NamedPackageIdent { @@ -443,4 +461,23 @@ mod tests { let ident2 = serde_json::from_str::(&raw).unwrap(); assert_eq!(ident, ident2); } + + #[test] + fn test_named_package_ident_matches_id() { + assert!(NamedPackageIdent::from_str("ns/name") + .unwrap() + .matches_id(&NamedPackageId::try_new("ns/name", "0.1.0").unwrap())); + + assert!(NamedPackageIdent::from_str("ns/name") + .unwrap() + .matches_id(&NamedPackageId::try_new("ns/name", "1.0.1").unwrap())); + + assert!(NamedPackageIdent::from_str("ns/name@1") + .unwrap() + .matches_id(&NamedPackageId::try_new("ns/name", "1.0.1").unwrap())); + + assert!(!NamedPackageIdent::from_str("ns/name@2") + .unwrap() + .matches_id(&NamedPackageId::try_new("ns/name", "1.0.1").unwrap())); + } } diff --git a/lib/config/src/package/package_ident.rs b/lib/config/src/package/package_ident.rs index 5b03d6ef8..0e6a5544a 100644 --- a/lib/config/src/package/package_ident.rs +++ b/lib/config/src/package/package_ident.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use super::{NamedPackageIdent, PackageHash, PackageParseError}; +use super::{NamedPackageIdent, PackageHash, PackageId, PackageParseError}; #[derive(PartialEq, Eq, Clone, Debug, Hash)] pub enum PackageIdent { @@ -24,6 +24,17 @@ impl PackageIdent { None } } + + /// Returns true if this ident matches the given package id. + /// + /// Semver constraints are matched against the package id's version. + pub fn matches_id(&self, id: &PackageId) -> bool { + match (self, id) { + (Self::Named(a), PackageId::Named(b)) => a.matches_id(b), + (Self::Hash(a), PackageId::Hash(b)) => a == b, + _ => false, + } + } } impl From for PackageIdent { @@ -92,3 +103,23 @@ impl schemars::JsonSchema for PackageIdent { String::json_schema(gen) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_package_ident_matches_id() { + assert!(PackageIdent::from_str("ns/pkg") + .unwrap() + .matches_id(&PackageId::new_named("ns/pkg", "1.0.0".parse().unwrap()))); + + assert!(PackageIdent::from_str("ns/pkg@2") + .unwrap() + .matches_id(&PackageId::new_named("ns/pkg", "2.3.7".parse().unwrap()))); + + assert!(!PackageIdent::from_str("ns/pkg@3") + .unwrap() + .matches_id(&PackageId::new_named("ns/pkg", "2.3.7".parse().unwrap()))); + } +}