From 4d0a79b2272e409d1986e69715793bab3c674efc Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 18:12:31 -0800 Subject: [PATCH 01/14] what's the extension available --- .github/workflows/ci.yml | 124 ++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fbeb6f..23ce68d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,73 +14,73 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} jobs: - php-5_5-linux-x64: - name: php-linux-x64 (5.5) - runs-on: ubuntu-latest - steps: - - name: Setup PHP with Xdebug - uses: shivammathur/setup-php@v2 - with: - coverage: xdebug - php-version: 5.5 - ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false + # php-5_5-linux-x64: + # name: php-linux-x64 (5.5) + # runs-on: ubuntu-latest + # steps: + # - name: Setup PHP with Xdebug + # uses: shivammathur/setup-php@v2 + # with: + # coverage: xdebug + # php-version: 5.5 + # ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive + # - name: Checkout + # uses: actions/checkout@v2 + # with: + # submodules: recursive - - name: Build for PHP 5.5 - env: - CC: clang - CXX: clang++ - run: | - phpize - ./configure - make + # - name: Build for PHP 5.5 + # env: + # CC: clang + # CXX: clang++ + # run: | + # phpize + # ./configure + # make - - name: Install dependencies - run: | - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php composer-setup.php - php -c php.ini composer.phar require --dev --ignore-platform-reqs phpunit/phpunit "4.8.36" - php -c php.ini composer.phar update --no-interaction + # - name: Install dependencies + # run: | + # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + # php composer-setup.php + # php -c php.ini composer.phar require --dev --ignore-platform-reqs phpunit/phpunit "4.8.36" + # php -c php.ini composer.phar update --no-interaction - php-linux-x64: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" - - "8.0" - steps: - - name: Setup PHP with Xdebug - uses: shivammathur/setup-php@v2 - with: - coverage: xdebug - php-version: ${{matrix.version}} - ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false + # php-linux-x64: + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # version: + # - "5.6" + # - "7.0" + # - "7.1" + # - "7.2" + # - "7.3" + # - "7.4" + # - "8.0" + # steps: + # - name: Setup PHP with Xdebug + # uses: shivammathur/setup-php@v2 + # with: + # coverage: xdebug + # php-version: ${{matrix.version}} + # ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive + # - name: Checkout + # uses: actions/checkout@v2 + # with: + # submodules: recursive - - name: Run tests - env: - CC: clang - CXX: clang++ - run: | - phpize - ./configure - make - ./dev-scripts/run_tests + # - name: Run tests + # env: + # CC: clang + # CXX: clang++ + # run: | + # phpize + # ./configure + # make + # ./dev-scripts/run_tests # linux-arm: # name: ARM (${{ matrix.arch }}) @@ -117,6 +117,8 @@ jobs: toolset: ${{steps.setup-php-sdk.outputs.toolset}} - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | + ls php-bin + ls php-bin/ext phpize .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl nmake From acf8cb072ad818cc42764de8de1be4c5d4cd1b4d Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 18:25:36 -0800 Subject: [PATCH 02/14] try this out --- .github/workflows/ci.yml | 84 +++++++++++++++++++-------------------- composer.json | 3 +- dev-scripts/run_tests.bat | 3 +- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23ce68d..af5f7fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,48 +142,48 @@ jobs: # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" # python builder.pyz build -p ${{ env.PACKAGE_NAME }} downstream - macos: - runs-on: macos-${{ matrix.version }} - strategy: - matrix: - version: [10.15] - steps: - # Force PHP to 8.0 - # Doing this because tests fail in PHP 8.1 (default on macos Github Runner as of Dec 2021) - # due to the old version of PHPUnit we're using. - # We're using an old PHPUnit because it's compatible our min supported PHP 5.5. - # Quick fix is to force PHP version back to 8.0, which can still run our tests without error. - # A real solution is to get our tests working on all PHP versions - # (maybe don't use PHPUnit, maybe raise our min supported PHP version so we can upgrade, - # or maybe use PHPUnit-Polyfills so we can use a modern PHPUnit with old PHP) - - name: Setup PHP 8.0 - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - - name: Build PHP 8 extension and test - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" - chmod a+x builder - ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + # macos: + # runs-on: macos-${{ matrix.version }} + # strategy: + # matrix: + # version: [10.15] + # steps: + # # Force PHP to 8.0 + # # Doing this because tests fail in PHP 8.1 (default on macos Github Runner as of Dec 2021) + # # due to the old version of PHPUnit we're using. + # # We're using an old PHPUnit because it's compatible our min supported PHP 5.5. + # # Quick fix is to force PHP version back to 8.0, which can still run our tests without error. + # # A real solution is to get our tests working on all PHP versions + # # (maybe don't use PHPUnit, maybe raise our min supported PHP version so we can upgrade, + # # or maybe use PHPUnit-Polyfills so we can use a modern PHPUnit with old PHP) + # - name: Setup PHP 8.0 + # uses: shivammathur/setup-php@v2 + # with: + # php-version: '8.0' + # - name: Build PHP 8 extension and test + # run: | + # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" + # chmod a+x builder + # ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream - pecl-package-test: - runs-on: macos-latest - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' + # pecl-package-test: + # runs-on: macos-latest + # steps: + # - name: Setup PHP + # uses: shivammathur/setup-php@v2 + # with: + # php-version: '8.0' - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive + # - name: Checkout + # uses: actions/checkout@v2 + # with: + # submodules: recursive - - name: Run tests - run: | - ./dev-scripts/prepare_release.sh --name aws-crt --user aws-crt --email aws-sdk-common-runtime@amazon.com --version 1.0.0 --notes NOTES - tar -zxf *.tgz - cd awscrt-1.0.0 - phpize - ./configure - make + # - name: Run tests + # run: | + # ./dev-scripts/prepare_release.sh --name aws-crt --user aws-crt --email aws-sdk-common-runtime@amazon.com --version 1.0.0 --notes NOTES + # tar -zxf *.tgz + # cd awscrt-1.0.0 + # phpize + # ./configure + # make diff --git a/composer.json b/composer.json index f7dbdd9..6f1e6ee 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,7 @@ }, "minimum-stability": "alpha", "require": { - "php": ">=5.5", - "ext-awscrt": "*" + "php": ">=5.5" }, "require-dev": { "phpunit/phpunit":"^5.6.3" diff --git a/dev-scripts/run_tests.bat b/dev-scripts/run_tests.bat index 5611d2c..a7b1eef 100644 --- a/dev-scripts/run_tests.bat +++ b/dev-scripts/run_tests.bat @@ -11,7 +11,6 @@ if not "%~1"=="" ( set "PHP_BINARY=%~1" ) - REM Check if composer_dir was found if "%composer_dir%"=="" ( echo No composer found. @@ -22,7 +21,7 @@ set "script_dir=%~dp0" set "work_dir=%script_dir%/.." cd %work_dir% -call %PHP_BINARY% -c php-win.ini %composer_dir% update +composer update call %PHP_BINARY% -c php-win.ini vendor/bin/phpunit tests --debug From 4718d07921924719a3b4fad8f62e1a6fd47df7d1 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 18:36:28 -0800 Subject: [PATCH 03/14] update from outside the bat? --- .github/workflows/ci.yml | 1 + dev-scripts/run_tests.bat | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af5f7fc..fcec817 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,6 +123,7 @@ jobs: .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl nmake nmake generate-php-ini + composer update --ignore-platform-req=ext-awscrt .\dev-scripts\run_tests ${{steps.setup-php-sdk.outputs.prefix}}\php # windows-vc14: diff --git a/dev-scripts/run_tests.bat b/dev-scripts/run_tests.bat index a7b1eef..fff4913 100644 --- a/dev-scripts/run_tests.bat +++ b/dev-scripts/run_tests.bat @@ -21,7 +21,6 @@ set "script_dir=%~dp0" set "work_dir=%script_dir%/.." cd %work_dir% -composer update call %PHP_BINARY% -c php-win.ini vendor/bin/phpunit tests --debug From f098c102f0d17818133b82e1bab517b57b746b58 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:26:42 -0800 Subject: [PATCH 04/14] get the full path of the extension --- .github/workflows/ci.yml | 4 +--- Makefile.frag.w32 | 2 ++ dev-scripts/run_tests.bat | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcec817..00252df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,13 +117,11 @@ jobs: toolset: ${{steps.setup-php-sdk.outputs.toolset}} - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - ls php-bin - ls php-bin/ext phpize .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl nmake nmake generate-php-ini - composer update --ignore-platform-req=ext-awscrt + type .\php-win.ini .\dev-scripts\run_tests ${{steps.setup-php-sdk.outputs.prefix}}\php # windows-vc14: diff --git a/Makefile.frag.w32 b/Makefile.frag.w32 index 14cd941..b37987b 100644 --- a/Makefile.frag.w32 +++ b/Makefile.frag.w32 @@ -27,3 +27,5 @@ $(AWSCRT_DIR)\ext\api.h: $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h # Get the dll directory to load generate-php-ini: @echo extension=$(BUILD_DIR)\php_awscrt.dll > php-win.ini + @echo extension=$(PHP_PREFIX)\php_openssl.dll >> php-win.ini + @echo extension=$(PHP_PREFIX)\php_mbstring.dll >> php-win.ini diff --git a/dev-scripts/run_tests.bat b/dev-scripts/run_tests.bat index fff4913..e92f1cb 100644 --- a/dev-scripts/run_tests.bat +++ b/dev-scripts/run_tests.bat @@ -21,6 +21,7 @@ set "script_dir=%~dp0" set "work_dir=%script_dir%/.." cd %work_dir% +call %PHP_BINARY% -c php-win.ini %composer_dir% update call %PHP_BINARY% -c php-win.ini vendor/bin/phpunit tests --debug From 987d5a07a7ce3117801540a63aa48a5523463a0d Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:32:57 -0800 Subject: [PATCH 05/14] forgot ext --- Makefile.frag.w32 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.frag.w32 b/Makefile.frag.w32 index b37987b..441abcd 100644 --- a/Makefile.frag.w32 +++ b/Makefile.frag.w32 @@ -27,5 +27,5 @@ $(AWSCRT_DIR)\ext\api.h: $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h # Get the dll directory to load generate-php-ini: @echo extension=$(BUILD_DIR)\php_awscrt.dll > php-win.ini - @echo extension=$(PHP_PREFIX)\php_openssl.dll >> php-win.ini - @echo extension=$(PHP_PREFIX)\php_mbstring.dll >> php-win.ini + @echo extension=$(PHP_PREFIX)\ext\php_openssl.dll >> php-win.ini + @echo extension=$(PHP_PREFIX)\ext\php_mbstring.dll >> php-win.ini From 7be4c7c888f16b51a09f45813b51a1406c0dd22f Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:41:23 -0800 Subject: [PATCH 06/14] finally, get the window CI running --- .github/workflows/ci.yml | 230 +++++++++++++++++++-------------------- php-win.ini | 2 +- 2 files changed, 116 insertions(+), 116 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00252df..70212c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,86 +14,86 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} jobs: - # php-5_5-linux-x64: - # name: php-linux-x64 (5.5) - # runs-on: ubuntu-latest - # steps: - # - name: Setup PHP with Xdebug - # uses: shivammathur/setup-php@v2 - # with: - # coverage: xdebug - # php-version: 5.5 - # ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false + php-5_5-linux-x64: + name: php-linux-x64 (5.5) + runs-on: ubuntu-latest + steps: + - name: Setup PHP with Xdebug + uses: shivammathur/setup-php@v2 + with: + coverage: xdebug + php-version: 5.5 + ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false - # - name: Checkout - # uses: actions/checkout@v2 - # with: - # submodules: recursive + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive - # - name: Build for PHP 5.5 - # env: - # CC: clang - # CXX: clang++ - # run: | - # phpize - # ./configure - # make + - name: Build for PHP 5.5 + env: + CC: clang + CXX: clang++ + run: | + phpize + ./configure + make - # - name: Install dependencies - # run: | - # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - # php composer-setup.php - # php -c php.ini composer.phar require --dev --ignore-platform-reqs phpunit/phpunit "4.8.36" - # php -c php.ini composer.phar update --no-interaction + - name: Install dependencies + run: | + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + php composer-setup.php + php -c php.ini composer.phar require --dev --ignore-platform-reqs phpunit/phpunit "4.8.36" + php -c php.ini composer.phar update --no-interaction - # php-linux-x64: - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # matrix: - # version: - # - "5.6" - # - "7.0" - # - "7.1" - # - "7.2" - # - "7.3" - # - "7.4" - # - "8.0" - # steps: - # - name: Setup PHP with Xdebug - # uses: shivammathur/setup-php@v2 - # with: - # coverage: xdebug - # php-version: ${{matrix.version}} - # ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false + php-linux-x64: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - "5.6" + - "7.0" + - "7.1" + - "7.2" + - "7.3" + - "7.4" + - "8.0" + steps: + - name: Setup PHP with Xdebug + uses: shivammathur/setup-php@v2 + with: + coverage: xdebug + php-version: ${{matrix.version}} + ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false - # - name: Checkout - # uses: actions/checkout@v2 - # with: - # submodules: recursive + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive - # - name: Run tests - # env: - # CC: clang - # CXX: clang++ - # run: | - # phpize - # ./configure - # make - # ./dev-scripts/run_tests + - name: Run tests + env: + CC: clang + CXX: clang++ + run: | + phpize + ./configure + make + ./dev-scripts/run_tests - # linux-arm: - # name: ARM (${{ matrix.arch }}) - # runs-on: ubuntu-latest - # strategy: - # matrix: - # arch: [armv6, armv7, arm64] - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" - # chmod a+x builder - # ./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream + linux-arm: + name: ARM (${{ matrix.arch }}) + runs-on: ubuntu-latest + strategy: + matrix: + arch: [armv6, armv7, arm64] + steps: + - name: Build ${{ env.PACKAGE_NAME }} + run: | + python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" + chmod a+x builder + ./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream windows-vc16: runs-on: windows-2019 @@ -141,48 +141,48 @@ jobs: # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" # python builder.pyz build -p ${{ env.PACKAGE_NAME }} downstream - # macos: - # runs-on: macos-${{ matrix.version }} - # strategy: - # matrix: - # version: [10.15] - # steps: - # # Force PHP to 8.0 - # # Doing this because tests fail in PHP 8.1 (default on macos Github Runner as of Dec 2021) - # # due to the old version of PHPUnit we're using. - # # We're using an old PHPUnit because it's compatible our min supported PHP 5.5. - # # Quick fix is to force PHP version back to 8.0, which can still run our tests without error. - # # A real solution is to get our tests working on all PHP versions - # # (maybe don't use PHPUnit, maybe raise our min supported PHP version so we can upgrade, - # # or maybe use PHPUnit-Polyfills so we can use a modern PHPUnit with old PHP) - # - name: Setup PHP 8.0 - # uses: shivammathur/setup-php@v2 - # with: - # php-version: '8.0' - # - name: Build PHP 8 extension and test - # run: | - # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" - # chmod a+x builder - # ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + macos: + runs-on: macos-${{ matrix.version }} + strategy: + matrix: + version: [10.15] + steps: + # Force PHP to 8.0 + # Doing this because tests fail in PHP 8.1 (default on macos Github Runner as of Dec 2021) + # due to the old version of PHPUnit we're using. + # We're using an old PHPUnit because it's compatible our min supported PHP 5.5. + # Quick fix is to force PHP version back to 8.0, which can still run our tests without error. + # A real solution is to get our tests working on all PHP versions + # (maybe don't use PHPUnit, maybe raise our min supported PHP version so we can upgrade, + # or maybe use PHPUnit-Polyfills so we can use a modern PHPUnit with old PHP) + - name: Setup PHP 8.0 + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + - name: Build PHP 8 extension and test + run: | + python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" + chmod a+x builder + ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream - # pecl-package-test: - # runs-on: macos-latest - # steps: - # - name: Setup PHP - # uses: shivammathur/setup-php@v2 - # with: - # php-version: '8.0' + pecl-package-test: + runs-on: macos-latest + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' - # - name: Checkout - # uses: actions/checkout@v2 - # with: - # submodules: recursive + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive - # - name: Run tests - # run: | - # ./dev-scripts/prepare_release.sh --name aws-crt --user aws-crt --email aws-sdk-common-runtime@amazon.com --version 1.0.0 --notes NOTES - # tar -zxf *.tgz - # cd awscrt-1.0.0 - # phpize - # ./configure - # make + - name: Run tests + run: | + ./dev-scripts/prepare_release.sh --name aws-crt --user aws-crt --email aws-sdk-common-runtime@amazon.com --version 1.0.0 --notes NOTES + tar -zxf *.tgz + cd awscrt-1.0.0 + phpize + ./configure + make diff --git a/php-win.ini b/php-win.ini index 31d5621..fb0f704 100644 --- a/php-win.ini +++ b/php-win.ini @@ -1,3 +1,3 @@ -extension_dir="ext" +extension=php_awscrt.dll extension=php_openssl.dll extension=php_mbstring.dll \ No newline at end of file From 5667b284ad1480f6396557a21b7000a7180d369c Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:45:38 -0800 Subject: [PATCH 07/14] try if it catches the error --- .github/workflows/ci.yml | 3 +++ Makefile.frag.w32 | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70212c8..fc611be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,9 @@ jobs: windows-vc16: runs-on: windows-2019 + defaults: + run: + shell: cmd # TODO: does this matter make the error out? strategy: matrix: arch: [x64] diff --git a/Makefile.frag.w32 b/Makefile.frag.w32 index 441abcd..3090286 100644 --- a/Makefile.frag.w32 +++ b/Makefile.frag.w32 @@ -27,5 +27,5 @@ $(AWSCRT_DIR)\ext\api.h: $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h # Get the dll directory to load generate-php-ini: @echo extension=$(BUILD_DIR)\php_awscrt.dll > php-win.ini - @echo extension=$(PHP_PREFIX)\ext\php_openssl.dll >> php-win.ini + @echo extension=$(PHP_PREFIX)\php_openssl.dll >> php-win.ini @echo extension=$(PHP_PREFIX)\ext\php_mbstring.dll >> php-win.ini From 9e95d7fc0afb79656dd85bd25b6d81ad0833dfc4 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:46:54 -0800 Subject: [PATCH 08/14] keep the arm linux out --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc611be..c2e7ff5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,18 +82,18 @@ jobs: make ./dev-scripts/run_tests - linux-arm: - name: ARM (${{ matrix.arch }}) - runs-on: ubuntu-latest - strategy: - matrix: - arch: [armv6, armv7, arm64] - steps: - - name: Build ${{ env.PACKAGE_NAME }} - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" - chmod a+x builder - ./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream + # linux-arm: + # name: ARM (${{ matrix.arch }}) + # runs-on: ubuntu-latest + # strategy: + # matrix: + # arch: [armv6, armv7, arm64] + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" + # chmod a+x builder + # ./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream windows-vc16: runs-on: windows-2019 From 7ac1c8abb04b2825ecee191982dffb125f7fc0ff Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 21:58:36 -0800 Subject: [PATCH 09/14] what happened? --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2e7ff5..15a94c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,9 +97,6 @@ jobs: windows-vc16: runs-on: windows-2019 - defaults: - run: - shell: cmd # TODO: does this matter make the error out? strategy: matrix: arch: [x64] @@ -119,6 +116,7 @@ jobs: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - name: Build ${{ env.PACKAGE_NAME }} + consumers + shell: cmd run: | phpize .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl From 79b877203a0485a200ad89c4c6512ea599833b39 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 22:03:34 -0800 Subject: [PATCH 10/14] why --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15a94c7..9c2ec31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,6 @@ jobs: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - name: Build ${{ env.PACKAGE_NAME }} + consumers - shell: cmd run: | phpize .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl From 830ac2d84176ee15eeb2a999f75c415de46b1a1a Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 22:23:04 -0800 Subject: [PATCH 11/14] keep every step separate? --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c2ec31..68222b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,9 @@ jobs: windows-vc16: runs-on: windows-2019 + defaults: + run: + shell: cmd # TODO: does this matter? strategy: matrix: arch: [x64] @@ -115,14 +118,11 @@ jobs: with: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - phpize - .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl - nmake - nmake generate-php-ini - type .\php-win.ini - .\dev-scripts\run_tests ${{steps.setup-php-sdk.outputs.prefix}}\php + - run: phpize + - run: .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl + - run: nmake + - run: nmake generate-php-ini + - run: .\dev-scripts\run_tests ${{steps.setup-php-sdk.outputs.prefix}}\php # windows-vc14: # runs-on: windows-latest From 4d5420dffcb04748c0e5febd826c3dcedb85f998 Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Thu, 23 Feb 2023 22:30:30 -0800 Subject: [PATCH 12/14] done --- .github/workflows/ci.yml | 3 ++- Makefile.frag.w32 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68222b2..e67912e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,7 +99,7 @@ jobs: runs-on: windows-2019 defaults: run: - shell: cmd # TODO: does this matter? + shell: cmd # use CMD instead of powershell to catch error from bat script strategy: matrix: arch: [x64] @@ -118,6 +118,7 @@ jobs: with: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} + # CMD only execute one commend per run - run: phpize - run: .\configure --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} --enable-awscrt=shared --enable-cli --enable-openssl - run: nmake diff --git a/Makefile.frag.w32 b/Makefile.frag.w32 index 3090286..441abcd 100644 --- a/Makefile.frag.w32 +++ b/Makefile.frag.w32 @@ -27,5 +27,5 @@ $(AWSCRT_DIR)\ext\api.h: $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h # Get the dll directory to load generate-php-ini: @echo extension=$(BUILD_DIR)\php_awscrt.dll > php-win.ini - @echo extension=$(PHP_PREFIX)\php_openssl.dll >> php-win.ini + @echo extension=$(PHP_PREFIX)\ext\php_openssl.dll >> php-win.ini @echo extension=$(PHP_PREFIX)\ext\php_mbstring.dll >> php-win.ini From cdef4b7ef1531465d2be8930f1e2bc4825f1d67e Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Fri, 24 Feb 2023 15:39:09 -0800 Subject: [PATCH 13/14] update helper scripts and more --- .github/workflows/ci.yml | 6 +- dev-scripts/cleanup.sh | 48 -------- dev-scripts/cleanup_build.py | 40 +++++++ dev-scripts/prepare_package_xml.sh | 152 ------------------------ dev-scripts/prepare_pecl_package_xml.py | 147 +++++++++++++++++++++++ dev-scripts/prepare_pecl_release.py | 47 ++++++++ dev-scripts/prepare_release.sh | 41 ------- dev-scripts/run_tests.bat | 26 ++-- dev-scripts/{run_tests => run_tests.sh} | 0 dev-scripts/test.py | 9 ++ php-win.ini | 2 +- 11 files changed, 262 insertions(+), 256 deletions(-) delete mode 100755 dev-scripts/cleanup.sh create mode 100644 dev-scripts/cleanup_build.py delete mode 100755 dev-scripts/prepare_package_xml.sh create mode 100644 dev-scripts/prepare_pecl_package_xml.py create mode 100644 dev-scripts/prepare_pecl_release.py delete mode 100755 dev-scripts/prepare_release.sh rename dev-scripts/{run_tests => run_tests.sh} (100%) create mode 100644 dev-scripts/test.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e67912e..0ed8153 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,7 @@ jobs: ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream pecl-package-test: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -179,9 +179,9 @@ jobs: with: submodules: recursive - - name: Run tests + - name: Test PECL package build run: | - ./dev-scripts/prepare_release.sh --name aws-crt --user aws-crt --email aws-sdk-common-runtime@amazon.com --version 1.0.0 --notes NOTES + python3 dev-scripts/prepare_pecl_release.py --name aws-crt --user aws-crt --version 1.0.0 tar -zxf *.tgz cd awscrt-1.0.0 phpize diff --git a/dev-scripts/cleanup.sh b/dev-scripts/cleanup.sh deleted file mode 100755 index ad43122..0000000 --- a/dev-scripts/cleanup.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -BASENAME=${0} -TOOLS_DIR=$(dirname ${BASENAME}) -WORK_DIR="${TOOLS_DIR}/.." - -cd "${WORK_DIR}" - -find . -name \*.tgz -a |xargs rm -rf - -## get rid of anything that phpize, configure and make as well -rm -rf .deps \ -.libs \ -Makefile \ -Makefile.fragments \ -Makefile.global \ -Makefile.objects \ -acinclude.m4 \ -aclocal.m4 \ -autom4te.cache \ -build \ -config.guess \ -config.h \ -config.h.in* \ -config.log \ -config.nice \ -config.status \ -config.sub \ -configure \ -configure.in \ -configure.ac \ -include \ -install-sh \ -libtool \ -ltmain.sh \ -missing \ -mkinstalldirs \ -modules \ -run-tests.php \ -awscrt.la \ -vendor \ -composer.lock \ -ext/awscrt.stub.php \ - -find . -name \*.lo -o -name \*.o | xargs rm -f -find . -name \*.la -o -name \*.a | xargs rm -f -find . -name \*.so | xargs rm -f -find . -name .libs -a -type d|xargs rm -rf diff --git a/dev-scripts/cleanup_build.py b/dev-scripts/cleanup_build.py new file mode 100644 index 0000000..41cafaf --- /dev/null +++ b/dev-scripts/cleanup_build.py @@ -0,0 +1,40 @@ +import os +import glob +import shutil + +TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) +WORK_DIR = os.path.join(TOOLS_DIR, '..') + + +def remove_files(files): + for file in files: + if os.path.exists(file): + os.remove(file) + + +os.chdir(WORK_DIR) + +# Remove specified directories +dirs_to_remove = ['.deps', '.libs', 'build', 'include', 'modules', 'vendor'] +for directory in dirs_to_remove: + shutil.rmtree(directory, ignore_errors=True) + +# Remove specified files +files_to_remove = ['Makefile', 'Makefile.fragments', 'Makefile.global', 'Makefile.objects', + 'config.guess', 'config.h', 'config.log', 'config.nice', 'config.status', + 'config.sub', 'configure', 'configure.in', 'configure.ac', 'install-sh', + 'libtool', 'ltmain.sh', 'missing', 'mkinstalldirs', 'run-tests.php', + 'awscrt.la', 'composer.lock', 'ext/awscrt.stub.php', 'acinclude.m4', 'aclocal.m4', + 'autom4te.cache'] + +# Remove all .lo and .o files +files_to_remove += glob.glob(os.path.join(WORK_DIR, '**/*.lo')) +files_to_remove += glob.glob(os.path.join(WORK_DIR, '**/*.o')) + +# Remove all .la and .a files +files_to_remove += glob.glob(os.path.join(WORK_DIR, '**/*.la')) +files_to_remove += glob.glob(os.path.join(WORK_DIR, '**/*.a')) +# Remove all .tgz files +files_to_remove += glob.glob(os.path.join(WORK_DIR, '*.tgz')) + +remove_files(files_to_remove) diff --git a/dev-scripts/prepare_package_xml.sh b/dev-scripts/prepare_package_xml.sh deleted file mode 100755 index 29fcff8..0000000 --- a/dev-scripts/prepare_package_xml.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/zsh -zparseopts -A opts -name: -user: -email: -version: -notes: -if [[ $# -lt 10 ]] -then - echo "Usage ${0} --name NAME, --user USER --email EMAIL --version VERSION --notes NOTES" - exit 1 -fi -NAME="${opts[--name]}" -USER="${opts[--user]}" -EMAIL="${opts[--email]}" -VERSION="${opts[--version]}" -NOTES="${opts[--notes]}" - -BASENAME=${0} -TOOLS_DIR=$(dirname ${BASENAME}) - -TODAY=$(date -u +%Y-%m-%d) - -cat $TOOLS_DIR/package.xml-template_pre \ - | sed "s/{{{NAME}}}/$NAME/g" \ - | sed "s/{{{USER}}}/$USER/g" \ - | sed "s/{{{EMAIL}}}/$EMAIL/g" \ - | sed "s/{{{TODAY}}}/$TODAY/g" \ - | sed "s/{{{VERSION}}}/$VERSION/g" \ - | sed "s/{{{NOTES}}}/$NOTES/g" - -source_ext='(c|cc|h|cpp|hpp|m4|w32|ini|frag|cmake|inl|in|py|gnu|yaml|def|pl|S|s|errordata|go|lds|num|asm|mod|peg|mk|rs|toml|sh)' -doc_ext='(md|json|html|dot|graphml|png|gn|sha1|css|rst|)' - -special_docs='(LICENSE*|NOTICE|changelog.txt|CHANGELOG|THIRD-PARTY|README*|readme|METADATA|CONTRIBUTORS|UPDATING|doc.config|THIRD-PARTY-LICENSES.txt)' -special_tests='(ci-test.sh|format-check.sh|run_tests*|sanitizer-blacklist.txt|run-clang-tidy.sh|benchmark-build-run.sh|break-tests.sh|generate-coverage.sh|test.xml)' -special_src='(gen_api.php|gen_stub.php|CMakeLists.txt|post.sh|postun.sh|Makefile*|build-buildspec.sh|build-deps.sh|objects.txt|go.*|BUILD*|DEPS|install_and_run.sh|codemod.sh|requirements.txt)' -skip_files='(package.xml*|prepare_release.sh|codereview.settings|*.o|*.a|*.obj|*.lib|break-tests-android.sh|whitespace.txt|prepare_package_xml.sh|crypto_test_data.cc|*.pdf|*.svg|*.docx|cbmc-proof.txt|codecov*|litani*|*.toml|module.modulemap|cleanup.sh)' - -special_scripts='(awscrt.stub.php)' - -skip_directories='(tests|test|AWSCRTAndroidTestRunner|docker-images|codebuild|fuzz|third_party|docs|generated-src|aws-lc|aws-crt-sys|ecdsa-fuzz-corpus|bin|examples|compliance|verification)' - -process_file() { - if (( $# == 0 )) - then - echo "ERROR: filename not passed" - exit 1 - fi - if [[ $1 = $~skip_files ]] - then - # This file is not part of the release bundle - return 0 - fi - - echo -n '' - return 0 -} - - -process_dir() { - if (( $# == 0 )) - then - echo "WARNING: dirname not passed" - exit 1 - fi - if [[ "${1}" = $~skip_directories ]] - then - return 0 - fi - echo '' - cd "$1" - for a in * - do - if [[ -f ${a} ]] - then process_file "${a}" - else process_dir "${a}" - fi - done - # Special cases for compiler features placed in tests directories in and s2n - if [[ "${1}" = "s2n" && -d tests ]] - then - echo '' - echo '' - cd tests/features - for a in * - do - process_file "${a}" - done - cd ../.. - echo '' - echo '' - fi - echo '' - cd .. - return 0 -} - -echo '' -for a in * -do - if [[ ${a} == 'tests' ]] - then - echo '' - for b in tests/* - do - echo '' - done - echo '' - continue - fi - # skip the src directory as it is not part of the native extension - if [[ ${a} == 'src' ]] - then - continue - fi - - if [[ -f ${a} ]] - then process_file "${a}" - else process_dir "${a}" - fi -done -echo '' - -cat $TOOLS_DIR/package.xml-template_post diff --git a/dev-scripts/prepare_pecl_package_xml.py b/dev-scripts/prepare_pecl_package_xml.py new file mode 100644 index 0000000..f5e3c37 --- /dev/null +++ b/dev-scripts/prepare_pecl_package_xml.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +import argparse +import os +import re +from datetime import datetime + +parser = argparse.ArgumentParser( + description="Generate package.xml file for a release bundle.") +parser.add_argument("--name", help="Name of the package", required=True) +parser.add_argument( + "--user", help="Username of the package maintainer", required=True) +parser.add_argument( + "--email", help="Email address of the package maintainer", default='aws-sdk-common-runtime@amazon.com') +parser.add_argument( + "--version", help="Version number of the package", required=True) +parser.add_argument( + "--notes", help="Release notes for the package", default='New release') +args = parser.parse_args() + + +name = args.name +user = args.user +email = args.email +version = args.version +notes = args.notes + + +tools_dir = os.path.dirname(os.path.abspath(__file__)) +work_dir = os.path.join(tools_dir, '..') + +os.chdir(work_dir) + +today = datetime.utcnow().strftime("%Y-%m-%d") + +source_ext = "(c|cc|h|cpp|hpp|m4|w32|ini|frag|cmake|inl|in|py|gnu|yaml|def|pl|S|s|errordata|go|lds|num|asm|mod|peg|mk|rs|toml|sh)" +doc_ext = "(md|json|html|dot|graphml|png|gn|sha1|css|rst)" + +special_docs = "(LICENSE.*|NOTICE|changelog.txt|CHANGELOG|THIRD-PARTY|README.*|readme|METADATA|CONTRIBUTORS|UPDATING|doc.config|THIRD-PARTY-LICENSES.txt)" +special_tests = "(ci-test.sh|format-check.sh|run_tests.*|sanitizer-blacklist.txt|run-clang-tidy.sh|benchmark-build-run.sh|break-tests.sh|generate-coverage.sh|test.xml)" +special_src = "(gen_api.php|gen_stub.php|CMakeLists.txt|post.sh|postun.sh|Makefile.*|build-buildspec.sh|build-deps.sh|objects.txt|go.*|BUILD.*|DEPS|install_and_run.sh|codemod.sh|requirements.txt)" +skip_files = "(package.xml.*|prepare_release.sh|codereview.settings|.*\\.o|.*\\.a|.*\\.obj|.*\\.lib|break-tests-android.sh|whitespace.txt|prepare_package_xml.sh|crypto_test_data.cc|.*\\.pdf|.*\\.svg|.*\\.docx|cbmc-proof.txt|codecov.*|litani.*|.*\\.toml|module\\.modulemap|cleanup.sh|^\..*)" + + +special_scripts = "(awscrt.stub.php)" + +skip_directories = "(tests|test|AWSCRTAndroidTestRunner|docker-images|codebuild|fuzz|third_party|docs|generated-src|aws-lc|aws-crt-sys|ecdsa-fuzz-corpus|bin|examples|compliance|verification|^\..*)" + +output_file_name = os.path.join(work_dir, 'package.xml') + + +def process_file(file_name, f): + if re.match(skip_files, file_name): + # This file is not part of the release bundle + return + f.write(f'\n') + + +def process_dir(dir_name, f): + if re.match(skip_directories, dir_name): + return + + f.write(f'\n') + + if dir_name == 'tests' and os.path.isdir('tests'): + f.write('\n') + f.write('\n') + os.chdir('tests/features') + for file_name in os.listdir(): + process_file(file_name) + os.chdir('../..') + f.write('\n') + f.write('\n') + + else: + os.chdir(dir_name) + for file_name in os.listdir(): + if os.path.isfile(file_name): + process_file(file_name, f) + else: + process_dir(file_name, f) + + f.write('\n') + os.chdir('..') + + +# Main code +with open(os.path.join(tools_dir, "package.xml-template_pre"), 'r') as f: + template_pre = f.read() + +template_pre = re.sub(r"{{{NAME}}}", name, template_pre) +template_pre = re.sub(r"{{{USER}}}", user, template_pre) +template_pre = re.sub(r"{{{EMAIL}}}", email, template_pre) +template_pre = re.sub(r"{{{TODAY}}}", today, template_pre) +template_pre = re.sub(r"{{{VERSION}}}", version, template_pre) +template_pre = re.sub(r"{{{NOTES}}}", notes, template_pre) + +with open(output_file_name, "w") as f: + f.write(template_pre) + f.write('\n') + +with open(output_file_name, "a") as f: + for file_name in os.listdir(): + if file_name == 'tests': + f.write('\n') + for test_file in os.listdir('tests'): + f.write( + f'\n') + f.write('\n') + continue + + if file_name == 'src': + # skip the src directory as it is not part of the native extension + continue + + if os.path.isfile(file_name): + process_file(file_name, f) + else: + process_dir(file_name, f) + +with open(output_file_name, "a") as f: + f.write('\n') + with open(os.path.join(tools_dir, "package.xml-template_post"), 'r') as template: + f.write(template.read()) diff --git a/dev-scripts/prepare_pecl_release.py b/dev-scripts/prepare_pecl_release.py new file mode 100644 index 0000000..1bbfc5e --- /dev/null +++ b/dev-scripts/prepare_pecl_release.py @@ -0,0 +1,47 @@ +import argparse +import os +import subprocess + + +parser = argparse.ArgumentParser(description='PECL Package generator') +parser.add_argument("--name", help="Name of the package", required=True) +parser.add_argument( + "--user", help="Username of the package maintainer", required=True) +parser.add_argument( + "--email", help="Email address of the package maintainer", default='aws-sdk-common-runtime@amazon.com') +parser.add_argument( + "--version", help="Version number of the package", required=True) +parser.add_argument( + "--notes", help="Release notes for the package", default='New release') +args = parser.parse_args() + +PACKAGE = 'awscrt' +NAME = args.name +USER = args.user +EMAIL = args.email +VERSION = args.version +NOTES = args.notes + +TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) +WORK_DIR = os.path.join(TOOLS_DIR, '..') + +subprocess.run(['python3', f'{TOOLS_DIR}/cleanup_build.py'], check=True) + +os.chdir(WORK_DIR) + +subprocess.run(['git', 'submodule', 'update', + '--init', '--recursive'], check=True) + +subprocess.run(['python3', f'{TOOLS_DIR}/prepare_pecl_package_xml.py', '--name', NAME, '--user', USER, + '--email', EMAIL, '--version', VERSION, '--notes', NOTES], check=True) +try: + with open('package.xml', 'r') as f: + package_xml = f.read() + subprocess.run(['tidy', '-xml', '-m', '-i', 'package.xml'], check=True) + subprocess.run(['pear', 'package-validate'], check=True) + subprocess.run(['pear', 'package'], check=True) +except subprocess.CalledProcessError as e: + print(f'ERROR PROCESSING review package.xml: {e}') + exit(1) + +print(f'Size of {PACKAGE}-{VERSION}.tgz: {os.path.getsize(f"{PACKAGE}-{VERSION}.tgz") / 1024 / 1024:.2f} MB') diff --git a/dev-scripts/prepare_release.sh b/dev-scripts/prepare_release.sh deleted file mode 100755 index 0cf237d..0000000 --- a/dev-scripts/prepare_release.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/zsh -zparseopts -A opts -name: -user: -email: -version: -notes: -if [[ $# -lt 10 ]]; then - echo "Usage ${0} --name NAME --user USER --email EMAIL --version VERSION --notes NOTES" - exit 1 -fi -PACKAGE='awscrt' -NAME="${opts[--name]}" -USER="${opts[--user]}" -EMAIL="${opts[--email]}" -VERSION="${opts[--version]}" -NOTES="${opts[--notes]}" - - -BASENAME=${0} -TOOLS_DIR=$(dirname ${BASENAME}) -WORK_DIR="${TOOLS_DIR}/.." - -cd "${WORK_DIR}" - -git submodule update --init --recursive - -$TOOLS_DIR/cleanup.sh -$TOOLS_DIR/prepare_package_xml.sh --name "${NAME}" --user "${USER}" --email "${EMAIL}" --version "${VERSION}" --notes "${NOTES}" >package.xml -if [[ $? -ne 0 ]]; then - echo "ERROR PROCESSING review package.xml" - exit 1 -fi -tidy -xml -m -i package.xml -pear package-validate -if [[ $? -ne 0 ]]; then - echo "ERROR VALIDATING review package.xml" - exit 1 -fi -pear package -if [[ $? -ne 0 ]]; then - echo "ERROR PROCESSING review package.xml" - exit 1 -fi - -echo "Size of ${PACKAGE}-${VERSION}.tgz: " $(du -h "${PACKAGE}-${VERSION}.tgz") diff --git a/dev-scripts/run_tests.bat b/dev-scripts/run_tests.bat index e92f1cb..28e152f 100644 --- a/dev-scripts/run_tests.bat +++ b/dev-scripts/run_tests.bat @@ -1,9 +1,6 @@ @echo on setlocal -REM Run command to get composer_dir -set "composer_dir=" -for /f "usebackq delims=" %%i in (`where composer.phar`) do set "composer_dir=%%i" set "PHP_BINARY=php" @@ -11,18 +8,25 @@ if not "%~1"=="" ( set "PHP_BINARY=%~1" ) -REM Check if composer_dir was found -if "%composer_dir%"=="" ( - echo No composer found. - exit /b 1 -) - set "script_dir=%~dp0" set "work_dir=%script_dir%/.." cd %work_dir% +set vendor_path=vendor + +if not exist "%vendor_path%" ( + REM Run command to get composer_dir + set "composer_dir=" + for /f "usebackq delims=" %%i in (`where composer.phar`) do set "composer_dir=%%i" + + REM Check if composer_dir was found + if "%composer_dir%"=="" ( + echo No composer found. + exit /b 1 + ) +) + call %PHP_BINARY% -c php-win.ini %composer_dir% update call %PHP_BINARY% -c php-win.ini vendor/bin/phpunit tests --debug - -endlocal \ No newline at end of file +endlocal diff --git a/dev-scripts/run_tests b/dev-scripts/run_tests.sh similarity index 100% rename from dev-scripts/run_tests rename to dev-scripts/run_tests.sh diff --git a/dev-scripts/test.py b/dev-scripts/test.py new file mode 100644 index 0000000..09499dd --- /dev/null +++ b/dev-scripts/test.py @@ -0,0 +1,9 @@ +import os + +# get the absolute path of the script file +script_path = os.path.abspath(__file__) + +# get the directory of the script file +script_dir = os.path.dirname(script_path) + +print("Directory of the script file:", script_dir) diff --git a/php-win.ini b/php-win.ini index fb0f704..a1bdb78 100644 --- a/php-win.ini +++ b/php-win.ini @@ -1,3 +1,3 @@ extension=php_awscrt.dll extension=php_openssl.dll -extension=php_mbstring.dll \ No newline at end of file +extension=php_mbstring.dll From 4e15b06c849776a43ed902ef8c36e4c8c25041ca Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Fri, 24 Feb 2023 15:52:07 -0800 Subject: [PATCH 14/14] replace tidy with python --- dev-scripts/prepare_pecl_release.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dev-scripts/prepare_pecl_release.py b/dev-scripts/prepare_pecl_release.py index 1bbfc5e..a510b59 100644 --- a/dev-scripts/prepare_pecl_release.py +++ b/dev-scripts/prepare_pecl_release.py @@ -1,6 +1,7 @@ import argparse import os import subprocess +import xml.dom.minidom parser = argparse.ArgumentParser(description='PECL Package generator') @@ -37,7 +38,11 @@ subprocess.run(['python3', f'{TOOLS_DIR}/prepare_pecl_package_xml.py', '--name', try: with open('package.xml', 'r') as f: package_xml = f.read() - subprocess.run(['tidy', '-xml', '-m', '-i', 'package.xml'], check=True) + doc = xml.dom.minidom.parse('package.xml') + doc.encoding = 'UTF-8' + xml_str = doc.toprettyxml(indent=' ', newl='') + with open('package.xml', 'w') as f: + f.write(xml_str) subprocess.run(['pear', 'package-validate'], check=True) subprocess.run(['pear', 'package'], check=True) except subprocess.CalledProcessError as e: