Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constructor based installer #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,17 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./ci

#64
openlane-linux:
runs-on: "ubuntu-20.04"
env:
PACKAGE: "misc/openlane"
OS_NAME: "linux"
steps:
- uses: actions/checkout@v3
- name: 'Install tcllib'
run: |
sudo apt update
sudo apt install -y tcllib
- uses: ./ci
49 changes: 49 additions & 0 deletions .github/workflows/Construct.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build installers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a separated workflow instead of an additional job in Build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the same. Construct is a new workflow, which is called as a reusable workflow from Upload. I mean having it as an additional job in workflow Build, without creating a new (reusable) workflow.
The Build workflow might be executed directly, not as a reusable workflow, which would ignore the recipes/jobs defined in Construct. However, if you put this job in Build, then it will always be run together with other recipes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the same. Construct is a new workflow, which is called as a reusable workflow from Upload. I mean having it as an additional job in workflow Build, without creating a new (reusable) workflow. The Build workflow might be executed directly, not as a reusable workflow, which would ignore the recipes/jobs defined in Construct. However, if you put this job in Build, then it will always be run together with other recipes.

Good point that it shouldn't be in fact run from Upload but from Build. Perhaps you could move the Construct job then @proppy and use needs: "openlane-linux" for it? It'd be also nice to have openlane.sky130a parametrized in Construct.yml so that it's reusable if we ever want to have more installers constructed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Build workflow might be executed directly, not as a reusable workflow, which would ignore the recipes/jobs defined in Construct. However, if you put this job in Build, then it will always be run together with other recipes.

My thinking that whe only want to "release" the installer when we actually publish the packages (so w/ that logic the same way we don't run Upload when we run Build independently, we couldn't run Construct).


on:
workflow_call:

permissions:
contents: write

defaults:
run:
shell: bash

jobs:
openlane-sky130a-installer:
runs-on: "ubuntu-20.04"
steps:
- name: checkout conda-eda
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags

- name: construct installer
run: |
export CI_SCRIPTS_PATH="$(pwd)/ci"
./ci/install.sh
conda install constructor
constructor installer/openlane.sky130a/

- name: archive openlane.sky130a installer
uses: actions/upload-artifact@v3
with:
name: "openlane-sky130a-installer"
path: |
/home/runner/work/conda-eda/conda-eda/openlane-sky130a-0-Linux-x86_64.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there any variable available with this path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be ${{ env.GITHUB_WORKSPACE }}/openlane-sky130a-0-Linux-x86_64.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using openlane-sky130a-0-Linux-x86_64.sh should also work. Since actions/checkout@v3 is used, the default location for other steps is the root of the repo already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I have no preference on the two.


- run: |
git config --local user.name conda-eda@bot
git config --local user.email conda-eda@bot
TAG=$(git describe --tags)
git tag $TAG
git push origin "HEAD:refs/tags/$TAG"
echo "TAG=$TAG" >> $GITHUB_ENV
Comment on lines +39 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just realized there are two issues here:

  1. git describe --tags will use tags from previous runs of this code in Construct.yml so pretty soon we'll have tags like: v0.0-1337-gc24a15291-X-gSHA-X-gSHA-X-gSHA-X-gSHA-...
  2. There's no check if the tag already exists and the workflow will be triggered every day (with Upload.yml nightly runs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I did had this issue, and handled it by removing --tags from the git describe command

You're right it will overwrite the existing release with a new build even if there is no change in conda-eda which could be unfortunate if there are some upstream change but no conda-eda commit.


- uses: softprops/action-gh-release@v1
with:
name: ${{ env.TAG }}
tag_name: ${{ env.TAG }}
files: |
openlane-sky130a-installer/*.sh
6 changes: 6 additions & 0 deletions .github/workflows/Upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ jobs:
ANACONDA_USER: ${{ secrets.ANACONDA_USER }}


Construct:
needs: Upload
if: always() && (github.event_name != 'pull_request') && (github.ref == 'refs/heads/master')
uses: ./.github/workflows/Construct.yml


Cleanup:
runs-on: ubuntu-20.04
steps:
Expand Down
15 changes: 15 additions & 0 deletions installer/openlane.sky130a/construct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: openlane-sky130a
version: 0

channels:
- https://conda.anaconda.org/litex-hub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

litex-hub alone should also work, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all the constructor example were using fully qualified URLs: https://github.com/conda/constructor/search?q=conda.anaconda.org I assumed it was best-practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems channel names are enough for other channels than main indeed: https://github.com/restlessronin/lila-deep/blob/415fc7172c49e0a1ae766c7c9331d0d85645ef33/.colab/construct.yaml

Though I found no construct.yaml with plain main on GH (https://github.com/search?q=main+extension%3Ayaml+filename%3Aconstruct.yaml&type=Code) so I have no preference on full URLs vs channel names.

- http://repo.anaconda.com/pkgs/main/

specs:
- python 3.7*
- conda
- openlane
- open_pdks.sky130a
- xls

post_install: post_install.sh
9 changes: 9 additions & 0 deletions installer/openlane.sky130a/post_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -ex

cat >> $PREFIX/share/openlane/install/env.tcl <<EOF
set ::env(PDK) "sky130A"
set ::env(STD_CELL_LIBRARY) "sky130_fd_sc_hd"
set ::env(STD_CELL_LIBRARY_OPT) "sky130_fd_sc_hd"
EOF
32 changes: 32 additions & 0 deletions misc/openlane/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e
set -x

# Identify OS
UNAME_OUT="$(uname -s)"
case "${UNAME_OUT}" in
Linux*) OS=Linux;;
*) OS="${UNAME_OUT}"
echo "Unknown OS: ${OS}"
exit;;
esac

mkdir -p $PREFIX/share/openlane
git archive HEAD | tar -xv -C $PREFIX/share/openlane
# define system and pdk variables
mkdir -p $PREFIX/share/openlane/install
cp -a $RECIPE_DIR/env.tcl $PREFIX/share/openlane/install
mkdir -p $PREFIX/share/openlane/install/build/versions
touch $PREFIX/share/openlane/install/build/versions/keep-directory
# override default configuration to disable missing tools
cp -a $RECIPE_DIR/disable-missing-tools.tcl $PREFIX/share/openlane/configuration/disable-missing-tools.tcl
echo -n ' disable-missing-tools.tcl' >> $PREFIX/share/openlane/configuration/load_order.txt
# add flow.tcl shortcut
mkdir -p $PREFIX/bin
cat > $PREFIX/bin/flow.tcl <<EOF
#!/usr/bin/env tclsh
lappend argv "-ignore_mismatches"
source "$::env(CONDA_PREFIX)/share/openlane/flow.tcl"
EOF
chmod +x $PREFIX/bin/flow.tcl
6 changes: 6 additions & 0 deletions misc/openlane/disable-missing-tools.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://github.com/hdl/conda-eda/issues/174
set ::env(RUN_CVC) 0
# https://github.com/The-OpenROAD-Project/OpenLane/issues/1380
set ::env(RUN_LVS) 0
# https://github.com/hdl/conda-eda/issues/175
set ::env(RUN_KLAYOUT) 0
10 changes: 10 additions & 0 deletions misc/openlane/env.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# define system variables
set ::env(OPENLANE_ROOT) "$::env(CONDA_PREFIX)/share/openlane"
set ::env(OL_INSTALL_DIR) "$::env(CONDA_PREFIX)/share/openlane/install"
set ::env(OPENLANE_LOCAL_INSTALL) 1
if { ! [info exists ::env(TCLLIBPATH)] } {
set ::env(TCLLIBPATH) [glob -type d "/usr/share/tcltk/tcllib*"]
}
lappend ::auto_path $::env(TCLLIBPATH)
# default to conda-install PDKs
set ::env(PDK_ROOT) "$::env(CONDA_PREFIX)/share/pdk"
50 changes: 50 additions & 0 deletions misc/openlane/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Use `conda-build-prepare` before building for a better version string.
{% set version = '%s_%04i_%s'|format(GIT_DESCRIBE_TAG, GIT_DESCRIBE_NUMBER|int, GIT_DESCRIBE_HASH or 'gUNKNOWN') %}

package:
name: openlane
version: {{ version }}

source:
git_url: https://github.com/The-OpenROAD-Project/OpenLane
git_rev: master

build:
# number: 201803050325
number: {{ environ.get('DATE_NUM') }}
# string: 20180305_0325
string: {{ environ.get('DATE_STR') }}
script_env:
- CI
- CONDA_OUT
- TEST_PACKAGE

requirements:
run:
- openroad
- magic
- netgen
- yosys
- click
- pyyaml

test:
requires:
- open_pdks.sky130a
commands:
- PDK=sky130A STD_CELL_LIBRARY=sky130_fd_sc_hd STD_CELL_LIBRARY_OPT=sky130_fd_sc_hd flow.tcl -design inverter

about:
home: https://github.com/The-OpenROAD-Project/OpenLane
license: Apache-2.0
license_family: Apache
license_file: LICENSE
summary: 'OpenLane is an automated RTL to GDSII flow.'
description: |
OpenLane is an automated RTL to GDSII flow based on several
components including OpenROAD, Yosys, Magic, Netgen, CVC,
SPEF-Extractor, KLayout and a number of custom scripts for design
exploration and optimization. It also provides a number of custom
scripts for design exploration, optimization and ECO.
doc_url: https://openlane.readthedocs.io/
dev_url: https://github.com/The-OpenROAD-Project/OpenLane