-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Project Source code (I don't remember what i did.)
- Loading branch information
Showing
10 changed files
with
289 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
release: | ||
types: [created] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: php:8.3 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt update -yqq | ||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq | ||
- name: Install phive | ||
run: | | ||
wget -O phive.phar https://phar.io/releases/phive.phar | ||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc | ||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79 | ||
gpg --verify phive.phar.asc phive.phar | ||
chmod +x phive.phar | ||
mv phive.phar /usr/local/bin/phive | ||
- name: Install phab | ||
run: | | ||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C | ||
- name: Install latest version of NCC | ||
run: | | ||
git clone https://git.n64.cc/nosial/ncc.git | ||
cd ncc | ||
make redist | ||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1) | ||
if [ -z "$NCC_DIR" ]; then | ||
echo "NCC build directory not found" | ||
exit 1 | ||
fi | ||
php "$NCC_DIR/INSTALL" --auto | ||
cd .. && rm -rf ncc | ||
- name: Build project | ||
run: | | ||
ncc build --config release --log-level debug | ||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Socialbox_build | ||
path: build/release/net.nosial.socialbox.ncc | ||
|
||
check-phpunit: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
phpunit-exists: ${{ steps.check.outputs.phpunit-exists }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Check for phpunit.xml | ||
id: check | ||
run: | | ||
if [ -f phpunit.xml ]; then | ||
echo "phpunit-exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "phpunit-exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
test: | ||
needs: [build, check-phpunit] | ||
runs-on: ubuntu-latest | ||
container: | ||
image: php:8.3 | ||
if: needs.check-phpunit.outputs.phpunit-exists == 'true' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Socialbox_build | ||
path: Socialbox_build # Adjust this to download the artifact directly under 'Socialbox_build' | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt update -yqq | ||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq | ||
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions | ||
chmod +x /usr/local/bin/install-php-extensions | ||
install-php-extensions zip | ||
- name: Install phive | ||
run: | | ||
wget -O phive.phar https://phar.io/releases/phive.phar | ||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc | ||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79 | ||
gpg --verify phive.phar.asc phive.phar | ||
chmod +x phive.phar | ||
mv phive.phar /usr/local/bin/phive | ||
- name: Install phab | ||
run: | | ||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C | ||
- name: Install latest version of NCC | ||
run: | | ||
git clone https://git.n64.cc/nosial/ncc.git | ||
cd ncc | ||
make redist | ||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1) | ||
if [ -z "$NCC_DIR" ]; then | ||
echo "NCC build directory not found" | ||
exit 1 | ||
fi | ||
php "$NCC_DIR/INSTALL" --auto | ||
cd .. && rm -rf ncc | ||
- name: Install NCC packages | ||
run: | | ||
ncc package install --package="Socialbox_build/net.nosial.socialbox.ncc" --build-source --reinstall -y --log-level debug | ||
- name: Run PHPUnit tests | ||
run: | | ||
wget https://phar.phpunit.de/phpunit-11.3.phar | ||
php phpunit-11.3.phar --configuration phpunit.xml | ||
release: | ||
needs: [build, test] | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
container: | ||
image: php:8.3 | ||
if: github.event_name == 'release' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Socialbox_build | ||
path: Socialbox_build | ||
|
||
- name: Upload to GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
Socialbox_build/net.nosial.socialbox.ncc | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
if (PHP_SAPI !== 'cli') | ||
{ | ||
print('net.nosial.socialbox must be run from the command line.' . PHP_EOL); | ||
exit(1); | ||
} | ||
|
||
if(!isset($argv)) | ||
{ | ||
if(isset($_SERVER['argv'])) | ||
{ | ||
$argv = $_SERVER['argv']; | ||
} | ||
else | ||
{ | ||
print('net.nosial.socialbox failed to run, no $argv found.' . PHP_EOL); | ||
exit(1); | ||
} | ||
} | ||
|
||
require('ncc'); | ||
\ncc\Classes\Runtime::import('net.nosial.socialbox', 'latest'); | ||
exit(\Socialbox\Program::main($argv)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Socialbox\Classes; | ||
|
||
class Configuration | ||
{ | ||
private static ?array $configuration = null; | ||
|
||
public static function getConfiguration(): array | ||
{ | ||
if(self::$configuration === null) | ||
{ | ||
$config = new \ConfigLib\Configuration('net.nosial.socialbox'); | ||
|
||
$config->setDefault('database.host', '127.0.0.1'); | ||
$config->setDefault('database.port', 3306); | ||
$config->setDefault('database.username', 'root'); | ||
$config->setDefault('database.password', null); | ||
$config->setDefault('database.name', 'test'); | ||
$config->save(); | ||
|
||
self::$configuration = $config->getConfiguration(); | ||
} | ||
|
||
return self::$configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Socialbox; | ||
|
||
class Program | ||
{ | ||
/** | ||
* Socialbox main entry point | ||
* | ||
* @param string[] $args Command-line arguments | ||
* @return int Exit code | ||
*/ | ||
public static function main(array $args): int | ||
{ | ||
print("Hello World from net.nosial.socialbox!" . PHP_EOL); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Socialbox; | ||
|
||
class Socialbox | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Socialbox\Classes; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Socialbox's Configuration Test Class | ||
* | ||
* This is a test suite for testing the "getConfiguration" method in the "Configuration" class. | ||
*/ | ||
class ConfigurationTest extends TestCase | ||
{ | ||
/** | ||
* Test the "getConfiguration" method in "Configuration" class. | ||
*/ | ||
public function testGetConfiguration(): void | ||
{ | ||
$config = Configuration::getConfiguration(); | ||
$this->assertIsArray($config, "Configuration should be an array."); | ||
|
||
//Assert that all the default configuration exists | ||
$this->assertArrayHasKey('database.host', $config); | ||
$this->assertEquals($config['database.host'], '127.0.0.1'); | ||
|
||
$this->assertArrayHasKey('database.port', $config); | ||
$this->assertEquals($config['database.port'], 3306); | ||
|
||
$this->assertArrayHasKey('database.username', $config); | ||
$this->assertEquals($config['database.username'], 'root'); | ||
|
||
$this->assertArrayHasKey('database.password', $config); | ||
$this->assertNull($config['database.password'], 'null should be the value of database.password.'); | ||
|
||
$this->assertArrayHasKey('database.name', $config); | ||
$this->assertEquals($config['database.name'], 'test'); | ||
} | ||
} |