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_build.py b/dev-scripts/cleanup_build.py
index 6df535c..41cafaf 100644
--- a/dev-scripts/cleanup_build.py
+++ b/dev-scripts/cleanup_build.py
@@ -5,55 +5,36 @@ import shutil
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
WORK_DIR = os.path.join(TOOLS_DIR, '..')
-# Remove specified directories
-DIRS_TO_REMOVE = [
- '.deps',
- '.libs',
- 'build',
- 'include',
- 'modules',
- 'vendor',
- 'autom4te.cache']
-# Remove specified files
-FILES_TO_REMOVE = [
- 'Makefile',
- 'Makefile.fragments',
- 'Makefile.global',
- 'Makefile.objects',
- 'config.guess',
- 'config.h',
- 'config.h.in',
- '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',
- '**/*.lo',
- '**/*.o',
- '**/*.la',
- '**/*.a',
- '*.tgz']
+def remove_files(files):
+ for file in files:
+ if os.path.exists(file):
+ os.remove(file)
+
os.chdir(WORK_DIR)
-
-for directory in DIRS_TO_REMOVE:
+# Remove specified directories
+dirs_to_remove = ['.deps', '.libs', 'build', 'include', 'modules', 'vendor']
+for directory in dirs_to_remove:
shutil.rmtree(directory, ignore_errors=True)
-for pattern in FILES_TO_REMOVE:
- for filepath in glob.glob(pattern):
- os.remove(filepath)
+# 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_pecl_package_xml.py b/dev-scripts/prepare_pecl_package_xml.py
index 3acbf58..f5e3c37 100644
--- a/dev-scripts/prepare_pecl_package_xml.py
+++ b/dev-scripts/prepare_pecl_package_xml.py
@@ -84,25 +84,26 @@ def process_dir(dir_name, f):
return
f.write(f'
\n')
- 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)
- # Special cases for compiler features placed in tests directories in and s2n
- if dir_name == 's2n' and os.path.isdir('tests'):
- f.write('')
- f.write('')
+ if dir_name == 'tests' and os.path.isdir('tests'):
+ f.write('\n')
+ f.write('\n')
os.chdir('tests/features')
- for a in os.listdir():
- process_file(a, f)
+ for file_name in os.listdir():
+ process_file(file_name)
os.chdir('../..')
- f.write('')
- f.write('')
+ f.write('\n')
+ f.write('\n')
- f.write('')
+ 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('..')
diff --git a/dev-scripts/prepare_pecl_release.py b/dev-scripts/prepare_pecl_release.py
index fd4874b..1bbfc5e 100644
--- a/dev-scripts/prepare_pecl_release.py
+++ b/dev-scripts/prepare_pecl_release.py
@@ -1,8 +1,6 @@
import argparse
import os
import subprocess
-import xml.dom.minidom
-import sys
parser = argparse.ArgumentParser(description='PECL Package generator')
@@ -27,32 +25,23 @@ NOTES = args.notes
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
WORK_DIR = os.path.join(TOOLS_DIR, '..')
-
-def run(args):
- print(f"$ {subprocess.list2cmdline(args)}")
- subprocess.check_call(args)
-
-
-run(['python3', f'{TOOLS_DIR}/cleanup_build.py'])
+subprocess.run(['python3', f'{TOOLS_DIR}/cleanup_build.py'], check=True)
os.chdir(WORK_DIR)
-run(['git', 'submodule', 'update', '--init', '--recursive'])
+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:
- run(['python3', f'{TOOLS_DIR}/prepare_pecl_package_xml.py', '--name', NAME, '--user', USER,
- '--email', EMAIL, '--version', VERSION, '--notes', NOTES])
+ 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:
- sys.exit(f'ERROR PROCESSING review package.xml: {e}')
-
-with open('package.xml', 'r') as f:
- package_xml = f.read()
-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)
-run(['pear', 'package-validate'])
-run(['pear', 'package'])
+ 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/run_tests.bat b/dev-scripts/run_tests.bat
index 2eb0136..28e152f 100644
--- a/dev-scripts/run_tests.bat
+++ b/dev-scripts/run_tests.bat
@@ -12,6 +12,20 @@ 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
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)