Raised This Month: $12 Target: $400
 3% 

Compiling source code through GitHub


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 06-17-2021 , 14:45   Compiling source code through GitHub
Reply With Quote #1

Hello,
I was wondering if it's possible to compile an AmxModX plugin using some kind of API or Integration for GitHub, just like Alliedmodders "Get plugin" function.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-17-2021 , 23:32   Re: Compiling source code through GitHub
Reply With Quote #2

Typically you have to do that type of thing with Jenkins or Travis CI.

It would be neat to be able to create a GitHub Action (GitHub implementation of a CI system like Jenkins/Travis, afaik) for this. Never created one before so I'm not sure what all it would take to set that up (if it's even possible).
__________________

Last edited by fysiks; 06-17-2021 at 23:33.
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2021 , 01:54   Re: Compiling source code through GitHub
Reply With Quote #3

So, I just got something working with GitHub actions. I created a test repo with a GitHub workflow that calls a sequence of commands/actions to compile the test plugin when you push to GitHub. The "workflow" is defined .github/workflows/main.yml.

If the plugin compiles successfully, the commit will go green. If the plugin fails to compile the commit will go red.

It does not (yet) give you access to the compiled plugin but in theory it should be possible to publish the compiled plugin as a release. Also, as it's configured, it does not grab any mod-specific files but that should be quite easy to add.

I haven't tested with custom include files but I think it should work as long as they are properly in the scripting/include folder.
__________________

Last edited by fysiks; 06-19-2021 at 23:32.
fysiks is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 06-20-2021 , 04:51   Re: Compiling source code through GitHub
Reply With Quote #4

So, basically it would work, but you won't get the binary files only if the owner of repo will publish the release as an offical one, isn't that?
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-20-2021 , 16:51   Re: Compiling source code through GitHub
Reply With Quote #5

Well, I think it's possible to have it create/update a draft release every time that code is pushed to GitHub. This would make it so that the latest binary will always be available. I'm working on this right now to see how hard this will be. My current thought is that there will be a continuously updated draft release for each branch.

If I can do this, then it will effectively be the same as the "Get Plugin" function. The difference is that the plugin gets compiled when the source code is pushed to GitHub instead of when you click on a link. The side effect is that if a new version of AMX Mod X is generated, it won't be compiled with that version unless the GitHub action is re-run.
__________________

Last edited by fysiks; 06-20-2021 at 18:47.
fysiks is offline
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 06-22-2021 , 13:08   Re: Compiling source code through GitHub
Reply With Quote #6

Check out this workflow a friend made to me for my project (by the time I didn't have any experience in making workflows). Probably is too bloated because I package everything my plugin needs to run (AMXX 1.9 and Metamod-P binaries and the plugin resources) for release, but the compiling part is there.

To sum up, it's possible and the community should start to use this to improve the development of medium/big projects.

Also this will probably benefit moderators who have to check if a plugin has been malicious altered and allows to upload the plugin binaries without users worrying about.
__________________
rtxa is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2021 , 01:10   Re: Compiling source code through GitHub
Reply With Quote #7

That's basically the same thing that I'm doing in mine though I didn't know about the latest.php script at amxmodx.org. I'm more used to Jenkins and I was looking for a way to upload an artifact to the workflow itself like Jenkins has and it looks like that's what you are doing (GitHub Actions are entirely new to me).

I spent some time and updated mine (found here) with inspiration from rtxa's version. Mine now compiles all plugins in your scripting folder and it uploads the compiled plugins as an artifact that you can download from the workflow run page. You can easily change the AMX Mod X version (only works for 1.9 and 1.10 currently), the scripting folder location in your repo, and if you want it to download the mod-specific files, all via three environment variables.

Note that the default life of artifacts is 90 days. If you want to make them more permanent, you'll need to create a release.
__________________

Last edited by fysiks; 06-23-2021 at 01:11.
fysiks is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-17-2021 , 10:16   Re: Compiling source code through GitHub
Reply With Quote #8

I can't get this work for me lmao.

This is the error which pop-up everytime:
[/php]
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
/home/runner/work/_temp/1164bdb0-1b81-4a15-9f89-7a0f944ed4ca.sh: line 9: 1520 Aborted (core dumped) ./amxxpc $(basename $file) -o$ARTIFACTS_DIR/$(basename "$amxfile")

Compiling most_valuable_player.sma...
Error: Process completed with exit code 134.
[/php]

GitHub Repository: https://github.com/ShadowsAdi/MostValuablePlayer/
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-28-2021 , 18:17   Re: Compiling source code through GitHub
Reply With Quote #9

I'm not sure why you would need the chmod on amxxpc, I've never needed to do that. Also, you are missing an include file. Try disabling REAPI so that all used includes exist and see if that works.
__________________
fysiks is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-29-2021 , 04:06   Re: Compiling source code through GitHub
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
I'm not sure why you would need the chmod on amxxpc, I've never needed to do that. Also, you are missing an include file. Try disabling REAPI so that all used includes exist and see if that works.
Oh, almost forgot about reapi, I think this will solve the issue, I will be back with an answer.

Edit: It works, I downloaded the last version of ReAPI for include files and everything seems ok. https://github.com/ShadowsAdi/MostVa...ws/compile.yml

Thank you!
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 07-29-2021 at 04:31. Reason: Edit
Shadows Adi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode