-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Labels
compatibility-nonbreakingChanges that are (likely to be) non-breakingChanges that are (likely to be) non-breakingexperience-mediumThis issue is of medium difficulty, and requires some experienceThis issue is of medium difficulty, and requires some experiencehelp wantedExtra attention is neededExtra attention is needed
Description
In CI, we have the following job:
zerocopy/.github/workflows/ci.yml
Lines 334 to 408 in 3bb9a54
| check_versions: | |
| needs: generate_cache | |
| runs-on: ubuntu-latest | |
| name: Check crate versions match | |
| steps: | |
| - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
| - uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
| # Make sure that both crates are at the same version, and that zerocopy | |
| # depends exactly upon the current version of zerocopy-derive. See | |
| # `INTERNAL.md` for an explanation of why we do this. | |
| - name: Check crate versions match | |
| run: | | |
| set -eo pipefail | |
| # Usage: version <crate-name> | |
| function version { | |
| cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").version" | |
| } | |
| ver_zerocopy=$(version zerocopy) | |
| ver_zerocopy_derive=$(version zerocopy-derive) | |
| # The non-dev dependency version (`.kind == null` filters out the dev | |
| # dependency, and `.target == null` filters out the targeted version). | |
| zerocopy_derive_dep_ver=$(cargo metadata --format-version 1 \ | |
| | jq -r ".packages[] | select(.name == \"zerocopy\").dependencies[] | select((.name == \"zerocopy-derive\") and .kind == null and .target == null).req") | |
| # The non-dev dependency, targeted version. | |
| zerocopy_derive_targeted_ver=$(cargo metadata --format-version 1 \ | |
| | jq -r ".packages[] | select(.name == \"zerocopy\").dependencies[] | select((.name == \"zerocopy-derive\") and .kind == null and .target == \"cfg(any())\").req") | |
| # The dev dependency version (`.kind == \"dev\"` selects only the dev | |
| # dependency). | |
| zerocopy_derive_dev_dep_ver=$(cargo metadata --format-version 1 \ | |
| | jq -r ".packages[] | select(.name == \"zerocopy\").dependencies[] | select((.name == \"zerocopy-derive\") and .kind == \"dev\").req") | |
| if [[ "$ver_zerocopy" == "$ver_zerocopy_derive" ]]; then | |
| echo "Same crate version ($ver_zerocopy) found for zerocopy and zerocopy-derive." | tee -a $GITHUB_STEP_SUMMARY | |
| else | |
| echo "Different crate versions found for zerocopy ($ver_zerocopy) and zerocopy-derive ($ver_zerocopy_derive)." \ | |
| | tee -a $GITHUB_STEP_SUMMARY >&2 | |
| exit 1 | |
| fi | |
| # Note the leading `=` sign - the dependency needs to be an exact one. | |
| if [[ "=$ver_zerocopy_derive" == "$zerocopy_derive_dep_ver" ]]; then | |
| echo "zerocopy depends upon same version of zerocopy-derive in-tree ($zerocopy_derive_dep_ver)." | tee -a $GITHUB_STEP_SUMMARY | |
| else | |
| echo "zerocopy depends upon different version of zerocopy-derive ($zerocopy_derive_dep_ver) than the one in-tree ($ver_zerocopy_derive)." \ | |
| | tee -a $GITHUB_STEP_SUMMARY >&2 | |
| exit 1 | |
| fi | |
| if [[ "=$ver_zerocopy_derive" == "$zerocopy_derive_dev_dep_ver" ]]; then | |
| echo "In dev mode, zerocopy depends upon same version of zerocopy-derive in-tree ($zerocopy_derive_dev_dep_ver)." | tee -a $GITHUB_STEP_SUMMARY | |
| else | |
| echo "In dev mode, zerocopy depends upon different version of zerocopy-derive ($zerocopy_derive_dev_dep_ver) than the one in-tree ($ver_zerocopy_derive)." \ | |
| | tee -a $GITHUB_STEP_SUMMARY >&2 | |
| exit 1 | |
| fi | |
| if [[ "$zerocopy_derive_dep_ver" == "$zerocopy_derive_targeted_ver" ]]; then | |
| echo "Same crate version ($zerocopy_derive_dep_ver) found for optional and targeted zerocopy-derive dependency." \ | |
| | tee -a $GITHUB_STEP_SUMMARY | |
| else | |
| echo "Different crate versions found for optional ($zerocopy_derive_dep_ver) and targeted ($zerocopy_derive_targeted_ver) dependency." \ | |
| | tee -a $GITHUB_STEP_SUMMARY >&2 | |
| exit 1 | |
| fi |
Over time, it has grown to contain a lot of duplicated code. The task for this issue is to deduplicate where it makes sense to do so using whatever techniques are appropriate (e.g., bash functions, etc).
Metadata
Metadata
Assignees
Labels
compatibility-nonbreakingChanges that are (likely to be) non-breakingChanges that are (likely to be) non-breakingexperience-mediumThis issue is of medium difficulty, and requires some experienceThis issue is of medium difficulty, and requires some experiencehelp wantedExtra attention is neededExtra attention is needed