AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   Compiling source code through GitHub (https://forums.alliedmods.net/showthread.php?t=333061)

Shadows Adi 06-17-2021 14:45

Compiling source code through GitHub
 
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.

fysiks 06-17-2021 23:32

Re: Compiling source code through GitHub
 
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).

fysiks 06-19-2021 01:54

Re: Compiling source code through GitHub
 
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.

Shadows Adi 06-20-2021 04:51

Re: Compiling source code through GitHub
 
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?

fysiks 06-20-2021 16:51

Re: Compiling source code through GitHub
 
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.

rtxa 06-22-2021 13:08

Re: Compiling source code through GitHub
 
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.

fysiks 06-23-2021 01:10

Re: Compiling source code through GitHub
 
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.

Shadows Adi 07-17-2021 10:16

Re: Compiling source code through GitHub
 
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/

fysiks 07-28-2021 18:17

Re: Compiling source code through GitHub
 
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.

Shadows Adi 07-29-2021 04:06

Re: Compiling source code through GitHub
 
Quote:

Originally Posted by fysiks (Post 2753943)
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!


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

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