Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: update rust-toolchain file to TOML format #1511

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.68.2"
33 changes: 32 additions & 1 deletion tests/bats/common_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
parse_toml() {
local input=$1
local key=$2

# Using sed to extract the value of a specified key from Toml content
local value
value=$(echo "$input" | sed -n 's/.*'"$key"' = "\(.*\)"/\1/p')
# Remove quote
# shellcheck disable=SC2001
value=$(echo "$value" | sed 's/"//g')

echo "$value"
}

get_rust_toolcahin() {
local base_dir=$1
local toml_file="${base_dir}/rust-toolchain.toml"
local legacy_toml_file="${base_dir}/rust-toolchain"
local version

if [ -f "$toml_file" ]; then
local toml_content
toml_content=$(cat "$toml_file")
version=$(parse_toml "$toml_content" 'channel')
else
version=$(cat "$legacy_toml_file")
fi

echo "$version"
}

repo_base_dir="${BATS_TEST_DIRNAME}/../.."
rust_toolchain=$(cat ${repo_base_dir}/rust-toolchain)
rust_toolchain=$(get_rust_toolcahin "$repo_base_dir")
compile_image="localhost/compile-image:${rust_toolchain}"
nydus_snapshotter_repo="https://github.com/containerd/nydus-snapshotter.git"

Expand Down