Skip to content

[ESI][Runtime] Fix engine teardown oversight #38250

[ESI][Runtime] Fix engine teardown oversight

[ESI][Runtime] Fix engine teardown oversight #38250

Workflow file for this run

name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
# Cancel previous CI builds when a new push occurs to the same PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Do sanity check (clang-format and python-format) first.
sanity-check:
name: Sanity Check
runs-on: ubuntu-latest
container:
image: ghcr.io/circt/images/circt-ci-build:20260107030736
steps:
# Clone the CIRCT repo and its submodules. Do shallow clone to save clone
# time.
- name: Get CIRCT
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 2
submodules: "false"
- name: Set git safe
run: |
git config --global --add safe.directory $PWD
# --------
# Lint the CIRCT C++ code.
# -------
# Choose the git commit to diff against for the purposes of linting.
# Since this workflow is triggered on both pushes and pull requests, we
# have to determine if the pull request target branch is set (which it
# will only be on the PR triggered flow). If it's not, then compare
# against the last commit.
- name: choose-commit
if: ${{ always() }}
env:
# Base ref is the target branch, in text form (not hash)
PR_BASE: ${{ github.base_ref }}
run: |
# Run clang-format
if [ -z "$PR_BASE" ]; then
DIFF_COMMIT_NAME="HEAD^"
else
DIFF_COMMIT_NAME="$PR_BASE"
fi
echo "DIFF_COMMIT_NAME=$DIFF_COMMIT_NAME" >> $GITHUB_ENV
# Since we did a shallow fetch for this repo, we must fetch the commit
# upon which we be diff'ing. The last step set the ref name in the
# $DIFF_COMMIT_NAME environment variable. When running the fetch, resolve
# it to the commit hash and pass that hash along to subsequent steps.
- name: git fetch base commit
continue-on-error: true
run: |
if echo "$DIFF_COMMIT_NAME" | grep -q HEAD; then
DIFF_COMMIT_SHA=$( git rev-parse $DIFF_COMMIT_NAME )
else
git fetch --recurse-submodules=no origin $DIFF_COMMIT_NAME
DIFF_COMMIT_SHA=$( git rev-parse origin/$DIFF_COMMIT_NAME )
fi
echo "DIFF_COMMIT=$DIFF_COMMIT_SHA" >> $GITHUB_ENV
# Run 'git clang-format', comparing against the target commit hash. If
# clang-format fixed anything, fail and output a patch.
- name: clang-format
if: ${{ always() }}
run: |
# Run clang-format
git clang-format $DIFF_COMMIT || true
git diff --ignore-submodules > clang-format.patch
if [ -s clang-format.patch ]; then
echo "Clang-format found formatting problems in the following " \
"files. See diff in the clang-format.patch artifact."
git diff --ignore-submodules --name-only
git checkout .
exit 1
fi
echo "Clang-format found no formatting problems"
exit 0
# Run yapf to check Python formatting.
- name: python-format
if: ${{ always() }}
shell: bash
run: |
files=$(git diff --name-only --diff-filter=d $DIFF_COMMIT | grep -e '\.py$' || echo -n)
if [[ ! -z $files ]]; then
yapf --diff $files
fi
# Check that test files with "REQUIRES: slang" have "// UNSUPPORTED: valgrind"
- name: slang-valgrind-check
if: ${{ always() }}
run: |
python3 utils/find_slang_tests_without_valgrind.py test
python3 utils/find_slang_tests_without_valgrind.py integration_test
# Upload the format patches to an artifact (zip'd) associated
# with the workflow run. Only run this on a failure.
- name: Upload format patches
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: ${{ failure() }}
with:
name: clang-format-patches
path: clang-*.patch
# Unfortunately, artifact uploads are always zips so display the diff as
# well to provide feedback at a glance.
- name: clang format patches display
if: ${{ failure() }}
continue-on-error: true
run: |
# Display patches
if [ ! -z clang-format.patch ]; then
echo "Clang-format patch"
echo "================"
cat clang-format.patch
echo "================"
fi
# --- end of sanity-check job.
# --- end of configure-circt-unified job.
# Choose the build/test matrix.
choose-matrix:
runs-on: ubuntu-latest
steps:
# Clone CIRCT as shallow as possible. We just need the `.github`
# directory.
- name: Get CIRCT (for .github)
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 1
submodules: "false"
- name: Set JSON Matrix
id: get-config
# Use release builds so that these all are cached.
run: |
config=$(cat <<EOF
[
{
"name": "Linux (GCC) Integration",
"install_target": "",
"package_name_prefix": "",
"cmake_build_type": "release",
"llvm_enable_assertions": "ON",
"build_shared_libs": "ON",
"run_tests": true,
"run_integration_tests": true,
"runner": "ubuntu-24.04",
"cmake_c_compiler": "gcc"
},
{
"name": "Linux (Clang) Integration w/ Reverse Iteration",
"install_target": "",
"package_name_prefix": "",
"cmake_build_type": "release",
"llvm_enable_assertions": "OFF",
"build_shared_libs": "OFF",
"run_tests": true,
"run_integration_tests": true,
"runner": "ubuntu-24.04",
"cmake_c_compiler": "clang",
"extra_cmake_args": "-DLLVM_ENABLE_REVERSE_ITERATION=ON"
},
{
"name": "Windows Test",
"install_target": "",
"package_name_prefix": "",
"cmake_build_type": "release",
"llvm_enable_assertions": "ON",
"build_shared_libs": "OFF",
"run_tests": true,
"run_integration_tests": false,
"runner": "windows-2022",
"cmake_c_compiler": "cl"
}
]
EOF
)
echo "Test Matrix:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo "$config" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
compact=$(echo "$config" | jq -c '.')
echo "config=$compact" >> $GITHUB_OUTPUT
outputs:
config: ${{ steps.get-config.outputs.config }}
# Build CIRCT and run its tests.
build-and-test:
name: ${{ matrix.generated.name }}
needs:
- sanity-check
- choose-matrix
if: ${{ needs.choose-matrix.outputs.config != '[]' }}
strategy:
matrix:
generated: ${{ fromJSON(needs.choose-matrix.outputs.config) }}
permissions:
contents: write
actions: write
uses: ./.github/workflows/unifiedBuildTestAndInstall.yml
with:
runner: ${{ matrix.generated.runner }}
cmake_build_type: ${{ matrix.generated.cmake_build_type }}
build_shared_libs: ${{ matrix.generated.build_shared_libs }}
llvm_enable_assertions: ${{ matrix.generated.llvm_enable_assertions }}
run_tests: ${{ matrix.generated.run_tests }}
run_integration_tests: ${{ matrix.generated.run_integration_tests }}
install_target: ${{ matrix.generated.install_target }}
package_name_prefix: ${{ matrix.generated.package_name_prefix }}
cmake_c_compiler: ${{ matrix.generated.cmake_c_compiler }}
extra_cmake_args: ${{ matrix.generated.extra_cmake_args }}
# --- end of build-circt job.
# Upload metadata about the triggering event so the companion
# `dispatchCirctTests.yml` workflow can pick it up. That workflow runs on
# `workflow_run`, which executes in the context of this repository and
# therefore has access to `CIRCT_TESTS_DISPATCH_TOKEN` even for PRs opened
# from forks (regular `pull_request` runs from forks do not).
#
# We deliberately do not depend on `build-and-test` here: the dispatcher
# gates on `workflow_run.conclusion == 'success'`, which already reflects
# whether the build matrix passed.
upload-dispatch-metadata:
name: Upload Dispatch Metadata
runs-on: ubuntu-latest
steps:
- name: Write PR number
run: |
mkdir -p dispatch-metadata
echo "${{ github.event.pull_request.number }}" \
> dispatch-metadata/pr_number
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dispatch-metadata
path: dispatch-metadata/
retention-days: 1