GCP Image Test #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: GCP cloud-image-tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_major: | |
| description: 'AlmaLinux major version' | |
| required: true | |
| default: '10' | |
| type: choice | |
| options: | |
| - 10-kitten | |
| - 10 | |
| - 9 | |
| - 8 | |
| arch: | |
| description: 'Architecture to test' | |
| required: true | |
| default: 'ALL' | |
| type: choice | |
| options: | |
| - ALL | |
| - x86_64 | |
| - aarch64 | |
| image_override: | |
| description: 'Image to test, overrides version_major to test a direct image instead. Architecture must be set properly for the image being passed. This must be a full path to a GCP image, for example, projects/almalinux-dev-images-469421/global/images/almalinux-9-v20230920' | |
| required: false | |
| default: '' | |
| # notify_mattermost: | |
| # description: "Send notification to Mattermost" | |
| # required: true | |
| # type: boolean | |
| # default: false | |
| jobs: | |
| init-data: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_path: ${{ steps.determine_image.outputs.image_path }} | |
| steps: | |
| - name: Determine image to test | |
| id: determine_image | |
| run: | | |
| if [ -n "${{ inputs.image_override }}" ]; then | |
| echo "Using image override: ${{ inputs.image_override }}" | |
| image_path="${{ inputs.image_override }}" | |
| elif [ "${{ inputs.arch == 'ALL' }}" ]; then | |
| echo "Using version major: ${{ inputs.version_major }}" | |
| echo "Using all architectures" | |
| image_path="projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ inputs.version_major }}" | |
| else | |
| echo "Using version major: ${{ inputs.version_major }}" | |
| echo "Using arch: ${{ inputs.arch }}" | |
| image_path="projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ inputs.version_major }}" | |
| fi | |
| echo "Determined image path: ${image_path}" | |
| echo "image_path=${image_path}" >> $GITHUB_OUTPUT | |
| - name: Generate Randomized Matrix | |
| id: randomized-shape-matrix | |
| shell: python | |
| env: | |
| FAMILY_SPACING: 3 | |
| run: | | |
| # The original shape list remains the same | |
| shapes = [ | |
| 'n4-standard-2', 'n4-standard-80', 'n2-standard-2', 'n2-standard-128', | |
| 'n2d-standard-2', 'n2d-standard-224', 'n1-standard-1', 'n1-standard-96', | |
| 'c4-standard-2', 'c4-standard-288', 'c4-standard-288-metal', | |
| 'c4-standard-4-lssd', 'c4-standard-288-lssd', 'c4d-standard-2', | |
| 'c4d-standard-384', 'c4d-standard-384-metal', 'c4d-standard-8-lssd', | |
| 'c4d-standard-384-lssd', 'c3-standard-4', 'c3-standard-176', | |
| 'c3-standard-192-metal', 'c3-standard-4-lssd', 'c3-standard-176-lssd', | |
| 'c3d-standard-4', 'c3d-standard-360', 'c3d-standard-8-lssd', | |
| 'c3d-standard-360-lssd', 'e2-standard-2', 'e2-standard-32', | |
| 'e2-medium', 't2d-standard-1', 't2d-standard-60' | |
| ] | |
| # --- | |
| # Python script with configurable spacing | |
| # --- | |
| import random | |
| from collections import defaultdict | |
| import os | |
| import json | |
| # Get the spacing value from the environment variable | |
| family_spacing = int(os.environ.get('FAMILY_SPACING', 2)) | |
| family_groups = defaultdict(list) | |
| for shape in shapes: | |
| family = shape.split('-')[0] | |
| family_groups[family].append(shape) | |
| for family in family_groups: | |
| random.shuffle(family_groups[family]) | |
| final_list = [] | |
| last_families_used = [] | |
| # Continue picking from families until all shapes are used | |
| while any(family_groups.values()): | |
| eligible_families = [ | |
| f for f in family_groups.keys() | |
| if family_groups[f] and f not in last_families_used | |
| ] | |
| if not eligible_families: | |
| # This happens if all remaining families are in last_families_used, | |
| # meaning we have to break the separation rule to finish. | |
| # We'll just pick from any remaining family. | |
| eligible_families = [f for f in family_groups.keys() if family_groups[f]] | |
| # Choose a family to pick from | |
| chosen_family = random.choice(eligible_families) | |
| # Append the first shape from the chosen family | |
| final_list.append(family_groups[chosen_family].pop(0)) | |
| # Update the list of recently used families | |
| last_families_used.append(chosen_family) | |
| if len(last_families_used) > family_spacing: | |
| last_families_used.pop(0) | |
| matrix_json = json.dumps([{"shape": s} for s in final_list]) | |
| with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | |
| f.write(f'matrix={matrix_json}\n') | |
| - name: Display Generated Matrix | |
| run: | | |
| echo "Generated shape matrix: ${{ steps.randomized-shape-matrix.outputs.matrix }}" | |
| # this initial test does the generic suite of tests not assigned to any specific shape - letting the test system | |
| # choose its own shapes and sizes. This is run first to catch any major issues before running the per-shape tests | |
| # which take a long time and use a lot of resources. Think of this as a smoke test to catch major issues early. | |
| test-gcp-initialtest: | |
| name: AlmaLinux ${{ inputs.image_override || format('{0} {1}', inputs.version_major, matrix.arch) }} Generic Full Run | |
| needs: init-data | |
| permissions: | |
| id-token: write | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # this sets the arch matrix based on the input | |
| # if input is ALL, then set to both x86_64 and aarch64 | |
| # otherwise set to the selected arch | |
| arch: ${{ fromJSON(inputs.arch == 'ALL' && '["x86_64","aarch64"]' || format('["{0}"]', inputs.arch)) }} | |
| steps: | |
| # we don't need the checked out files, but this is required for the google auth action to work | |
| - uses: 'actions/checkout@v5' | |
| - id: 'google-auth-image-testing' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| workload_identity_provider: 'projects/527193872801/locations/global/workloadIdentityPools/github-actions/providers/github' | |
| service_account: 'github-actions-image-testing@almalinux-image-testing-469421.iam.gserviceaccount.com' | |
| - name: 'Set up Google Cloud SDK' | |
| uses: 'google-github-actions/setup-gcloud@v3.0.0' | |
| - name: 'Run Google cloud-image-testing tests which are hard-coded to specific shapes' | |
| shell: bash | |
| run: | | |
| docker run \ | |
| -v ${{ env.GOOGLE_GHA_CREDS_PATH }}:/creds/auth.json \ | |
| -e GOOGLE_APPLICATION_CREDENTIALS=/creds/auth.json \ | |
| gcr.io/compute-image-tools/cloud-image-tests:latest \ | |
| -project almalinux-image-testing-469421 \ | |
| -parallel_stagger 10s \ | |
| -parallel_count 20 \ | |
| -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|packagevalidation|ssh|metadata|disk|lssd|vmspec)$' \ | |
| -images '${{ needs.init-data.outputs.image_path }}${{ inputs.image_override == '' && matrix.arch == 'aarch64' && '-arm64' || ''}}' | |
| test-gcp-pershape-x86_64: | |
| name: AlmaLinux ${{ inputs.image_override || format('{0}', inputs.version_major) }} x86_64 ${{ matrix.shape }} | |
| needs: [init-data, test-gcp-initialtest] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| if: inputs.arch == 'ALL' || inputs.arch == 'x86_64' | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 2 | |
| matrix: | |
| shape: ${{ fromJson(needs.randomized-shape-matrix.outputs.matrix) }} | |
| steps: | |
| # we don't need the checked out files, but this is required for the google auth action to work | |
| - uses: 'actions/checkout@v5' | |
| - id: 'google-auth-image-testing' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| workload_identity_provider: 'projects/527193872801/locations/global/workloadIdentityPools/github-actions/providers/github' | |
| service_account: 'github-actions-image-testing@almalinux-image-testing-469421.iam.gserviceaccount.com' | |
| - name: 'Set up Google Cloud SDK' | |
| uses: 'google-github-actions/setup-gcloud@v3.0.0' | |
| - name: 'Run Google cloud-image-testing tests on ${{ matrix.shape }}' | |
| shell: bash | |
| run: | | |
| docker run \ | |
| -v ${{ env.GOOGLE_GHA_CREDS_PATH }}:/creds/auth.json \ | |
| -e GOOGLE_APPLICATION_CREDENTIALS=/creds/auth.json \ | |
| gcr.io/compute-image-tools/cloud-image-tests:latest \ | |
| -project almalinux-image-testing-469421 \ | |
| -parallel_stagger 10s \ | |
| -parallel_count 20 \ | |
| -x86_shape ${{ matrix.shape }} \ | |
| -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|packagevalidation|ssh|metadata)$' \ | |
| -images '${{ needs.init-data.outputs.image_path || inputs.image_override }}${{ inputs.image_override == '' && matrix.arch == 'aarch64' && '-arm64' || ''}}' | |
| test-gcp-pershape-aarch64: | |
| name: AlmaLinux ${{ inputs.image_override || format('{0}', inputs.version_major) }} aarch64 ${{ matrix.shape }} | |
| needs: [init-data, test-gcp-initialtest] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| if: inputs.arch == 'ALL' || inputs.arch == 'aarch64' | |
| strategy: | |
| fail-fast: false | |
| # the arm sizes are smaller so we can do more concurrently | |
| max-parallel: 3 | |
| matrix: | |
| shape: | |
| - c4a-standard-1 | |
| - c4a-standard-72 | |
| - c4a-standard-4-lssd | |
| - c4a-standard-72-lssd | |
| - t2a-standard-1 | |
| - t2a-standard-48 | |
| steps: | |
| # we don't need the checked out files, but this is required for the google auth action to work | |
| - uses: 'actions/checkout@v5' | |
| - id: 'google-auth-image-testing' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| workload_identity_provider: 'projects/527193872801/locations/global/workloadIdentityPools/github-actions/providers/github' | |
| service_account: 'github-actions-image-testing@almalinux-image-testing-469421.iam.gserviceaccount.com' | |
| - name: 'Set up Google Cloud SDK' | |
| uses: 'google-github-actions/setup-gcloud@v3.0.0' | |
| - name: 'Run Google cloud-image-testing tests on ${{ matrix.shape }}' | |
| shell: bash | |
| run: | | |
| docker run \ | |
| -v ${{ env.GOOGLE_GHA_CREDS_PATH }}:/creds/auth.json \ | |
| -e GOOGLE_APPLICATION_CREDENTIALS=/creds/auth.json \ | |
| gcr.io/compute-image-tools/cloud-image-tests:latest \ | |
| -project almalinux-image-testing-469421 \ | |
| -parallel_stagger 10s \ | |
| -parallel_count 20 \ | |
| -arm64_shape ${{ matrix.shape }} \ | |
| -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|packagevalidation|ssh|metadata)$' \ | |
| -images '${{ needs.init-data.outputs.image_path || inputs.image_override }}${{ inputs.image_override == '' && matrix.arch == 'aarch64' && '-arm64' || ''}}' |