From 0d730bc5cdafa3b862e4aa16225d4d0117ccf461 Mon Sep 17 00:00:00 2001 From: Arya Date: Mon, 4 Nov 2024 13:52:00 -0500 Subject: [PATCH 1/3] Adds a test to check for crates in the Cargo.lock file that are being pulled in from a git source. --- zebrad/tests/acceptance.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 1a8cefbe0b2..3dfc959eb58 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -3538,3 +3538,15 @@ async fn nu6_funding_streams_and_coinbase_balance() -> Result<()> { Ok(()) } + +/// Check that Zebra does not depend on any crates from git sources. +#[test] +#[ignore] +fn check_no_git_refs_in_cargo_lock() { + let cargo_lock_contents = + fs::read_to_string("../Cargo.lock").expect("should have Cargo.lock file in root dir"); + + if cargo_lock_contents.contains(r#"source = "git+"#) { + panic!("Cargo.lock includes git sources") + } +} From 77dbf9de397e018eaa61c1c23170f504b76df21b Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 20 Nov 2024 16:22:41 -0300 Subject: [PATCH 2/3] add `check_no_git_refs_in_cargo_lock` to CI --- .github/workflows/sub-ci-unit-tests-docker.yml | 9 +++++++++ docker/entrypoint.sh | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sub-ci-unit-tests-docker.yml b/.github/workflows/sub-ci-unit-tests-docker.yml index dd6c89a5a75..da69d12e286 100644 --- a/.github/workflows/sub-ci-unit-tests-docker.yml +++ b/.github/workflows/sub-ci-unit-tests-docker.yml @@ -197,3 +197,12 @@ jobs: # If there is already an open issue with this label, any failures become comments on that issue. always-create-new-issue: false github-token: ${{ secrets.GITHUB_TOKEN }} + + run-check-no-git-refs: + if: contains(github.event.pull_request.labels.*.name, 'A-release') + runs-on: ubuntu-latest + steps: + - name: Run check_no_git_refs_in_cargo_lock + run: | + docker pull ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}@${{ inputs.image_digest }} + docker run --tty -e NETWORK -e RUN_CHECK_NO_GIT_REFS=1 ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}@${{ inputs.image_digest }} diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index dc1dbc121cf..e5d51e58eb3 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -224,12 +224,16 @@ case "$1" in if [[ "${RUN_ALL_TESTS}" -eq "1" ]]; then # Run unit, basic acceptance tests, and ignored tests, only showing command output if the test fails. # If the lightwalletd environmental variables are set, we will also run those tests. - exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES}" --workspace -- --nocapture --include-ignored + exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES}" --workspace -- --nocapture --include-ignored --exclude check_no_git_refs_in_cargo_lock elif [[ "${RUN_ALL_EXPERIMENTAL_TESTS}" -eq "1" ]]; then # Run unit, basic acceptance tests, and ignored tests with experimental features. # If the lightwalletd environmental variables are set, we will also run those tests. - exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES_EXPERIMENTAL}" --workspace -- --nocapture --include-ignored + exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES_EXPERIMENTAL}" --workspace -- --nocapture --include-ignored --exclude check_no_git_refs_in_cargo_lock + + elif [[ "${RUN_CHECK_NO_GIT_REFS}" -eq "1" ]]; then + # Run the check_no_git_refs_in_cargo_lock test. + exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES}" --workspace -- --nocapture --include-ignored check_no_git_refs_in_cargo_lock elif [[ "${TEST_FAKE_ACTIVATION_HEIGHTS}" -eq "1" ]]; then # Run state tests with fake activation heights. From 0a5d703be49b2f93b32ac2347253ce2628060a5e Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 20 Nov 2024 16:55:21 -0300 Subject: [PATCH 3/3] try skip instead of exclude --- docker/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e5d51e58eb3..ccd09f43c33 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -224,12 +224,12 @@ case "$1" in if [[ "${RUN_ALL_TESTS}" -eq "1" ]]; then # Run unit, basic acceptance tests, and ignored tests, only showing command output if the test fails. # If the lightwalletd environmental variables are set, we will also run those tests. - exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES}" --workspace -- --nocapture --include-ignored --exclude check_no_git_refs_in_cargo_lock + exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES}" --workspace -- --nocapture --include-ignored --skip check_no_git_refs_in_cargo_lock elif [[ "${RUN_ALL_EXPERIMENTAL_TESTS}" -eq "1" ]]; then # Run unit, basic acceptance tests, and ignored tests with experimental features. # If the lightwalletd environmental variables are set, we will also run those tests. - exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES_EXPERIMENTAL}" --workspace -- --nocapture --include-ignored --exclude check_no_git_refs_in_cargo_lock + exec cargo test --locked --release --features "${ENTRYPOINT_FEATURES_EXPERIMENTAL}" --workspace -- --nocapture --include-ignored --skip check_no_git_refs_in_cargo_lock elif [[ "${RUN_CHECK_NO_GIT_REFS}" -eq "1" ]]; then # Run the check_no_git_refs_in_cargo_lock test.