Skip to content

Commit

Permalink
Add check for binary compatibility by building a small sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Nov 29, 2022
1 parent 3f2397e commit 06bf7e6
Show file tree
Hide file tree
Showing 6 changed files with 1,570 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
options: --volume ${{ github.workspace }}:/work:rw --workdir /work --privileged --env CARGO_TERM_COLOR=always
run: gitleaks detect --verbose --config .github/workflows/config/gitleaks.toml

- name: Install Prerequisites
- name: Install prerequisites
run: bin/check/install_prerequisites.sh

- name: Rustfmt
Expand All @@ -58,6 +58,9 @@ jobs:
- name: Check crates licence
run: python3 bin/check/license.py

- name: Check hurl crate API changes
run: bin/check/compatibility.sh

- name: Check CHANGELOG
run: bin/check/changelog.sh

54 changes: 54 additions & 0 deletions bin/check/compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -eu

get_sample_crate_version() {
crate="$1"
version=$(grep --regexp "^$crate = " contrib/sample/Cargo.toml | cut --delimiter ' ' --field 3 | sed 's/"//g')
echo "$version"
}

get_snapshot_crate_version() {
crate="$1"
version=$(grep --regexp '^version = ' "packages/$crate/Cargo.toml" | cut --delimiter '"' --field 2)
echo "$version"
}

get_major() {
version="$1"
major=$(echo "$version" | cut --delimiter '.' --field 1)
echo "$major"
}

# Extract sample and snapshots versions
hurl_sample_version=$(get_sample_crate_version "hurl")
hurl_sample_major=$(get_major "$hurl_sample_version")
hurl_snapshot_version=$(get_snapshot_crate_version "hurl")
hurl_snapshot_major=$(get_major "$hurl_snapshot_version")
echo "hurl (sample) major=$hurl_sample_major ($hurl_sample_version)"
echo "hurl (SNAPSHOT) major=$hurl_snapshot_major ($hurl_snapshot_version)"

hurl_core_sample_version=$(get_sample_crate_version "hurl_core")
hurl_core_sample_major=$(get_major "$hurl_core_sample_version")
hurl_core_snapshot_version=$(get_snapshot_crate_version "hurl_core")
hurl_core_snapshot_major=$(get_major "$hurl_core_snapshot_version")
echo "hurl_core (sample) major=$hurl_core_sample_major ($hurl_core_sample_version)"
echo "hurl_core (SNAPSHOT) major=$hurl_core_snapshot_major ($hurl_core_snapshot_version)"

if [ "$hurl_sample_major" != "$hurl_snapshot_major" ] && [ "$hurl_core_sample_major" != "$hurl_core_snapshot_major" ];then
echo "Major versions are different, no need to check crates compatibility"
exit 0
else
echo "Major versions are equal, check crates compatibility"
fi



# Replace versions for our sample
sed -i -- "s/hurl = \"[0-9.]*\"/hurl = { version = \"$hurl_snapshot_version\", path = \"..\/..\/packages\/hurl\" }/" contrib/sample/Cargo.toml
sed -i -- "s/hurl_core = \"[0-9.]*\"/hurl_core = { version = \"$hurl_core_snapshot_version\", path = \"..\/..\/packages\/hurl_core\" }/" contrib/sample/Cargo.toml

cd contrib/sample || exit
cargo clean
cargo update
cargo build
cargo run -- hello.hurl
Loading

0 comments on commit 06bf7e6

Please sign in to comment.