Skip to content

Extract script outside of action.yml + remove unused code + add test that does not rely on a remote wireguard server #8

Open
Tycale wants to merge 7 commits intoegor-tensin:masterfrom
sortlist:master
Open

Extract script outside of action.yml + remove unused code + add test that does not rely on a remote wireguard server #8
Tycale wants to merge 7 commits intoegor-tensin:masterfrom
sortlist:master

Conversation

@Tycale
Copy link
Contributor

@Tycale Tycale commented Jan 7, 2023

Extracting the bash script outside of the yaml file helps in order to apply Shellcheck and other linters. It showed no errors, so that's great ! I removed the unused code (about systemD) as I think it's a bit confusing. I changed the array call for the additional arguments. I pushed everything in a single commit, sorry for that.

Thanks for this helpful Github action.

@Tycale
Copy link
Contributor Author

Tycale commented Jan 7, 2023

Crazy, again this error !
I would love to see the output with -o xtrace but this will leak the IPs you are using in the workflow run. So I won't. I will add an "echo" instead at the array expansion.

@Tycale
Copy link
Contributor Author

Tycale commented Jan 7, 2023

Force pushing does not re-run the workflow.. Too bad :p

@Tycale
Copy link
Contributor Author

Tycale commented Jan 7, 2023

I don't get it, it is running without issue on my GHA "runs-on: ubuntu-latest"..

@Tycale
Copy link
Contributor Author

Tycale commented Jan 7, 2023

So issue is most likely at line 72 https://github.com/egor-tensin/setup-wireguard/pull/8/files#diff-c992f6abfc7ff51f20d8266ec1acff44ac43ff1e87bcc75968bc2b9f0b72da23R72

As this is the only change I made in this file (with the management of the variables). But I really don't understand why. Crazy bash array expansion.

@egor-tensin
Copy link
Owner

So issue is most likely at line 72 https://github.com/egor-tensin/setup-wireguard/pull/8/files#diff-c992f6abfc7ff51f20d8266ec1acff44ac43ff1e87bcc75968bc2b9f0b72da23R72

As this is the only change I made in this file (with the management of the variables). But I really don't understand why. Crazy bash array expansion.

Please see a page on my website about bash: https://egort.name/blog/notes/bash.html. Especially under "Arrays" -> "Expansion". Basically, the rule is: always expand arrays using ${xs[@]+"${xs[@]}"}. I agree that this is crazy. Please revert this change about array expansion.

@Tycale
Copy link
Contributor Author

Tycale commented Jan 9, 2023

I was not previously aware of the ${xs[@]+"${xs[@]}"} syntax in Bash. This seems unusual but I ain't try fight with Bash.

@Tycale
Copy link
Contributor Author

Tycale commented Jan 9, 2023

I think the error is triggered by the fact that the vars are missing !

image

And the bash error:

Error: any valid address is expected rather than "dev".

It is coming from the line 51 : https://github.com/egor-tensin/setup-wireguard/pull/8/files#diff-c992f6abfc7ff51f20d8266ec1acff44ac43ff1e87bcc75968bc2b9f0b72da23R51

With ifname defined but not ip:

# ip addr add "$ip" dev "$ifname"
Error: any valid prefix is expected rather than "".

@Tycale
Copy link
Contributor Author

Tycale commented Jan 9, 2023

Can you try to run the workflow manually from your side ?
https://github.com/egor-tensin/setup-wireguard/blob/master/.github/workflows/test.yml#L26

Does Github keeps the secrets empty when it's executed by a pull request ? The only var going through is the keepalive with the value 25..

@Tycale Tycale force-pushed the master branch 2 times, most recently from 2031118 to 7a281cf Compare January 10, 2023 13:52
Tycale and others added 3 commits January 10, 2023 14:04
Extracting the code from the yaml file allows for easier editing and
use of linter tools. Additionally, unused code has been removed.

Signed-off-by: Thibault Gérondal <thibault.gerondal@sortlist.com>
This commit enables testing of the code against a Wireguard server in a
netns. This avoids any connection to the outside (no more security
issues) and makes the test robust and reproducible for anyone who wants
to do so.

Signed-off-by: Thibault Gérondal github@tycale.be>
@Tycale Tycale changed the title Extract script outside of action.yml + remove systemD Extract script outside of action.yml + remove unused code + add test that does not rely on a remote wireguard server Jan 10, 2023
@Tycale Tycale requested a review from egor-tensin January 10, 2023 14:07
The previous array expansion is useful only if the bash array is not
defined. As the array is defined before, this can be simplified.

Signed-off-by: Thibault Gérondal <github@tycale.be>
@Tycale
Copy link
Contributor Author

Tycale commented Feb 9, 2023

@egor-tensin What do you think about this change ? This makes the test self-contained thanks to network namespaces.

Tycale and others added 3 commits February 20, 2023 17:22
Signed-off-by: Thibault Gérondal <contact@tycale.be>
Signed-off-by: Thibault Gérondal <thibault@initia.cloud>
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.

2 participants