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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add yq to act and custom #117

Merged
merged 6 commits into from
Nov 19, 2023
Merged

Conversation

Beanow
Copy link
Contributor

@Beanow Beanow commented Nov 3, 2023

Resolves #78

I gave this a simple test build locally (linux x86_64).

docker build -f linux/ubuntu/Dockerfile \
--build-arg FROM_IMAGE=buildpack-deps \
--build-arg FROM_TAG=22.04 \
--build-arg TYPE=act \
-t test-act \
.

#         馃Ж Executing yq.sh 馃Ж
# + /imagegeneration/installers/yq.sh
# Downloading 'https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64' to '/tmp/yq'...
# Download completed
# Performing checksum verification
# Checksum verification passed

docker run --rm test-act yq --version
# yq (https://github.com/mikefarah/yq/) version v4.35.2

Since there's a lot of hard-coded references to this path.
Unlike upstream we detect the arch suffix here.
@Beanow
Copy link
Contributor Author

Beanow commented Nov 3, 2023

11 minutes of pulling later... can confirm it's the same as:

docker run --rm catthehacker/ubuntu:full-latest yq --version
# yq (https://github.com/mikefarah/yq/) version v4.35.2

Comment on lines 141 to 158
case "$(uname -m)" in
'aarch64')
scripts=(
yq
)
;;
'x86_64')
scripts=(
yq
)
;;
*) exit 1 ;;
esac

for SCRIPT in "${scripts[@]}"; do
printf "\n\t馃Ж Executing %s.sh 馃Ж\t\n" "${SCRIPT}"
"/imagegeneration/installers/${SCRIPT}.sh"
done
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks building on any arch other than aarch64/x86_64

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially a problem, because the act base image is built for armhf, aarch64 and x86_64.

The flavour images are not built for armhf and usually don't work on any arch other than aarch64 (rust image not built due to cpu intensive compiling in qemu)/x86_64.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point, I looked at the wrong matrix. The yq script already supports arm/v7.
I'll have a look at updating the cases.

Does this approach otherwise look OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the missing arch

Copy link
Collaborator

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts from my side...

I would be careful if you remove double quotes in bash, have bad experience in the past.

else
local ERR_EXIT_ENABLED=false
fi
set +e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add ERR_EXIT_ENABLED if it is ignored in the first iteration due to unconditional set +e?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this script aren't my own. They're from the upstream repository.

Primary reason I found the sync was necessary was because checksum validation code was added and used for the yq download.

I'll have to defer to the blame upstream for your questions though :]

Here it's actions/runner-images#8352

Copy link
Contributor Author

@Beanow Beanow Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, I'm not defending the decisions upstream. I don't have an opinion on the suggestions you made here.

But I think there's maintenance tradeoffs between how closely you want to track the other repo. So I feel the decision to diverge and track our own patches here should be up to the maintainers and not me :]

Feel free to edit, or request changes.

@@ -49,21 +57,156 @@ download_with_retries() {
## echo "packageName is not installed!"
## fi
IsPackageInstalled() {
dpkg -S "$1" &>/dev/null
dpkg -S $1 &> /dev/null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary to remove quotes?

Removing quotes in bash is dangerous.

Example:

listargs() { while [[ -n "$1" ]]; do echo $1; shift; done };
IsPackageInstalled() { listargs -S $1; } ;
IsPackageInstalled "hello or";

argument hello or ends up beeing interpreted by bash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems upstream this was never quoted.

I found this, but is just a move. The code before was initial commit.
actions/runner-images@a7ee8ab

@@ -41,9 +41,10 @@ case "$(uname -m)" in
go
js
dotnet
yq
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to install yq twice in the custom image?

act-latest is the base of custom-latest, js-latest, go-latest and so on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. That's just me being unfamiliar in the codebase 馃槀

external_hash=$(get_hash_from_remote_file "${base_url}/checksums" "${filename} " "" " " "19")
use_checksum_comparison "/tmp/yq" "${external_hash}"
# Install YQ
sudo install /tmp/yq /usr/bin/yq
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe /usr/local/bin/yq to avoid conflicts with apt?

Copy link
Contributor Author

@Beanow Beanow Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise this script I tried to make minimal changes to compared to upstream.

I'm introducing different architectures here compared to upstream, which only support amd64.

It seems to be a deliberate workflow compatibility choice to install it here though.
actions/runner-images#3768

http_code=$(eval $COMMAND)
exit_code=$?
test "$ERR_EXIT_ENABLED" = true && set -e
if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove quotes for http_code? We don't control the output of curl, it may be able to inject stuff.

For example exit_code can only be a number, because that comes from bash itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fine now. I'm not familar with the pre 2023 history of this repository, there was a linter requiring changes from upstream files.

@ChristopherHX ChristopherHX merged commit ec09e6e into catthehacker:master Nov 19, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add yq to ubuntu:full-latest
3 participants