Skip to content

Commit

Permalink
add(ci): Check that dependencies have all been published to crates.io…
Browse files Browse the repository at this point in the history
… on release PRs (#8992)

* Adds a test to check for crates in the Cargo.lock file that are being pulled in from a git source.

* add `check_no_git_refs_in_cargo_lock` to CI

* try skip instead of exclude

---------

Co-authored-by: Alfredo Garcia <[email protected]>
  • Loading branch information
arya2 and oxarbitrage authored Nov 27, 2024
1 parent 0af0742 commit 8cfb61f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/sub-ci-unit-tests-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
8 changes: 6 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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
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.
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.
Expand Down
12 changes: 12 additions & 0 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 8cfb61f

Please sign in to comment.