From 276aec0df6a60d19a49b6a2b30bae22648fd1ffe Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:33:03 -0400 Subject: [PATCH 01/45] Create test.yml --- .github/workflows/test.yml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d96cba9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: Build and Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Use NCC Workflow + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: build/release/net.nosial.configlib.ncc + + - name: Build project + run: | + ncc build --config release --log-level debug + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ncc-build + path: build/release/net.nosial.configlib.ncc + + test: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: ncc-build + path: ncc-build + + - name: Use NCC Workflow + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: ncc-build/net.nosial.configlib.ncc + + - name: Run PHPUnit tests + run: | + wget https://phar.phpunit.de/phpunit-11.3.phar + php phpunit-11.3.phar --configuration phpunit.xml From 8042e508631f1988a226666e83d2906e0421d885 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:36:28 -0400 Subject: [PATCH 02/45] Update test.yml --- .github/workflows/test.yml | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d96cba9..24e152d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,20 +10,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Use NCC Workflow - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: build/release/net.nosial.configlib.ncc - - - name: Build project - run: | - ncc build --config release --log-level debug - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: ncc-build - path: build/release/net.nosial.configlib.ncc + # Reference the reusable workflow at the job level + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: build/release/net.nosial.configlib.ncc test: needs: build @@ -39,10 +29,10 @@ jobs: name: ncc-build path: ncc-build - - name: Use NCC Workflow - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: ncc-build/net.nosial.configlib.ncc + # Reuse the NCC workflow for the test phase + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: ncc-build/net.nosial.configlib.ncc - name: Run PHPUnit tests run: | From a3c9fe41f3affaf539e7cd68cbc6848d9d202383 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:37:27 -0400 Subject: [PATCH 03/45] Update test.yml From 6abf687e93626439e4b2e2806042fb03fd5d8f24 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:38:06 -0400 Subject: [PATCH 04/45] Update test.yml From 5a24645f09ca06ca268e123bf74eaeccc95d28ae Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:39:56 -0400 Subject: [PATCH 05/45] Update test.yml --- .github/workflows/test.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24e152d..514520c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # Reference the reusable workflow at the job level - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: build/release/net.nosial.configlib.ncc + # Reference the reusable workflow at the top level of the job + ncc-setup: + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: build/release/net.nosial.configlib.ncc test: needs: build @@ -29,11 +30,11 @@ jobs: name: ncc-build path: ncc-build - # Reuse the NCC workflow for the test phase - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: ncc-build/net.nosial.configlib.ncc - + # Reuse the NCC workflow for the test phase + ncc-setup: + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: ncc-build/net.nosial.configlib.ncc - name: Run PHPUnit tests run: | wget https://phar.phpunit.de/phpunit-11.3.phar From 20441809ccc5d46b13d84d5013e9ab5c9b367201 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:50:34 -0400 Subject: [PATCH 06/45] Update test.yml --- .github/workflows/test.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 514520c..ad1402d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,11 +10,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # Reference the reusable workflow at the top level of the job - ncc-setup: - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: build/release/net.nosial.configlib.ncc + - name: Setup NCC + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: build/release/net.nosial.configlib.ncc test: needs: build @@ -30,11 +29,11 @@ jobs: name: ncc-build path: ncc-build - # Reuse the NCC workflow for the test phase - ncc-setup: - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: ncc-build/net.nosial.configlib.ncc + - name: Setup NCC + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: ncc-build/net.nosial.configlib.ncc + - name: Run PHPUnit tests run: | wget https://phar.phpunit.de/phpunit-11.3.phar From 0f5036742fd6e64701119956c8d07f5ee773cbd1 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:52:05 -0400 Subject: [PATCH 07/45] Update test.yml --- .github/workflows/test.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad1402d..f87cbeb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,16 +4,9 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup NCC - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: build/release/net.nosial.configlib.ncc + uses: nosial/ncc-workflow/.github/workflows/build.yml@main + with: + ncc_package_path: build/release/net.nosial.configlib.ncc test: needs: build From 93efe5741a0d63fbe6db61b1b29159b5a400c7c1 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 17 Sep 2024 16:54:34 -0400 Subject: [PATCH 08/45] Update test.yml From 4299096a0982200016e9cd6d51c76496b38f7203 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 14:00:33 -0400 Subject: [PATCH 09/45] Fix case inconsistency in project.json configuration schema --- project.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project.json b/project.json index 2b0c400..f6ee0e6 100644 --- a/project.json +++ b/project.json @@ -43,7 +43,7 @@ "default_configuration": "release", "main": "main", "define_constants": { - "version": "%ASSEMBLY.VERSION%" + "VERSION": "%ASSEMBLY.VERSION%" }, "dependencies": [ { @@ -78,7 +78,7 @@ } ], "configurations": [ - { + { "name": "release", "build_type": "ncc", "output": "build/release/%ASSEMBLY.PACKAGE%.ncc" @@ -93,4 +93,4 @@ } ] } -} +} \ No newline at end of file From a259f45684a9c0ead6084cc2a2adeea2f73172d1 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 14:01:10 -0400 Subject: [PATCH 10/45] Refactor temp directory handling and add getVersion method --- src/ConfigLib/Program.php | 49 ++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/ConfigLib/Program.php b/src/ConfigLib/Program.php index e0f1b09..dcb4c46 100644 --- a/src/ConfigLib/Program.php +++ b/src/ConfigLib/Program.php @@ -4,20 +4,18 @@ use Exception; use JetBrains\PhpStorm\NoReturn; - use ncc\Exceptions\InvalidPackageNameException; - use ncc\Exceptions\InvalidScopeException; - use ncc\Exceptions\PackageLockException; - use ncc\Exceptions\PackageNotFoundException; - use ncc\Runtime; use OptsLib\Parse; use RuntimeException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Yaml; + use function trigger_error; class Program { + private static ?string $version = null; + /** * Main entry point of the program * @@ -145,7 +143,7 @@ */ #[NoReturn] private static function help(): void { - print('ConfigLib v' . Runtime::getConstant('net.nosial.configlib', 'version') . PHP_EOL . PHP_EOL); + print('ConfigLib v' . self::getVersion() . PHP_EOL . PHP_EOL); print('Usage: configlib [options]' . PHP_EOL); print(' -h, --help Displays the help menu' . PHP_EOL); @@ -174,10 +172,6 @@ * @param array $args * @param Configuration $configuration * @return void - * @throws InvalidPackageNameException - * @throws InvalidScopeException - * @throws PackageLockException - * @throws PackageNotFoundException */ #[NoReturn] private static function edit(array $args, Configuration $configuration): void { @@ -196,21 +190,22 @@ } else { - if(!file_exists(Runtime::getDataPath('net.nosial.configlib') . DIRECTORY_SEPARATOR . 'tmp')) + $temporary_directory = sys_get_temp_dir(); + if(!file_exists($temporary_directory . DIRECTORY_SEPARATOR . 'configlib')) { - if (!mkdir($concurrentDirectory = Runtime::getDataPath('net.nosial.configlib') . DIRECTORY_SEPARATOR . 'tmp', 0777, true) && !is_dir($concurrentDirectory)) + if (!mkdir($concurrentDirectory = $temporary_directory . DIRECTORY_SEPARATOR . 'configlib', 0777, true) && !is_dir($concurrentDirectory)) { throw new RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); } - if(!file_exists(Runtime::getDataPath('net.nosial.configlib') . DIRECTORY_SEPARATOR . 'tmp')) + if(!file_exists($temporary_directory . DIRECTORY_SEPARATOR . 'configlib')) { print('Unable to create the temporary path to use' . PHP_EOL); exit(1); } } - $tempPath = Runtime::getDataPath('net.nosial.configlib') . DIRECTORY_SEPARATOR . 'tmp'; + $tempPath = $temporary_directory . DIRECTORY_SEPARATOR . 'configlib'; } $fs = new Filesystem(); @@ -276,4 +271,30 @@ exit(0); } + + /** + * Retrieves the current version of the library. If the version is not set, it checks + * if the CONFIGLIB_VERSION constant is defined. If neither is available, it returns 'Unknown' + * and triggers a user warning. + * + * @return string The current version of the library. + * @noinspection PhpUndefinedConstantInspection + */ + public static function getVersion(): string + { + if(self::$version !== null) + { + return self::$version; + } + + if(defined('CONFIGLIB_VERSION')) + { + self::$version = CONFIGLIB_VERSION; + return self::$version; + } + + self::$version = 'Unknown'; + trigger_error('ConfigLib version is unknown', E_USER_WARNING); + return self::$version; + } } \ No newline at end of file From b34005af1b1f542a53ab255486b7510d78d7fb84 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 14:01:22 -0400 Subject: [PATCH 11/45] Removed test.yml --- .github/workflows/test.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f87cbeb..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build and Test - -on: [push, pull_request] - -jobs: - build: - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: build/release/net.nosial.configlib.ncc - - test: - needs: build - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: ncc-build - path: ncc-build - - - name: Setup NCC - uses: nosial/ncc-workflow/.github/workflows/build.yml@main - with: - ncc_package_path: ncc-build/net.nosial.configlib.ncc - - - name: Run PHPUnit tests - run: | - wget https://phar.phpunit.de/phpunit-11.3.phar - php phpunit-11.3.phar --configuration phpunit.xml From 6cdc2336cd11897cf1f7f0e78b56cf42c17a6aa2 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 18:41:47 -0400 Subject: [PATCH 12/45] Add exit check and update project include paths --- .idea/php.xml | 8 ++++++-- src/ConfigLib/Program.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index 43259c7..c6952bf 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,10 +11,14 @@ + + + + + + - - diff --git a/src/ConfigLib/Program.php b/src/ConfigLib/Program.php index dcb4c46..2f1a6d1 100644 --- a/src/ConfigLib/Program.php +++ b/src/ConfigLib/Program.php @@ -51,6 +51,7 @@ if(!file_exists($configuration->getPath())) { print(sprintf('Configuration \'%s\' does not exist, aborting' . PHP_EOL, $configuration->getName())); + exit(1); } From 649d04d8aa099c0dd738cfeffb6f7b9c1a776827 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:37:07 -0400 Subject: [PATCH 13/45] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c124b4..211f710 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/ /.idea/php-test-framework.xml +/.idea/gbrowser_project.xml From 1b94a273b735abbe735a67cc4bea3692a21d5aba Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:44:01 -0400 Subject: [PATCH 14/45] Refactor Makefile for flexibility and maintenance --- Makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6e83f36..c6e2ca2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,20 @@ +# Variables +CONFIG ?= release +LOG_LEVEL = debug +OUTDIR = build/$(CONFIG) +PACKAGE = $(OUTDIR)/net.nosial.configlib.ncc + +# Default Target +all: build + +# Build Steps build: - ncc build --config="release" --log-level debug + ncc build --config=$(CONFIG) --log-level $(LOG_LEVEL) install: - sudo ncc package install --package="build/release/net.nosial.configlib.ncc" --skip-dependencies --reinstall -y --log-level debug + ncc package install --package=$(PACKAGE) --skip-dependencies --reinstall -y --log-level $(LOG_LEVEL) clean: - rm -rf build \ No newline at end of file + rm -rf build + +.PHONY: all build install clean \ No newline at end of file From 9f98b4c9b8c1f70163805a542937339499f050e9 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:44:10 -0400 Subject: [PATCH 15/45] Upgrade PHP configuration to version 8.3 --- .idea/php.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index c6952bf..a1673a5 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,9 +11,9 @@ + - @@ -22,7 +22,7 @@ - + From e3b2a3cf9a9838d325d66db6812fbdcb59a9b57c Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:44:19 -0400 Subject: [PATCH 16/45] Add --path option to display configuration storage path --- src/ConfigLib/Program.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ConfigLib/Program.php b/src/ConfigLib/Program.php index 2f1a6d1..a01199c 100644 --- a/src/ConfigLib/Program.php +++ b/src/ConfigLib/Program.php @@ -38,6 +38,7 @@ $editor = $args['editor'] ?? @$args['e'] ?? null; $export = $args['export'] ?? null; $import = $args['import'] ?? null; + $path = $args['path'] ?? null; if($configuration_name === null) { @@ -55,6 +56,12 @@ exit(1); } + if($path !== null) + { + print($configuration->getPath() . PHP_EOL); + exit(0); + } + if($import !== null) { try @@ -154,6 +161,7 @@ print(' -e, --editor (Optional) The editor to use (eg; nano, vim, notepad) (External)' . PHP_EOL); print(' --export (Optional) Exports the configuration to a file' . PHP_EOL); print(' --import (Optional) Imports the configuration from a file' . PHP_EOL); + print(' --path (Optional) Displays the configuration storage path' . PHP_EOL); print(' --nc (Optional) Disables type casting (eg; \'true\' > True) will always be a string' . PHP_EOL); print('Examples:' . PHP_EOL . PHP_EOL); @@ -163,6 +171,7 @@ print(' configlib --conf test --editor nano Edit the configuration' . PHP_EOL); print(' configlib --conf test --export out.json Export the configuration' . PHP_EOL); print(' configlib --conf test --import in.json Import a configuration' . PHP_EOL); + print(' configlib --conf test --path Displays the configuration storage path' . PHP_EOL); exit(0); } From 386e1375472259be86ae4ad57e2d176f135683fd Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:48:41 -0400 Subject: [PATCH 17/45] Updated CHANGELOG.md --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 530ea12..449338a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.0] - 2024-09-23 + +This update introduces changes for PHP 8.3 & NCC 2.1.0+ compatibility + +### Added + - Added PhpUnit tests for the library + - Added new option `--path` to the CLI interface to display the path to the configuration file + +### Changed + - Updated the codebase to be compatible with PHP 8.3 + - Updated the codebase to be compatible with NCC 2.1.0+ + - Updated Makefile + +### Fixed + - Fixed regex patterns to be more robust + + + ## [1.0.4] - 2023-08-12 This update introduces minor improvements From 0c837c6b5433515bc04ecfb05f191f136be8430f Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:50:21 -0400 Subject: [PATCH 18/45] Add --build-source flag to ncc build commands --- .github/workflows/ci.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7c392a..29623cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Build project run: | - ncc build --config release --log-level debug + ncc build --config release --build-source --log-level debug - name: Upload build artifacts uses: actions/upload-artifact@v4 diff --git a/Makefile b/Makefile index c6e2ca2..86f53a1 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ all: build # Build Steps build: - ncc build --config=$(CONFIG) --log-level $(LOG_LEVEL) + ncc build --config=$(CONFIG) --build-source --log-level $(LOG_LEVEL) install: ncc package install --package=$(PACKAGE) --skip-dependencies --reinstall -y --log-level $(LOG_LEVEL) From b5874371b1f259fc3cece0ae05b9e85cf667ba8d Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 13:53:02 -0400 Subject: [PATCH 19/45] Remove redundant --build-source flag from build steps --- .github/workflows/ci.yml | 8 ++++---- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29623cd..b547f1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,12 +46,12 @@ jobs: echo "NCC build directory not found" exit 1 fi - php "$NCC_DIR/INSTALL" --auto --install-composer + php "$NCC_DIR/INSTALL" --auto cd .. && rm -rf ncc - name: Build project run: | - ncc build --config release --build-source --log-level debug + ncc build --config release --log-level debug - name: Upload build artifacts uses: actions/upload-artifact@v4 @@ -106,12 +106,12 @@ jobs: echo "NCC build directory not found" exit 1 fi - php "$NCC_DIR/INSTALL" --auto --install-composer + php "$NCC_DIR/INSTALL" --auto cd .. && rm -rf ncc - name: Install NCC packages run: | - ncc package install --package="ncc-build/net.nosial.configlib.ncc" --reinstall -y --log-level debug + ncc package install --package="ncc-build/net.nosial.configlib.ncc" --build-source --reinstall -y --log-level debug - name: Run PHPUnit tests run: | diff --git a/Makefile b/Makefile index 86f53a1..5f919db 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,10 @@ all: build # Build Steps build: - ncc build --config=$(CONFIG) --build-source --log-level $(LOG_LEVEL) + ncc build --config=$(CONFIG) --log-level $(LOG_LEVEL) install: - ncc package install --package=$(PACKAGE) --skip-dependencies --reinstall -y --log-level $(LOG_LEVEL) + ncc package install --package=$(PACKAGE) --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL) clean: rm -rf build From 698e2cb334baf2aa6a5fd92fc7e542a6af3066d0 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 23 Sep 2024 18:50:08 -0400 Subject: [PATCH 20/45] Updated ci.yml --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b547f1b..7a33d55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,19 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Check for phpunit.xml + id: file_check + run: | + if [ -f phpunit.xml ]; then + echo "::set-output name=exists::true" + else + echo "::set-output name=exists::false" + fi + + - name: Skip if no phpunit.xml + if: steps.file_check.outputs.exists == 'false' + run: exit 78 + - name: Download build artifacts uses: actions/download-artifact@v4 with: From 2f41614d209f1f5098cccde16268db9e093c6c31 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 26 Sep 2024 14:57:27 -0400 Subject: [PATCH 21/45] Update version and improve config validation --- project.json | 2 +- src/ConfigLib/Configuration.php | 4 +--- tests/ConfigLib/ConfigurationTest.php | 4 +++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/project.json b/project.json index f6ee0e6..5424afe 100644 --- a/project.json +++ b/project.json @@ -35,7 +35,7 @@ "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", - "version": "1.1.0", + "version": "1.1.1", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { diff --git a/src/ConfigLib/Configuration.php b/src/ConfigLib/Configuration.php index 86ee637..62b604a 100644 --- a/src/ConfigLib/Configuration.php +++ b/src/ConfigLib/Configuration.php @@ -161,9 +161,7 @@ */ private static function validateKey(string $input): bool { - $pattern = '/^([a-zA-Z0-9]+\.?)+$/'; - - if (preg_match($pattern, $input)) + if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input)) { return true; } diff --git a/tests/ConfigLib/ConfigurationTest.php b/tests/ConfigLib/ConfigurationTest.php index a657551..2f8330b 100644 --- a/tests/ConfigLib/ConfigurationTest.php +++ b/tests/ConfigLib/ConfigurationTest.php @@ -52,8 +52,10 @@ class ConfigurationTest extends TestCase public function testGetMethodWithValidKey(): void { $config = new Configuration('test'); - $config->set('key1.key2', 'value'); + $this->assertTrue($config->set('key1.key2', 'value', true)); $this->assertEquals('value', $config->get('key1.key2')); + $this->assertTrue($config->set('foo.fizz_buzz', 'value', true)); + $this->assertEquals('value', $config->get('foo.fizz_buzz')); } /** From 489df9f79a0b60b502f9fd433741fa39fbeeec63 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 26 Sep 2024 14:58:09 -0400 Subject: [PATCH 22/45] Updated CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449338a..dd8cb07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] - 2024-09-26 + +This update introduces a minor bug fix + +### Fixed + - Fixed issue where keys containing underscores are considered to be invalid + + ## [1.1.0] - 2024-09-23 This update introduces changes for PHP 8.3 & NCC 2.1.0+ compatibility From b8e83d31bc229d71ed5b1bb0f463a5e3104994df Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 27 Sep 2024 13:18:53 -0400 Subject: [PATCH 23/45] Fix configuration path resolution and add setup script --- CHANGELOG.md | 9 +++++ project.json | 16 ++++++++- setup | 14 ++++++++ src/ConfigLib/Configuration.php | 58 ++++++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 setup diff --git a/CHANGELOG.md b/CHANGELOG.md index dd8cb07..02d7f1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.2] - 2024-09-27 + +This update fixes a critical bug where configuration files may not be found when using different user accounts, +especially when the configuration file is located in a directory that is not accessible by the user account running the +application. This was fixed by changing the way the configuration file path is resolved including by adding a setup +execution unit that will be executed post-installation to ensure that the configuration file is accessible by the user +account running the application. + + ## [1.1.1] - 2024-09-26 This update introduces a minor bug fix diff --git a/project.json b/project.json index 5424afe..c1797c0 100644 --- a/project.json +++ b/project.json @@ -27,15 +27,29 @@ "working_directory": "%CWD%", "tty": true } + }, + { + "name": "setup", + "runner": "php", + "execute": { + "target": "setup", + "working_directory": "%CWD%", + "tty": true + } } ], + "installer": { + "post_install": [ + "setup" + ] + }, "assembly": { "name": "ConfigLib", "package": "net.nosial.configlib", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", - "version": "1.1.1", + "version": "1.1.2", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { diff --git a/setup b/setup new file mode 100644 index 0000000..7c6b690 --- /dev/null +++ b/setup @@ -0,0 +1,14 @@ +path = $globalDir . DIRECTORY_SEPARATOR . $name . '.conf'; + } + if ($this->path === null) { - $filePath = $name . '.conf'; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $configDir = getenv('APPDATA') ?: getenv('LOCALAPPDATA'); @@ -514,4 +520,54 @@ $fs->dumpFile($path, $this->toYaml()); $fs->chmod($path, 0777); } + + /** + * Retrieves the global directory path for configuration files. + * + * @return string The global directory path for configuration files. + */ + public static function getGlobalDirectory(): string + { + $path = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'configlib'; + + if(file_exists($path) && is_writable($path)) + { + return $path; + } + + if((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) + { + $variables = [ + 'SYSTEMDRIVE', + 'CSIDL_APPDATA', + 'CSIDL_PROGRAM_FILES' + ]; + + foreach($variables as $variable) + { + $environment_variable = getenv($variable); + if($environment_variable) + { + return $environment_variable . DIRECTORY_SEPARATOR . 'configlib'; + } + } + } + else + { + $variables = [ + 'HOME', + 'XDG_CONFIG_HOME', + 'XDG_DATA_HOME' + ]; + + foreach($variables as $variable) + { + $environment_variable = getenv($variable); + if($environment_variable) + { + return $environment_variable . DIRECTORY_SEPARATOR . 'configlib'; + } + } + } + } } \ No newline at end of file From d75fbd72d273363079119ec435321487dd5fc02d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 12 Oct 2024 20:52:22 -0400 Subject: [PATCH 24/45] Updated Build System --- .github/workflows/ci.yml | 145 ------- .github/workflows/ncc_workflow.yml | 597 +++++++++++++++++++++++++++++ Makefile | 35 +- project.json | 91 ++++- 4 files changed, 693 insertions(+), 175 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/ncc_workflow.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e7c392a..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,145 +0,0 @@ -name: CI - -on: - push: - branches: - - 'master' - 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 --install-composer - 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: ncc-build - path: build/release/net.nosial.configlib.ncc - - test: - needs: build - runs-on: ubuntu-latest - container: - image: php:8.3 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: ncc-build - path: ncc-build # Adjust this to download the artifact directly under 'ncc-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 --install-composer - cd .. && rm -rf ncc - - - name: Install NCC packages - run: | - ncc package install --package="ncc-build/net.nosial.configlib.ncc" --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: ncc-build - path: ncc-build - - - name: Upload to GitHub Release - uses: softprops/action-gh-release@v1 - with: - files: | - ncc-build/net.nosial.configlib.ncc - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml new file mode 100644 index 0000000..d67880e --- /dev/null +++ b/.github/workflows/ncc_workflow.yml @@ -0,0 +1,597 @@ +name: CI + +on: + push: + branches: + - '**' + release: + types: [created] + workflow_dispatch: + +jobs: + release: + 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 artifact + uses: actions/upload-artifact@v4 + with: + name: release + path: build/release/net.nosial.configlib.ncc + debug: + 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 debug --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: debug + path: build/debug/net.nosial.configlib.ncc + release-compressed: + 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-compressed --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: release-compressed + path: build/release/net.nosial.configlib.gz.ncc + debug-compressed: + 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 debug-compressed --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: debug-compressed + path: build/debug/net.nosial.configlib.gz.ncc + release-executable: + 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-executable --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: release-executable + path: build/release/release_executable_gz + debug-executable: + 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 debug-executable --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: debug-executable + path: build/release/debug_executable_gz + release-compressed-executable: + 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-compressed-executable --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: release-compressed-executable + path: build/release/release_compressed_executable + debug-compressed-executable: + 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 debug-compressed-executable --log-level debug + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: debug-compressed-executable + path: build/release/debug_compressed_executable + + + # Checking for phpunit.xml + 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 + # Checking for phpdoc.dist.xml + check-phpdoc: + runs-on: ubuntu-latest + outputs: + phpdoc-exists: ${{ steps.check.outputs.phpdoc-exists }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check for phpdoc.dist.xml + id: check + run: | + if [ -f phpdoc.dist.xml ]; then + echo "phpdoc-exists=true" >> $GITHUB_OUTPUT + else + echo "phpdoc-exists=false" >> $GITHUB_OUTPUT + fi + generate-phpdoc: + needs: [release, check-phpdoc] + runs-on: ubuntu-latest + container: + image: php:8.3 + if: needs.check-phpdoc.outputs.phpdoc-exists == 'true' + + 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: Download PHPDocumentor + run: | + wget https://phpdoc.org/phpDocumentor.phar + chmod +x phpDocumentor.phar + + - name: Generate PHPDoc + run: | + php phpDocumentor.phar -d src -t docs + + - name: Upload PHPDoc + uses: actions/upload-artifact@v4 + with: + name: documentation + path: docs + + test: + needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, 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: release + path: release + + - 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="release/net.nosial.configlib.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 + + upload-artifacts: + needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, 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 release artifact + uses: actions/download-artifact@v4 + with: + name: release + path: release + - name: Download debug artifact + uses: actions/download-artifact@v4 + with: + name: debug + path: debug + - name: Download release-compressed artifact + uses: actions/download-artifact@v4 + with: + name: release-compressed + path: release-compressed + - name: Download debug-compressed artifact + uses: actions/download-artifact@v4 + with: + name: debug-compressed + path: debug-compressed + - name: Download release-executable artifact + uses: actions/download-artifact@v4 + with: + name: release-executable + path: release-executable + - name: Download debug-executable artifact + uses: actions/download-artifact@v4 + with: + name: debug-executable + path: debug-executable + - name: Download release-compressed-executable artifact + uses: actions/download-artifact@v4 + with: + name: release-compressed-executable + path: release-compressed-executable + - name: Download debug-compressed-executable artifact + uses: actions/download-artifact@v4 + with: + name: debug-compressed-executable + path: debug-compressed-executable + + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + release/net.nosial.configlib.ncc + debug/net.nosial.configlib.ncc + release-compressed/net.nosial.configlib.gz.ncc + debug-compressed/net.nosial.configlib.gz.ncc + release-executable/release_executable_gz + debug-executable/debug_executable_gz + release-compressed-executable/release_compressed_executable + debug-compressed-executable/debug_compressed_executable + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index c6e2ca2..c7466dd 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,37 @@ # Variables -CONFIG ?= release +DEFAULT_CONFIGURATION ?= release LOG_LEVEL = debug -OUTDIR = build/$(CONFIG) -PACKAGE = $(OUTDIR)/net.nosial.configlib.ncc # Default Target -all: build +all: release debug release-compressed debug-compressed release-executable debug-executable release-compressed-executable debug-compressed-executable # Build Steps -build: - ncc build --config=$(CONFIG) --log-level $(LOG_LEVEL) +release: + ncc build --config=release --log-level $(LOG_LEVEL) +debug: + ncc build --config=debug --log-level $(LOG_LEVEL) +release-compressed: + ncc build --config=release-compressed --log-level $(LOG_LEVEL) +debug-compressed: + ncc build --config=debug-compressed --log-level $(LOG_LEVEL) +release-executable: + ncc build --config=release-executable --log-level $(LOG_LEVEL) +debug-executable: + ncc build --config=debug-executable --log-level $(LOG_LEVEL) +release-compressed-executable: + ncc build --config=release-compressed-executable --log-level $(LOG_LEVEL) +debug-compressed-executable: + ncc build --config=debug-compressed-executable --log-level $(LOG_LEVEL) -install: - ncc package install --package=$(PACKAGE) --skip-dependencies --reinstall -y --log-level $(LOG_LEVEL) + +install: release + ncc package install --package=build/release/net.nosial.configlib.ncc --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL) + +test: release + [ -f phpunit.xml ] || { echo "phpunit.xml not found"; exit 1; } + phpunit clean: rm -rf build -.PHONY: all build install clean \ No newline at end of file +.PHONY: all install test clean release debug release-compressed debug-compressed release-executable debug-executable release-compressed-executable debug-compressed-executable \ No newline at end of file diff --git a/project.json b/project.json index f6ee0e6..0110128 100644 --- a/project.json +++ b/project.json @@ -5,6 +5,9 @@ "minimum_version": "8.0", "maximum_version": "8.2" }, + "options": { + "create_symlink": true + }, "update_source": { "source": "nosial/libs.config@n64", "repository": { @@ -13,28 +16,14 @@ "host": "git.n64.cc", "ssl": true } - }, - "options": { - "create_symlink": true } }, - "execution_policies":[ - { - "name": "main", - "runner": "php", - "execute": { - "target": "main", - "working_directory": "%CWD%", - "tty": true - } - } - ], "assembly": { "name": "ConfigLib", "package": "net.nosial.configlib", + "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "version": "1.1.0", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, @@ -49,31 +38,26 @@ { "name": "net.nosial.optslib", "version": "latest", - "source_type": "remote", "source": "nosial/libs.opts=latest@n64" }, { "name": "net.nosial.loglib", "version": "latest", - "source_type": "remote", "source": "nosial/libs.log=latest@n64" }, { "name": "com.symfony.filesystem", "version": "latest", - "source_type": "remote", "source": "symfony/filesystem=latest@packagist" }, { "name": "com.symfony.yaml", "version": "latest", - "source_type": "remote", "source": "symfony/yaml=latest@packagist" }, { "name": "com.symfony.process", "version": "latest", - "source_type": "remote", "source": "symfony/process=latest@packagist" } ], @@ -90,7 +74,72 @@ "define_constants": { "DEBUG": "1" } + }, + { + "name": "release-compressed", + "build_type": "ncc", + "output": "build/release/%ASSEMBLY.PACKAGE%.gz.ncc", + "options": { + "compression": "high" + } + }, + { + "name": "debug-compressed", + "build_type": "ncc", + "output": "build/debug/%ASSEMBLY.PACKAGE%.gz.ncc", + "options": { + "compression": "high" + }, + "define_constants": { + "DEBUG": "1" + } + }, + { + "name": "release-executable", + "build_type": "executable", + "output": "build/release/release_executable_gz", + "options": { + "ncc_configuration": "release" + } + }, + { + "name": "debug-executable", + "build_type": "executable", + "output": "build/release/debug_executable_gz", + "options": { + "ncc_configuration": "debug" + } + }, + { + "name": "release-compressed-executable", + "build_type": "executable", + "output": "build/release/release_compressed_executable", + "options": { + "ncc_configuration": "release-compressed" + } + }, + { + "name": "debug-compressed-executable", + "build_type": "executable", + "output": "build/release/debug_compressed_executable", + "options": { + "ncc_configuration": "debug-compressed" + } } ] - } + }, + "execution_policies": [ + { + "name": "main", + "runner": "php", + "execute": { + "working_directory": "%CWD%", + "silent": false, + "tty": true, + "timeout": null, + "idle_timeout": null, + "target": "main" + } + } + ] } \ No newline at end of file From b568f75d0ba31f554450ec4c866f67145aeb2d80 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:39:36 -0400 Subject: [PATCH 25/45] Updated Build System --- .idea/php.xml | 3 +++ project.json | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index a1673a5..9144d49 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -26,6 +26,9 @@ + + diff --git a/project.json b/project.json index 0110128..403b29a 100644 --- a/project.json +++ b/project.json @@ -105,7 +105,7 @@ { "name": "debug-executable", "build_type": "executable", - "output": "build/release/debug_executable_gz", + "output": "build/debug/debug_executable_gz", "options": { "ncc_configuration": "debug" } @@ -121,7 +121,7 @@ { "name": "debug-compressed-executable", "build_type": "executable", - "output": "build/release/debug_compressed_executable", + "output": "build/debug/debug_compressed_executable", "options": { "ncc_configuration": "debug-compressed" } From 2fd12137ae70a5aaaf56d629b280a1226933ebb0 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:46:52 -0400 Subject: [PATCH 26/45] Added upload-docs stage --- .github/workflows/ncc_workflow.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index d67880e..f372eb5 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -526,6 +526,32 @@ jobs: wget https://phar.phpunit.de/phpunit-11.3.phar php phpunit-11.3.phar --configuration phpunit.xml + upload-docs: + needs: [generate-phpdoc] + 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 documentation artifact + uses: actions/download-artifact@v4 + with: + name: documentation + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + docs/ + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + upload-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] permissions: write-all From 94ba9a93df32ca09d2ac5369f2c1fee9b6fe4b17 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:48:02 -0400 Subject: [PATCH 27/45] Bumped version to 1.1.1 --- CHANGELOG.md | 5 +++++ project.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 530ea12..9cd41e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] - 2024-10-13 + +This update introduces a new build system + + ## [1.0.4] - 2023-08-12 This update introduces minor improvements diff --git a/project.json b/project.json index 403b29a..b69fa4f 100644 --- a/project.json +++ b/project.json @@ -24,7 +24,7 @@ "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "version": "1.1.0", + "version": "1.1.1", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { From a19f372150b490c341e77be14a7a1a5a656cfe6e Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:49:20 -0400 Subject: [PATCH 28/45] Updated Build System --- .github/workflows/ncc_workflow.yml | 30 +------ project.json | 122 ++++++++++++++++++++--------- 2 files changed, 89 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index f372eb5..4a8eded 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -302,7 +302,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: debug-executable - path: build/release/debug_executable_gz + path: build/debug/debug_executable_gz release-compressed-executable: runs-on: ubuntu-latest container: @@ -400,7 +400,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: debug-compressed-executable - path: build/release/debug_compressed_executable + path: build/debug/debug_compressed_executable # Checking for phpunit.xml @@ -526,32 +526,6 @@ jobs: wget https://phar.phpunit.de/phpunit-11.3.phar php phpunit-11.3.phar --configuration phpunit.xml - upload-docs: - needs: [generate-phpdoc] - 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 documentation artifact - uses: actions/download-artifact@v4 - with: - name: documentation - - - name: Upload to GitHub Release - uses: softprops/action-gh-release@v1 - with: - files: | - docs/ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - upload-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] permissions: write-all diff --git a/project.json b/project.json index c1797c0..714cd75 100644 --- a/project.json +++ b/project.json @@ -5,6 +5,9 @@ "minimum_version": "8.0", "maximum_version": "8.2" }, + "options": { + "create_symlink": true + }, "update_source": { "source": "nosial/libs.config@n64", "repository": { @@ -13,42 +16,14 @@ "host": "git.n64.cc", "ssl": true } - }, - "options": { - "create_symlink": true } }, - "execution_policies":[ - { - "name": "main", - "runner": "php", - "execute": { - "target": "main", - "working_directory": "%CWD%", - "tty": true - } - }, - { - "name": "setup", - "runner": "php", - "execute": { - "target": "setup", - "working_directory": "%CWD%", - "tty": true - } - } - ], - "installer": { - "post_install": [ - "setup" - ] - }, "assembly": { "name": "ConfigLib", "package": "net.nosial.configlib", + "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "version": "1.1.2", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, @@ -63,31 +38,26 @@ { "name": "net.nosial.optslib", "version": "latest", - "source_type": "remote", "source": "nosial/libs.opts=latest@n64" }, { "name": "net.nosial.loglib", "version": "latest", - "source_type": "remote", "source": "nosial/libs.log=latest@n64" }, { "name": "com.symfony.filesystem", "version": "latest", - "source_type": "remote", "source": "symfony/filesystem=latest@packagist" }, { "name": "com.symfony.yaml", "version": "latest", - "source_type": "remote", "source": "symfony/yaml=latest@packagist" }, { "name": "com.symfony.process", "version": "latest", - "source_type": "remote", "source": "symfony/process=latest@packagist" } ], @@ -104,7 +74,89 @@ "define_constants": { "DEBUG": "1" } + }, + { + "name": "release-compressed", + "build_type": "ncc", + "output": "build/release/%ASSEMBLY.PACKAGE%.gz.ncc", + "options": { + "compression": "high" + } + }, + { + "name": "debug-compressed", + "build_type": "ncc", + "output": "build/debug/%ASSEMBLY.PACKAGE%.gz.ncc", + "options": { + "compression": "high" + }, + "define_constants": { + "DEBUG": "1" + } + }, + { + "name": "release-executable", + "build_type": "executable", + "output": "build/release/release_executable_gz", + "options": { + "ncc_configuration": "release" + } + }, + { + "name": "debug-executable", + "build_type": "executable", + "output": "build/debug/debug_executable_gz", + "options": { + "ncc_configuration": "debug" + } + }, + { + "name": "release-compressed-executable", + "build_type": "executable", + "output": "build/release/release_compressed_executable", + "options": { + "ncc_configuration": "release-compressed" + } + }, + { + "name": "debug-compressed-executable", + "build_type": "executable", + "output": "build/debug/debug_compressed_executable", + "options": { + "ncc_configuration": "debug-compressed" + } } ] - } + }, + "installer": { + "post_install": [ + "setup" + ] + }, + "execution_policies": [ + { + "name": "main", + "runner": "php", + "execute": { + "working_directory": "%CWD%", + "silent": false, + "tty": true, + "timeout": null, + "idle_timeout": null, + "target": "main" + } + }, + { + "name": "setup", + "runner": "php", + "execute": { + "working_directory": "%CWD%", + "silent": false, + "tty": true, + "timeout": null, + "idle_timeout": null, + "target": "setup" + } + } + ] } \ No newline at end of file From 3cf70a1f2b5cf6b86f9ae3276be95954fde18dd0 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:50:03 -0400 Subject: [PATCH 29/45] Added upload-dcs stage --- .github/workflows/ncc_workflow.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 4a8eded..a2da786 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -526,6 +526,31 @@ jobs: wget https://phar.phpunit.de/phpunit-11.3.phar php phpunit-11.3.phar --configuration phpunit.xml + upload-docs: + needs: [generate-phpdoc] + 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 documentation artifact + uses: actions/download-artifact@v4 + with: + name: documentation + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + docs/ + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + upload-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] permissions: write-all From ec741fd3efdf1f90be9ab80aff304b00e2337dc0 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 12:50:47 -0400 Subject: [PATCH 30/45] Bumped Version --- CHANGELOG.md | 5 +++++ project.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02d7f1d..463f5cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.3] - 2024-10-13 + +This update introduces a new build system + + ## [1.1.2] - 2024-09-27 This update fixes a critical bug where configuration files may not be found when using different user accounts, diff --git a/project.json b/project.json index 714cd75..ef6c4f3 100644 --- a/project.json +++ b/project.json @@ -24,7 +24,7 @@ "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "version": "1.1.2", + "version": "1.1.3", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { From 870a8d6b4e891fbbeadc4f23dd74ff5a096b9f8a Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 13:26:57 -0400 Subject: [PATCH 31/45] Updated build system --- .github/workflows/ncc_workflow.yml | 92 +++++++++++++++++------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index a2da786..9baf988 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -526,31 +526,6 @@ jobs: wget https://phar.phpunit.de/phpunit-11.3.phar php phpunit-11.3.phar --configuration phpunit.xml - upload-docs: - needs: [generate-phpdoc] - 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 documentation artifact - uses: actions/download-artifact@v4 - with: - name: documentation - - - name: Upload to GitHub Release - uses: softprops/action-gh-release@v1 - with: - files: | - docs/ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - upload-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] permissions: write-all @@ -568,55 +543,94 @@ jobs: with: name: release path: release + - name: Upload release artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + release/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download debug artifact uses: actions/download-artifact@v4 with: name: debug path: debug + - name: Upload debug artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + debug/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download release-compressed artifact uses: actions/download-artifact@v4 with: name: release-compressed path: release-compressed + - name: Upload release-compressed artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + release-compressed/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download debug-compressed artifact uses: actions/download-artifact@v4 with: name: debug-compressed path: debug-compressed + - name: Upload debug-compressed artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + debug-compressed/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download release-executable artifact uses: actions/download-artifact@v4 with: name: release-executable path: release-executable + - name: Upload release-executable artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + release-executable/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download debug-executable artifact uses: actions/download-artifact@v4 with: name: debug-executable path: debug-executable + - name: Upload debug-executable artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + debug-executable/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download release-compressed-executable artifact uses: actions/download-artifact@v4 with: name: release-compressed-executable path: release-compressed-executable + - name: Upload release-compressed-executable artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + release-compressed-executable/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download debug-compressed-executable artifact uses: actions/download-artifact@v4 with: name: debug-compressed-executable path: debug-compressed-executable - - - - name: Upload to GitHub Release + - name: Upload debug-compressed-executable artifact to release uses: softprops/action-gh-release@v1 with: - files: | - release/net.nosial.configlib.ncc - debug/net.nosial.configlib.ncc - release-compressed/net.nosial.configlib.gz.ncc - debug-compressed/net.nosial.configlib.gz.ncc - release-executable/release_executable_gz - debug-executable/debug_executable_gz - release-compressed-executable/release_compressed_executable - debug-compressed-executable/debug_compressed_executable - + files: | + debug-compressed-executable/* env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 84ad9a9fb36f0be90b3319e791471719523094aa Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 13:32:34 -0400 Subject: [PATCH 32/45] Updated build system --- .github/workflows/ncc_workflow.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 9baf988..8b623cd 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -526,6 +526,31 @@ jobs: wget https://phar.phpunit.de/phpunit-11.3.phar php phpunit-11.3.phar --configuration phpunit.xml + upload-documentation: + needs: generate-phpdoc + 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 documentation artifact + uses: actions/download-artifact@v4 + with: + name: documentation + + - name: Upload documentation artifact to release + uses: softprops/action-gh-release@v1 + with: + files: | + docs/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + upload-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] permissions: write-all From 7411563758fbe3b169ffa8e04e3d0779ecaddaea Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 13:33:37 -0400 Subject: [PATCH 33/45] Added phpdoc.dist.xml --- phpdoc.dist.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phpdoc.dist.xml diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 0000000..b33df6a --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,15 @@ + + + + build/docs + build/cache + + + + + src/ConfigLib + + ConfigLib + + + \ No newline at end of file From 371c486c4ff0ed5be58f06cf3ac2d3b8699ffe72 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 13:37:02 -0400 Subject: [PATCH 34/45] Updated build system --- .github/workflows/ncc_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 8b623cd..5f60a42 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -547,7 +547,7 @@ jobs: uses: softprops/action-gh-release@v1 with: files: | - docs/* + documentation/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1eae8df0e34d0304b1b40944d58ede979faf70f5 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:17:17 -0400 Subject: [PATCH 35/45] Updated build system --- .github/workflows/ncc_workflow.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 5f60a42..5033156 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -524,9 +524,16 @@ jobs: - name: Run PHPUnit tests run: | wget https://phar.phpunit.de/phpunit-11.3.phar - php phpunit-11.3.phar --configuration phpunit.xml + php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt --log-events-text reports/events.txt --log-events-verbose-text reports/verbose_events.txt - upload-documentation: + - name: Upload test reports + uses: actions/upload-artifact@v4 + with: + name: reports + path: reports + + + release-documentation: needs: generate-phpdoc permissions: write-all runs-on: ubuntu-latest @@ -551,8 +558,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - upload-artifacts: - needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, test] + release-artifacts: + needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable] permissions: write-all runs-on: ubuntu-latest container: From 19935179a0b9b3288443af9dc9195be122f5e8a6 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:17:27 -0400 Subject: [PATCH 36/45] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 211f710..2ab886f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ /.idea/php-test-framework.xml /.idea/gbrowser_project.xml +/.phpunit.result.cache From 56f57f89def36331ff3ddaf1a35669340e8ca884 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:23:16 -0400 Subject: [PATCH 37/45] Updated build system --- .github/workflows/ncc_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 5033156..4677680 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -524,7 +524,7 @@ jobs: - name: Run PHPUnit tests run: | wget https://phar.phpunit.de/phpunit-11.3.phar - php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt --log-events-text reports/events.txt --log-events-verbose-text reports/verbose_events.txt + php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt - name: Upload test reports uses: actions/upload-artifact@v4 From 8dc2d1c70d48e89c34d13e9947af625c71cef3ab Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:23:36 -0400 Subject: [PATCH 38/45] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2ab886f..6333a2b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ /.idea/php-test-framework.xml /.idea/gbrowser_project.xml /.phpunit.result.cache +/reports \ No newline at end of file From 2c33fa2f4984b7933279fc8c3d7a8bb490631678 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:26:02 -0400 Subject: [PATCH 39/45] Updated build system --- .github/workflows/ncc_workflow.yml | 1 + .idea/ConfigLib.iml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 4677680..857b7f3 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -549,6 +549,7 @@ jobs: uses: actions/download-artifact@v4 with: name: documentation + path: documentation - name: Upload documentation artifact to release uses: softprops/action-gh-release@v1 diff --git a/.idea/ConfigLib.iml b/.idea/ConfigLib.iml index 24c8dff..5527d54 100644 --- a/.idea/ConfigLib.iml +++ b/.idea/ConfigLib.iml @@ -5,6 +5,7 @@ + From bb4a93a364602f6eb14fda8bc548c224b0a41d8a Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:32:41 -0400 Subject: [PATCH 40/45] Updated Build System --- .github/workflows/ncc_workflow.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index 857b7f3..eb47ebe 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -551,14 +551,19 @@ jobs: name: documentation path: documentation - - name: Upload documentation artifact to release + - name: zip documentation + run: | + zip -r documentation.zip documentation + + - name: Upload documentation artifact uses: softprops/action-gh-release@v1 with: files: | - documentation/* + documentation.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release-artifacts: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable] permissions: write-all From cd4ea10fd6482645890228f4fe46e41123cc108b Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:35:54 -0400 Subject: [PATCH 41/45] Updated Build System --- .github/workflows/ncc_workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index eb47ebe..f5f9bde 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -553,6 +553,8 @@ jobs: - name: zip documentation run: | + sudo apt-get update + sudo apt-get install zip zip -r documentation.zip documentation - name: Upload documentation artifact From 65125c496ac8afd7b0139d7554dcb3e798d41187 Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 13 Oct 2024 14:41:27 -0400 Subject: [PATCH 42/45] Updated Build System --- .github/workflows/ncc_workflow.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ncc_workflow.yml b/.github/workflows/ncc_workflow.yml index f5f9bde..5f5ff8b 100644 --- a/.github/workflows/ncc_workflow.yml +++ b/.github/workflows/ncc_workflow.yml @@ -460,11 +460,15 @@ jobs: run: | php phpDocumentor.phar -d src -t docs + - name: Archive PHPDoc + run: | + zip -r docs.zip docs + - name: Upload PHPDoc uses: actions/upload-artifact@v4 with: name: documentation - path: docs + path: docs.zip test: needs: [release, debug, release-compressed, debug-compressed, release-executable, debug-executable, release-compressed-executable, debug-compressed-executable, check-phpunit] @@ -551,17 +555,11 @@ jobs: name: documentation path: documentation - - name: zip documentation - run: | - sudo apt-get update - sudo apt-get install zip - zip -r documentation.zip documentation - - name: Upload documentation artifact uses: softprops/action-gh-release@v1 with: files: | - documentation.zip + documentation/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e96695a5d8a459c47cfa0a06caa637fb1042f9bb Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 25 Oct 2024 20:01:15 -0400 Subject: [PATCH 43/45] Bumped version to 1.1.4 --- project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.json b/project.json index ef6c4f3..e880414 100644 --- a/project.json +++ b/project.json @@ -24,7 +24,7 @@ "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "version": "1.1.3", + "version": "1.1.4", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { From 0d823c88e756c3879ad2d3e4d45554b3e84e7eca Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 29 Oct 2024 00:23:02 -0400 Subject: [PATCH 44/45] Fixed regex pattern for configuration properties being considered invalid when they contain an underscore. --- .idea/php.xml | 14 ++++++++------ CHANGELOG.md | 8 ++++++++ src/ConfigLib/Configuration.php | 3 +-- tests/ConfigLib/ConfigurationTest.php | 7 ++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index 9144d49..49f80d7 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,14 +11,16 @@ - - - + + + + + - - + + + - diff --git a/CHANGELOG.md b/CHANGELOG.md index 463f5cb..c90335e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.4] - Ongoing + +This update introduces a minor bug fix + +### Fixed + - Fixed regex pattern for configuration properties being considered invalid when they contain an underscore. + + ## [1.1.3] - 2024-10-13 This update introduces a new build system diff --git a/src/ConfigLib/Configuration.php b/src/ConfigLib/Configuration.php index 7567b06..24be647 100644 --- a/src/ConfigLib/Configuration.php +++ b/src/ConfigLib/Configuration.php @@ -167,11 +167,10 @@ */ private static function validateKey(string $input): bool { - if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input)) + if (preg_match('/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$/', $input)) { return true; } - return false; } diff --git a/tests/ConfigLib/ConfigurationTest.php b/tests/ConfigLib/ConfigurationTest.php index 2f8330b..2ec4b21 100644 --- a/tests/ConfigLib/ConfigurationTest.php +++ b/tests/ConfigLib/ConfigurationTest.php @@ -9,7 +9,11 @@ class ConfigurationTest extends TestCase public static function setUpBeforeClass(): void { $config = new Configuration('test'); - unlink($config->getPath()); + + if(file_exists($config->getPath())) + { + unlink($config->getPath()); + } } public function testConstruct(): void @@ -24,6 +28,7 @@ class ConfigurationTest extends TestCase $this->assertTrue($config->set('key1.key2', 'value', true)); $this->assertEquals('value', $config->get('key1.key2')); + } public function testSetNotExists(): void From 76ca3f5290426d5f45eb2d74aa09205f89b8489c Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 29 Oct 2024 00:23:18 -0400 Subject: [PATCH 45/45] Updated CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c90335e..e046d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.1.4] - Ongoing +## [1.1.4] - 2024-10-29 This update introduces a minor bug fix