Replace CI

This removes the technical debt-laden CI with a new one based on Nix and Volare.

The CI uses Magic 8.3.515 and Volare 0.20.6 to build both sky130 and gf180mcu. A successful build is required for the CI to clear. This will run on all pushes and pull requests, and it takes about 30 minutes.

In the event a new tag is pushed and the secret `BOT_GH_TOKEN` is specified, the result of the build is pushed to Volare as a pre-release. Pre-releases may be converted to full releases at the Volare maintainer's discretion.
diff --git a/.github/Dockerfile b/.github/Dockerfile
deleted file mode 100644
index 84f612d..0000000
--- a/.github/Dockerfile
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2020 Efabless Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# syntax = docker/dockerfile:1.0-experimental
-FROM almalinux:8 as build
-
-# Common development tools and libraries (kitchen sink approach)
-RUN yum groupinstall -y "Development Tools"
-
-# magic dependencies
-RUN yum install -y csh wget tcl-devel tk-devel libX11-devel cairo-devel ncurses-devel
-
-#General utils
-RUN yum install -y git tcl tk libjpeg libgomp libXext libSM libXft libffi cairo gettext Xvfb
-RUN yum install -y python3 python3-pip python3-tkinter python3-devel
-
-RUN git clone git://opencircuitdesign.com/magic
-
-WORKDIR magic
-
-# build
-RUN ./configure --prefix=/build && \
-    make -j4 && \
-    make install
-
-
-ENV MAGIC_ROOT=/magic_root
-ENV BUILD_PATH=/build/
-
-ENV PATH=$MAGIC_ROOT:$MAGIC_ROOT/scripts:$BUILD_PATH/bin:$BUILD_PATH/bin/Linux-x86_64:$BUILD_PATH/pdn/scripts:$PATH
-ENV LD_LIBRARY_PATH=$BUILD_PATH/lib:$BUILD_PATH/lib/Linux-x86_64:$LD_LIBRARY_PATH
-ENV MANPATH=$BUILD_PATH/share/man:$MANPATH
-
-
-RUN mkdir -p /build/version/
-
-RUN date +"Build Timestamp: %Y-%m-%d_%H-%M-%S" > /build/version/magic.version
-RUN git rev-parse HEAD >> /build/version/magic.version
-RUN tar -czf /build.tar.gz /build
-
-WORKDIR /magic_root
diff --git a/.github/Makefile b/.github/Makefile
deleted file mode 100644
index 0447bcf..0000000
--- a/.github/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2020 Efabless Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Adopted from OpenLANE's Makefile.
-
-OPEN_PDKS_ROOT ?= $(shell pwd)/..
-THREADS ?= $(shell nproc)
-STD_CELL_LIBRARY ?= sky130_fd_sc_hd
-SKYWATER_COMMIT ?= main
-
-.DEFAULT_GOAL := all
-
-.PHONY: all
-all: pdk
-
-.PHONY: pdk
-pdk: skywater-pdk skywater-library build-pdk
-
-$(PDK_ROOT)/skywater-pdk:
-	git clone https://github.com/google/skywater-pdk.git $(PDK_ROOT)/skywater-pdk
-
-.PHONY: skywater-pdk
-skywater-pdk: $(PDK_ROOT)/skywater-pdk
-	cd $(PDK_ROOT)/skywater-pdk && \
-		git checkout -qf $(SKYWATER_COMMIT)
-
-.PHONY: skywater-library
-skywater-library: $(PDK_ROOT)/skywater-pdk
-	cd $(PDK_ROOT)/skywater-pdk && \
-		git submodule update --init libraries/$(STD_CELL_LIBRARY)/latest && \
-		$(MAKE) -j$(THREADS) $(STD_CELL_LIBRARY)
-
-.PHONY: all-skywater-libraries
-all-skywater-libraries: skywater-pdk
-	cd $(PDK_ROOT)/skywater-pdk && \
-		git submodule update --init libraries/sky130_fd_sc_hd/latest && \
-		git submodule update --init libraries/sky130_fd_sc_hs/latest && \
-		git submodule update --init libraries/sky130_fd_sc_hdll/latest && \
-		git submodule update --init libraries/sky130_fd_sc_ms/latest && \
-		git submodule update --init libraries/sky130_fd_sc_ls/latest && \
-		git submodule update --init libraries/sky130_fd_sc_hvl/latest && \
-		$(MAKE) -j$(THREADS) timing
-
-.PHONY: build-pdk
-build-pdk: $(PDK_ROOT)/skywater-pdk
-	[[ -d $(PDK_ROOT)/sky130A ]] && \
-		(echo "Warning: A sky130A build already exists under $(PDK_ROOT). It will be deleted first!" && \
-		sleep 5 && \
-		rm -rf $(PDK_ROOT)/sky130A) || \
-		true
-	cd $(OPEN_PDKS_ROOT) && \
-		./configure \
-			--prefix=$(PDK_ROOT) \
-			--datarootdir=$(PDK_ROOT) \
-			--enable-sky130-pdk=$(PDK_ROOT)/skywater-pdk \
-			&& \
-		cd sky130 && \
-		$(MAKE) veryclean && \
-		$(MAKE) && \
-		$(MAKE) install-local
diff --git a/.github/build-docker.sh b/.github/build-docker.sh
deleted file mode 100755
index c92792d..0000000
--- a/.github/build-docker.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2020 Efabless Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# exit when any command fails
-set -e
-
-docker build --rm -t magic .
-
-# Copy the build.tar.gz out of the docker container
-docker run --name magic magic:latest
-docker cp magic:/build.tar.gz ./magic.tar.gz
-docker rm magic
diff --git a/.github/build.sh b/.github/build.sh
deleted file mode 100755
index 8f08cb3..0000000
--- a/.github/build.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2020 Efabless Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# exit when any command fails
-set -e
-
-export OPEN_PDKS_ROOT=$(pwd)
-export PDK_ROOT=$(pwd)/pdks
-mkdir -p $PDK_ROOT
-
-cd .github
-
-echo ::group::.github/build-docker.sh
-bash ./build-docker.sh
-echo ::endgroup::
-
-echo ::group::make skywater-pdk
-make skywater-pdk
-echo ::endgroup::
-
-if [ x"$STD_CELL_LIBRARY" = xall ]; then
-    cnt=0
-    until make all-skywater-libraries; do
-        cnt=$((cnt+1))
-        if [ $cnt -eq 5 ]; then
-            exit 2
-        fi
-        rm -rf $PDK_ROOT/skywater-pdk
-        make skywater-pdk
-    done
-else
-    cnt=0
-    until make skywater-library; do
-        cnt=$((cnt+1))
-        if [ $cnt -eq 5 ]; then
-            exit 2
-        fi
-        rm -rf $PDK_ROOT/skywater-pdk
-        make skywater-pdk
-    done
-fi
-
-cd ..
-
-docker run \
-	\
-	-v $(pwd):/some_root \
-	-v $(pwd)/.github:/build_root \
-	-v $OPEN_PDKS_ROOT:$OPEN_PDKS_ROOT \
-	-v $PDK_ROOT:$PDK_ROOT \
-	\
-	-e OPEN_PDKS_ROOT=$OPEN_PDKS_ROOT \
-	-e PDK_ROOT=$PDK_ROOT \
-	-u $(id -u $USER):$(id -g $USER) \
-	\
-	magic:latest \
-	\
-	bash -c "cd /build_root && make build-pdk"
-exit 0
diff --git a/.github/capture.sh b/.github/capture.sh
deleted file mode 100644
index 559b2fc..0000000
--- a/.github/capture.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash
-# Copyright 2021 Open PDKs Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-mkdir -p ${GITHUB_WORKSPACE}/output/
-
-# Copy build log.
-cp ./sky130/sky130A_install.log ${GITHUB_WORKSPACE}/output/
-
-# Copy any core dupmps into the output directory.
-find . -name core -not \( -path '*/skywater-pdk/*' -prune \) | \
-	awk -v ln=1 '{print "cp " $0 " ${GITHUB_WORKSPACE}/output/core." ln++ }' | \
-	bash
-
-# Copy the magic tarball into output
-cp .github/magic.tar.gz ${GITHUB_WORKSPACE}/output/
-
-# Try to create a deterministic tar file
-# https://reproducible-builds.org/docs/archives/
-(
-	SKY130_DIR="$(pwd)/pdks/pdk/sky130A"
-	if ! [[ -d $SKY130_DIR ]]; then
-	    echo "Missing $SKY130_DIR"
-	    exit -1
-	fi
-
-	echo ::group::PDK tarball
-
-	cd ${SKY130_DIR}
-	tar \
-		--create \
-		--bzip2 \
-		--verbose \
-		\
-		--mtime='2020-05-07 00:00Z' \
-		--sort=name \
-		--owner=0 \
-		--group=0 \
-		--numeric-owner \
-		--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
-		\
-		--file ${GITHUB_WORKSPACE}/output/pdk-SKY130A-${STD_CELL_LIBRARY}.tar.bz2 .
-
-	echo ::endgroup::
-)
-
-# Free up disk space so the GitHub Action runner doesn't die when collecting
-# the artifacts.
-echo ::group::Freeup space
-
-df -h
-
-for DIR in ${GITHUB_WORKSPACE}/*; do
-	if [ x$DIR = x"${GITHUB_WORKSPACE}/output" ]; then
-		continue
-	fi
-	echo
-	echo "Removing $DIR"
-	rm -rvf $DIR
-done
-
-df -h
-
-echo ::endgroup::
-
-# Output which files are being saved.
-echo ::group::Output files
-du -h  ${GITHUB_WORKSPACE}/output/*
-echo ::endgroup::
-
-exit 0
diff --git a/.github/test.sh b/.github/test.sh
deleted file mode 100755
index b0ef360..0000000
--- a/.github/test.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-# Copyright 2020 Efabless Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-SKY130_DIR="$(pwd)/pdks/pdk/sky130A"
-if ! [[ -d $SKY130_DIR ]]; then
-    echo "Missing $SKY130_DIR"
-    exit -1
-fi
-
-du -h $SKY130_DIR
-
-echo ::group::Output files
-echo
-find $SKY130_DIR | sort
-echo
-echo ::endgroup::
-
-SIZE=$(du -sb $SKY130_DIR | cut -f1)
-# 250MB = 131,072,000 bytes; a fair estimate of the size of one library, I guess.
-if [[ $SIZE -lt 131072000 ]]; then
-    echo 'size is less than 125MB'
-    exit -1
-fi
-echo 'Built without fatal errors'
-echo "sky130A size is $SIZE bytes"
-exit 0
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000..0c92667
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,58 @@
+name: Build
+
+on:
+  push:
+  pull_request:
+
+jobs:
+  build-and-test:
+    strategy:
+      matrix:
+        os:
+          [
+            {
+              name: "macOS 14",
+              family: "macOS",
+              runner: "macos-14",
+              archs: "arm64",
+            },
+          ]
+        pdk: [sky130, gf180mcu]
+    name: Build ${{ matrix.pdk }} with Volare | ${{ matrix.os.name }} | ${{ matrix.os.archs }}
+    runs-on: ${{ matrix.os.runner }}
+    steps:
+      - name: Clear Build Space
+        run: |
+          echo "== Before =="
+          df -h
+          for xcode in /Applications/Xcode*; do
+            echo "== Removing $xcode … =="
+            rm -rf $xcode
+          done
+          echo "== After =="
+          df -h
+      - uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+      - uses: DeterminateSystems/nix-installer-action@main
+        with:
+          extra-conf: |
+            extra-substituters = https://openlane.cachix.org
+            extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E=
+      - name: Install Magic, Volare
+        run: nix profile install github:efabless/nix-eda/3d8f596ec8831538acdd61889d056378b5bea16b#magic-vlsi github:efabless/volare/0.20.6
+      - name: Set PDK root
+        run: |
+          mkdir -p root
+          echo "PDK_ROOT=$PWD/root" >> $GITHUB_ENV
+      - name: Build with Volare
+        run: |
+          volare build --include-libraries all --pdk ${{ matrix.pdk }} --use-repo-at open_pdks=$PWD --jobs $(sysctl -n hw.logicalcpu) --clear-build-artifacts $(git rev-parse HEAD)
+      - name: Push if New Tag
+        if: github.ref_type == 'tag'
+        run: |
+          if [ "${{ secrets.BOT_GH_TOKEN }}" != "" ]; then
+            volare push --pre --token ${{ secrets.BOT_GH_TOKEN }} --pdk ${{ matrix.pdk }} $(git rev-parse HEAD)
+          else
+            echo "Secret BOT_GH_TOKEN unset. Not attempting to push."
+          fi
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 638da03..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-name: CI
-
-on:
-  push:
-  pull_request:
-  workflow_dispatch:
-
-
-jobs:
-
-  Run:
-    strategy:
-      fail-fast: false
-      matrix:
-        library:
-          - sky130_fd_sc_hd
-          - sky130_fd_sc_hdll
-          - sky130_fd_sc_hs
-          - sky130_fd_sc_ms
-          - sky130_fd_sc_ls
-          - sky130_fd_sc_hvl
-          - all
-    env:
-      STD_CELL_LIBRARY: ${{ matrix.library }}
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v3
-      with:
-        fetch-depth: 0
-        submodules: true
-
-    - name: Build
-      run: |
-        bash .github/build.sh
-
-    - name: Test
-      run: |
-        bash .github/test.sh
-
-    - name: Capture
-      if: ${{ always() }}
-      run: |
-        bash .github/capture.sh
-
-    - name: Upload
-      if: ${{ always() }}
-      uses: actions/upload-artifact@v3
-      with:
-        name: ${{ matrix.library }}
-        path: ${{ github.workspace }}/output/**