From 12db7aa9427c1eb481cf0a3d0f30a7db43711b18 Mon Sep 17 00:00:00 2001 From: Vijai Kumar S Date: Tue, 9 Jul 2024 09:49:39 +0530 Subject: [PATCH] Introduce some more generics in actions (Integration test suite url is not hard coded anymore) --- .github/workflows/build.yml | 20 ++++++++++++++++---- CI/ci_cd_helper.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29b2c263b..45a9120d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -540,6 +540,18 @@ jobs: else echo "run_integration_tests=false" >> $GITHUB_OUTPUT fi + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + - name: Fetch the latest integration SDK url + run: | + echo "LATEST_INTEGRATION_TEST_SDK_URL=$(python CI/ci_cd_helper.py fetch-integration-test-sdk-url 0 | xargs)" >> $GITHUB_ENV + integration-tests-latest-release: runs-on: ubuntu-20.04 @@ -584,7 +596,7 @@ jobs: - name: Download and unzip test suite run: | - wget https://github.com/3MFConsortium/test_suites/releases/download/v2.0.0/3MF_Conformance_Test_Suites_v2.0.0.zip + wget ${{ env.LATEST_INTEGRATION_TEST_SDK_URL }} unzip 3MF_Conformance_Test_Suites_v2.0.0.zip -d test_suites - name: List files @@ -664,7 +676,7 @@ jobs: - name: Download and unzip test suite run: | - wget https://github.com/3MFConsortium/test_suites/releases/download/v2.0.0/3MF_Conformance_Test_Suites_v2.0.0.zip + wget ${{ env.LATEST_INTEGRATION_TEST_SDK_URL }} unzip 3MF_Conformance_Test_Suites_v2.0.0.zip -d test_suites - name: Copy integration test script @@ -781,7 +793,7 @@ jobs: - name: Download and unzip test suite run: | - wget https://github.com/3MFConsortium/test_suites/releases/download/v2.0.0/3MF_Conformance_Test_Suites_v2.0.0.zip + wget ${{ env.LATEST_INTEGRATION_TEST_SDK_URL }} unzip 3MF_Conformance_Test_Suites_v2.0.0.zip -d test_suites - name: Copy integration test script @@ -851,7 +863,7 @@ jobs: - name: Download and unzip test suite run: | - wget https://github.com/3MFConsortium/test_suites/releases/download/v2.0.0/3MF_Conformance_Test_Suites_v2.0.0.zip + wget ${{ env.LATEST_INTEGRATION_TEST_SDK_URL }} unzip 3MF_Conformance_Test_Suites_v2.0.0.zip -d test_suites - name: Copy integration test script diff --git a/CI/ci_cd_helper.py b/CI/ci_cd_helper.py index 01b218bf5..675880103 100644 --- a/CI/ci_cd_helper.py +++ b/CI/ci_cd_helper.py @@ -27,6 +27,24 @@ def extract_version_from_cmake(): return version +def get_integration_sdk_url(index): + url = "https://api.github.com/repos/3MFConsortium/test_suites/releases" + + try: + with urllib.request.urlopen(url) as response: + data = response.read().decode('utf-8') + + releases = json.loads(data) + selected_release = releases[index] # Select the release by index + for asset in selected_release['assets']: + asset_name = str(asset['name']) + if asset_name.startswith("3MF_Conformance_Test_Suites") and asset_name.endswith(".zip"): + return asset['browser_download_url'] + return None + except Exception as e: + print(f"Error fetching the SDK URL: {e}") + return None + def get_sdk_url(index): url = "https://api.github.com/repos/3MFConsortium/lib3mf/releases" @@ -50,6 +68,10 @@ def main(): subparsers = parser.add_subparsers(dest='command') + # Subparser for the fetch-integration-test-sdk-url command + parser_fetch_sdk_url = subparsers.add_parser('fetch-integration-test-sdk-url', help='Fetch the SDK URL for a specific integration test release index.') + parser_fetch_sdk_url.add_argument('index', type=int, help='Index of the release (0 for latest, 1 for second latest, etc.)') + # Subparser for the fetch-sdk-url command parser_fetch_sdk_url = subparsers.add_parser('fetch-sdk-url', help='Fetch the SDK URL for a specific release index.') parser_fetch_sdk_url.add_argument('index', type=int, help='Index of the release (0 for latest, 1 for second latest, etc.)') @@ -65,6 +87,12 @@ def main(): print(url) else: print("FAIL") + elif args.command == 'fetch-integration-test-sdk-url': + url = get_integration_sdk_url(args.index) + if url: + print(url) + else: + print("FAIL") elif args.command == 'extract-version': try: version = extract_version_from_cmake()