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