Skip to content

[ImportVerilog] Add support for buf primitive #36549

[ImportVerilog] Add support for buf primitive

[ImportVerilog] Add support for buf primitive #36549

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@v3
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@v4
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@v3
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) Test",
"install_target": "",
"package_name_prefix": "",
"cmake_build_type": "release",
"llvm_enable_assertions": "OFF",
"build_shared_libs": "OFF",
"run_tests": true,
"run_integration_tests": false,
"runner": "ubuntu-24.04",
"cmake_c_compiler": "clang"
},
{
"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 }}
# --- end of build-circt job.
# Dispatch a test run in circt/circt-tests once the entire build matrix has
# succeeded.
dispatch-circt-tests:
name: Dispatch circt-tests
needs: build-and-test
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.CIRCT_TESTS_DISPATCH_TOKEN }}
steps:
- name: Dispatch circt-tests
if: env.GH_TOKEN != ''
run: |
if [ "${{ github.event_name }}" = "push" ]; then
KIND=main
SHA=main
REPO="${{ github.repository }}"
PR_NUMBER=""
elif [ "${{ github.event_name }}" = "pull_request" ]; then
KIND=pr
SHA="${{ github.event.pull_request.head.ref }}"
REPO="${{ github.event.pull_request.head.repo.full_name }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
else
echo "Unhandled event type: ${{ github.event_name }}, skipping."
exit 0
fi
DISPATCH_ARGS="-f kind=$KIND -f sha=$SHA -f repo=$REPO"
if [ -n "$PR_NUMBER" ]; then
DISPATCH_ARGS="$DISPATCH_ARGS -f pr_number=$PR_NUMBER"
fi
echo "Dispatching circt-tests with args: $DISPATCH_ARGS"
gh workflow run test.yml --repo circt/circt-tests $DISPATCH_ARGS