-
Notifications
You must be signed in to change notification settings - Fork 258
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
Modification in bats.yaml #35136
base: main
Are you sure you want to change the base?
Modification in bats.yaml #35136
Conversation
Signed-off-by: anushkamittal20 <[email protected]>
Signed-off-by: anushkamittal20 <[email protected]>
Signed-off-by: anushkamittal20 <[email protected]>
- runs: | | ||
mkdir -p "${{targets.contextdir}}/opt/bats/" | ||
find . -maxdepth 1 -not -name '.' -not -name 'melange-out' -not -name '*.tmp' -not -name '*.log' \ | ||
-exec mv {} "${{targets.contextdir}}/opt/bats/" \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended that we move over everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey RJ, thanks for the review. The reason we needed to add all of this was to match the upstream image. https://github.com/bats-core/bats-core/blob/master/Dockerfile where the entire repo is shifted and the link that I created above is also created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, could we remove the .git folder? And anything else it may not actually be using at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compared the dir in my image:
bash-5.2$ ls /opt/bats
AUTHORS docker man
Dockerfile docker-compose.override.dist package.json
LICENSE.md docker-compose.yml shellcheck.sh
README.md docs test
SECURITY.md install.sh uninstall.sh
bin lib
contrib libexec
vs upstream
/code # ls /opt/bats
AUTHORS bin docs package.json
Dockerfile contrib install.sh shellcheck.sh
LICENSE.md docker lib test
README.md docker-compose.override.dist libexec uninstall.sh
SECURITY.md docker-compose.yml man
both are the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I explicitly look at removing items?
Signed-off-by: anushkamittal20 <[email protected]>
29f7d1f
to
59aa98f
Compare
Signed-off-by: anushkamittal20 <[email protected]>
1d794fb
to
9da964a
Compare
Signed-off-by: anushkamittal20 <[email protected]>
Signed-off-by: anushkamittal20 <[email protected]>
./install.sh "${{targets.contextdir}}/usr" | ||
./install.sh "${{targets.contextdir}}/usr" | ||
mkdir -p "${{targets.contextdir}}/tmp/" | ||
cp -r ./docker "${{targets.contextdir}}/tmp/docker" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/bats-core/bats-core/blob/89a7fae3b651d5c2f42a3874ec32e821014814eb/docker/install_libs.sh#L32 I saw that it downloads the files from their own repositories like https://github.com/bats-core/bats-support, so creating a separate packages for them like support, file, assert and detik would be great cuz in that case it'd be easier to keep these things in sync when there is a new version come up, but I'm not certain though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean like subpackages or completely new packages?
@@ -1,24 +1,22 @@ | |||
package: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writing some tests would be great here:
for example:
cat < example.sh
#!/bin/bash
Function to add two numbers
add_numbers() {
echo $(( $1 + $2 ))
}
Function to check if a file exists
file_exists() {
if [[ -f "$1" ]]; then
echo "true"
else
echo "false"
fi
}
Function to check if a string contains another string
string_contains() {
if [[ "$1" == "$2" ]]; then
echo "true"
else
echo "false"
fi
}
EOF
cat <
#!/usr/bin/env bats
Load the script to test
load_file() {
source "./example.sh"
}
setup() {
# This runs before every test
load_file
}
teardown() {
# This runs after every test
rm -f testfile.txt
}
@test "add_numbers should correctly add two numbers" {
run add_numbers 3 5
[ "$status" -eq 0 ]
[ "$output" -eq 8 ]
}
@test "file_exists should return true for existing file" {
touch testfile.txt
run file_exists testfile.txt
[ "$status" -eq 0 ]
[ "$output" = "true" ]
}
@test "file_exists should return false for non-existing file" {
run file_exists non_existing_file.txt
[ "$status" -eq 0 ]
[ "$output" = "false" ]
}
@test "string_contains should return true if substring is found" {
run string_contains "hello world" "hello"
[ "$status" -eq 0 ]
[ "$output" = "true" ]
}
@test "string_contains should return false if substring is not found" {
run string_contains "hello world" "bye"
[ "$status" -eq 0 ]
[ "$output" = "false" ]
}
EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing!
Signed-off-by: anushkamittal20 <[email protected]>
Adds a more detailed bats package to match upstream