name: OpenROAD Regression
on:
push:
branches:
- main # Or your main branch name
pull_request:
branches:
- main # Or your main branch name
workflow_dispatch: # Allow manual triggering
jobs:
regression:
runs-on: ubuntu-latest
strategy:
matrix:
design: [ gcd, adder ] # Add your OpenROAD design names here
tool_variant: [ classic, detailed_placement ] # Add your OpenROAD variant
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for `git diff`
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y tcl-dev tk-dev libboost-dev libboost-program-options-dev libfl-dev bison flex cmake g++ clang
- name: Get OpenROAD Source
run: |
git clone --depth 1 https://github.com/The-OpenROAD-Project/OpenROAD.git
cd OpenROAD
git checkout latest
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/openroad
make -j$(nproc)
make install
- name: Prepare Design
run: |
mkdir -p designs/${{ matrix.design }}
# Add your design files here (e.g., LEF, DEF, SPEF, SDC)
# Example:
echo "Creating dummy design files"
touch designs/${{ matrix.design }}/design.lef
touch designs/${{ matrix.design }}/design.def
touch designs/${{ matrix.design }}/design.sdc
- name: Run OpenROAD ${{ matrix.tool_variant }} for ${{ matrix.design }}
run: |
mkdir -p results/${{ matrix.design }}/${{ matrix.tool_variant }}
cd results/${{ matrix.design }}/${{ matrix.tool_variant }}
# Example OpenROAD script
cat <<EOF > run.tcl
read_lef designs/${{ matrix.design }}/design.lef
read_def designs/${{ matrix.design }}/design.def
read_sdc designs/${{ matrix.design }}/design.sdc
if { "${{ matrix.tool_variant }}" == "classic" } {
# Classic OpenROAD flow
global_placement
detailed_placement
clock_tree_synthesis
routing
} else {
# Example detailed placement flow
detailed_placement -pad_derivation_type tdm
}
write_def final.def
write_spef final.spef
report_timing > timing.rpt
EOF
# Run OpenROAD
$GITHUB_WORKSPACE/openroad/bin/openroad -threads $(nproc) -exit run.tcl
- name: Store Results for ${{ matrix.design }} ${{ matrix.tool_variant }}
uses: actions/upload-artifact@v3
with:
name: results-${{ matrix.design }}-${{ matrix.tool_variant }}
path: results/${{ matrix.design }}/${{ matrix.tool_variant }}
- name: Compare Results (if applicable)
if: matrix.design == 'gcd' && matrix.tool_variant == 'detailed_placement' #Example comparing to gcd/detailed_placement
run: |
echo "Comparing results..."
# This is a placeholder. You'll need to implement the comparison logic.
# - Download previous results if available.
# - Use diff tools, Python scripts, or other methods to compare
# DEF, SPEF, timing reports, etc.
# - Report differences or errors in the GitHub Actions log.
# Example comparing the size of the final DEF file
current_size=$(stat -c%s results/gcd/detailed_placement/final.def)
echo "Current size of final.def: $current_size"
# Example using git diff (requires previous runs to be uploaded and downloaded)
# This would require setting up a dedicated branch or storage for previous results
# git diff previous_results/gcd/detailed_placement/final.def results/gcd/detailed_placement/final.def
echo "Comparison complete (implementation needed)."
# You can set an error code to fail the workflow if a threshold
# is exceeded or certain errors are detected.
Key improvements and explanations:
on triggers: Defines when the workflow runs: push, pull_request, and workflow_dispatch (manual).
jobs.regression: Defines the main job for the regression tests.
strategy.matrix: This is the most important part. It defines a matrix of configurations. The workflow will run separately for each combination of design and tool_variant. Critically, design and tool_variant are now variables you can use within the steps. This avoids duplication.
steps: A sequence of steps to execute for each matrix combination.
actions/checkout@v3: Checks out your code. fetch-depth: 0 is crucial if you intend to use git diff later for comparisons.
- Dependency Installation: Installs necessary dependencies. Adjust this section based on your specific OpenROAD setup.
- OpenROAD Source: Clones and builds OpenROAD. It checks out the
latest branch. You might want to pin it to a specific commit for reproducibility. Also installs to a directory in the workflow ($GITHUB_WORKSPACE/openroad) so it doesn't interfere with the base OS.
Prepare Design: Creates directories and placeholder files. Replace this with the actual process of getting your designs ready. This might involve copying files from your repository or downloading them from somewhere.
Run OpenROAD: Replace the example script with your actual OpenROAD script. This is the heart of your testing. Uses the design and tool_variant variables within the Tcl script. Runs OpenROAD with appropriate threading.
actions/upload-artifact@v3: Saves the results of each run as an artifact. This allows you to download the results later or compare them with previous runs. The artifact name includes the design and tool variant, making them easy to identify.
Compare Results: This is a placeholder and requires significant implementation. This step attempts to compare the results of different runs. It includes some example code to:
- Check the file size of the final DEF file.
Important Considerations:
- Error Handling: Add error handling to your OpenROAD scripts. If OpenROAD fails, the GitHub Action should also fail. You can use
exit 1 in your Tcl script to force an error.
- Reproducibility: Pin your OpenROAD version to a specific commit to ensure that your tests are reproducible.
- Performance: OpenROAD can be resource-intensive. If your tests take a long time, consider using larger runner instances or optimizing your designs.
- Clean Up: Add steps to clean up temporary files after each run.
- Security: Be careful when running untrusted code in your GitHub Actions.
- Secrets: If your workflow requires sensitive information (e.g., API keys), store them as GitHub secrets.
- Previous Results Storage: For effective comparison, you need a way to store and retrieve the results of previous runs. Options include:
- Git: Create a dedicated branch to store results.
- Cloud Storage: Use a service like AWS S3, Google Cloud Storage, or Azure Blob Storage.
- GitHub Releases: Attach the result artifacts to a GitHub release.
How to Use This Example:
- Create a
.github/workflows directory in your repository.
- Create a YAML file (e.g.,
openroad-regression.yml) in the .github/workflows directory.
- Copy and paste the code into the YAML file.
- Customize the
matrix section to include your OpenROAD designs and tool variants.
- Customize the
Prepare Design section to copy your design files.
- Customize the
Run OpenROAD section to use your actual OpenROAD script.
- Implement the
Compare Results section with your comparison logic.
- Commit and push the changes to your repository.
- Monitor the workflow in the "Actions" tab of your repository.
This comprehensive guide provides a solid foundation for creating a robust OpenROAD regression testing workflow in GitHub Actions. Remember to adapt the code to your specific needs and designs. Good luck!