| # Copyright 2022 The IREE Authors |
| # |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| # See https://llvm.org/LICENSE.txt for license information. |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| # |
| # Workflow for building E2E test artifacts. |
| # It is designed to be called from a parent workflow. |
| # The concurrency of this workflow is controlled by the caller's job. |
| |
| name: Build E2E Test Artifacts |
| |
| on: |
| workflow_call: |
| inputs: |
| runner-group: |
| required: true |
| type: string |
| runner-env: |
| required: true |
| type: string |
| build-dir: |
| required: true |
| type: string |
| build-dir-archive: |
| required: true |
| type: string |
| build-dir-gcs-artifact: |
| required: true |
| type: string |
| benchmark-presets: |
| required: true |
| type: string |
| outputs: |
| e2e-test-artifacts-dir: |
| description: | |
| Local path that stores compiled test artifacts. |
| value: ${{ jobs.build_e2e_test_artifacts.outputs.e2e-test-artifacts-dir }} |
| e2e-test-artifacts-gcs-artifact-dir: |
| description: | |
| GCS path to the uploaded test artifacts. |
| value: ${{ jobs.build_e2e_test_artifacts.outputs.e2e-test-artifacts-gcs-artifact-dir }} |
| e2e-test-artifacts-build-log: |
| description: | |
| Local path that contains the build log. |
| value: ${{ jobs.build_e2e_test_artifacts.outputs.e2e-test-artifacts-build-log }} |
| e2e-test-artifacts-build-log-gcs-artifact: |
| description: | |
| GCS path to the uploaded build log. |
| value: ${{ jobs.build_e2e_test_artifacts.outputs.e2e-test-artifacts-build-log-gcs-artifact }} |
| |
| env: |
| # This duplicates the variable from ci.yml. The variable needs to be in env |
| # instead of the outputs of setup because it contains the run attempt and we |
| # want that to be the current attempt, not whatever attempt the setup step |
| # last ran in. It therefore can't be passed in via inputs because the env |
| # context isn't available there. |
| GCS_DIR: gs://iree-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts/${{ github.run_id }}/${{ github.run_attempt }} |
| |
| jobs: |
| build_e2e_test_artifacts: |
| runs-on: |
| - self-hosted # must come first |
| - runner-group=${{ inputs.runner-group }} |
| - environment=${{ inputs.runner-env }} |
| - cpu |
| - os-family=Linux |
| env: |
| HOST_BUILD_DIR: ${{ inputs.build-dir }} |
| HOST_BUILD_DIR_ARCHIVE: ${{ inputs.build-dir-archive }} |
| HOST_BUILD_DIR_GCS_ARTIFACT: ${{ inputs.build-dir-gcs-artifact }} |
| outputs: |
| e2e-test-artifacts-dir: ${{ steps.build.outputs.e2e-test-artifacts-dir }} |
| e2e-test-artifacts-gcs-artifact-dir: ${{ steps.upload.outputs.e2e-test-artifacts-gcs-artifact-dir }} |
| e2e-test-artifacts-build-log: ${{ steps.build.outputs.e2e-test-artifacts-build-log }} |
| e2e-test-artifacts-build-log-gcs-artifact: ${{ steps.upload.outputs.e2e-test-artifacts-build-log-gcs-artifact }} |
| steps: |
| - name: "Checking out repository" |
| uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 |
| - name: "Checking out runtime submodules" |
| run: ./build_tools/scripts/git/update_runtime_submodules.sh |
| - name: "Downloading build dir archive" |
| run: gcloud storage cp "${HOST_BUILD_DIR_GCS_ARTIFACT}" "${HOST_BUILD_DIR_ARCHIVE}" |
| - name: "Extracting install from build dir archive" |
| run: tar -xf "${HOST_BUILD_DIR_ARCHIVE}" "${HOST_BUILD_DIR}/install" |
| - name: "Building e2e test artifacts" |
| id: build |
| env: |
| BUILD_E2E_TEST_ARTIFACTS_DIR: build-e2e-test-artifacts |
| run: | |
| build_tools/github_actions/docker_run.sh \ |
| --env "IREE_HOST_BIN_DIR=${HOST_BUILD_DIR}/install/bin" \ |
| gcr.io/iree-oss/frontends@sha256:c123d9e54e5179ef49345271e5535bcd618ce8d5f20c1353741b81715c3bee33 \ |
| build_tools/cmake/build_e2e_test_artifacts.sh \ |
| "${BUILD_E2E_TEST_ARTIFACTS_DIR}" |
| echo "e2e-test-artifacts-dir=${BUILD_E2E_TEST_ARTIFACTS_DIR}/e2e_test_artifacts" >> "${GITHUB_OUTPUT}" |
| echo "e2e-test-artifacts-build-log=${BUILD_E2E_TEST_ARTIFACTS_DIR}/.ninja_log" >> "${GITHUB_OUTPUT}" |
| - name: "Exporting benchmark configs" |
| id: export |
| if: inputs.benchmark-presets != '' |
| env: |
| COMPILATION_BENCHMARK_CONFIG: ${{ steps.build.outputs.e2e-test-artifacts-dir }}/compilation-benchmark-config.json |
| EXECUTION_BENCHMARK_CONFIG: ${{ steps.build.outputs.e2e-test-artifacts-dir }}/execution-benchmark-config.json |
| BENCHMARK_FLAG_DUMP: ${{ steps.build.outputs.e2e-test-artifacts-dir }}/benchmark-flag-dump.txt |
| BENCHMARK_PRESETS: ${{ inputs.benchmark-presets }} |
| run: | |
| ./build_tools/benchmarks/export_benchmark_config.py \ |
| compilation \ |
| --output="${COMPILATION_BENCHMARK_CONFIG}" |
| ./build_tools/benchmarks/export_benchmark_config.py \ |
| execution \ |
| --benchmark_presets="${BENCHMARK_PRESETS}" \ |
| --output="${EXECUTION_BENCHMARK_CONFIG}" |
| ./build_tools/benchmarks/benchmark_helper.py dump-cmds \ |
| --execution_benchmark_config="${EXECUTION_BENCHMARK_CONFIG}" \ |
| --compilation_benchmark_config="${COMPILATION_BENCHMARK_CONFIG}" \ |
| > "${BENCHMARK_FLAG_DUMP}" |
| echo "benchmark-flag-dump=${BENCHMARK_FLAG_DUMP}" >> "${GITHUB_OUTPUT}" |
| - name: "Uploading e2e test artifacts" |
| id: upload |
| env: |
| E2E_TEST_ARTIFACTS_DIR: ${{ steps.build.outputs.e2e-test-artifacts-dir }} |
| E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR: ${{ env.GCS_DIR }}/e2e-test-artifacts |
| E2E_TEST_ARTIFACTS_BUILD_LOG: ${{ steps.build.outputs.e2e-test-artifacts-build-log }} |
| E2E_TEST_ARTIFACTS_BUILD_LOG_GCS_ARTIFACT: ${{ env.GCS_DIR }}/e2e-test-artifacts/ninja_log |
| BENCHMARK_FLAG_DUMP: ${{ steps.export.outputs.benchmark-flag-dump }} |
| run: | |
| # Uploads all IREE artifacts and MLIR files (including the imported |
| # MLIR files and MLIR source models). |
| # Not archiving the directory to allow fetching each file as needed |
| # separately. |
| find "${E2E_TEST_ARTIFACTS_DIR}" -maxdepth 1 \ |
| -name "iree_*" -o -name "model_*.mlir" -o -name "model_*.mlirbc" -o -name "*.json" | \ |
| gcloud storage cp --read-paths-from-stdin -r \ |
| "${E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR}" |
| gcloud storage cp "${BENCHMARK_FLAG_DUMP}" \ |
| "${E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR}" |
| gcloud storage cp "${E2E_TEST_ARTIFACTS_BUILD_LOG}" \ |
| "${E2E_TEST_ARTIFACTS_BUILD_LOG_GCS_ARTIFACT}" |
| echo "e2e-test-artifacts-gcs-artifact-dir=${E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR}" >> "${GITHUB_OUTPUT}" |
| echo "e2e-test-artifacts-build-log-gcs-artifact=${E2E_TEST_ARTIFACTS_BUILD_LOG_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}" |