Skip to content

Commit

Permalink
Introduce some more generics in actions (Integration test suite url i…
Browse files Browse the repository at this point in the history
…s not hard coded anymore)
  • Loading branch information
vijaiaeroastro committed Jul 9, 2024
1 parent 1ea936f commit 12db7aa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions CI/ci_cd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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.)')
Expand All @@ -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()
Expand Down

0 comments on commit 12db7aa

Please sign in to comment.