Skip to content

Commit

Permalink
Use own Docker image, add openocd
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Mar 29, 2024
1 parent 1156fda commit de29654
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 26 deletions.
82 changes: 82 additions & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# syntax=docker/dockerfile:1.2

# SPDX-FileCopyrightText: 2024 Google LLC

# SPDX-License-Identifier: CC0-1.0

ARG UBUNTU_VERSION
FROM ubuntu:$UBUNTU_VERSION AS builder

LABEL vendor="QBayLogic B.V." maintainer="devops@qbaylogic.com"
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 PREFIX=/opt

ARG DEPS_COMMON="build-essential ca-certificates curl git locales ca-certificates"

RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_COMMON \
&& locale-gen en_US.UTF-8 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM builder AS build-openocd-vexriscv

ARG DEPS_OPENOCD_VEXRISCV="autoconf automake libtool pkg-config libusb-1.0-0-dev libftdi-dev libhidapi-dev libusb-dev libyaml-dev"

RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_OPENOCD_VEXRISCV \
&& git clone --recursive https://github.com/SpinalHDL/openocd_riscv.git \
&& cd openocd_riscv \
&& ./bootstrap \
&& ./configure --enable-ftdi --enable-dummy --prefix=/opt \
&& make -j$(nproc) \
&& make install

FROM builder AS build-verilator

ARG DEPS_VERILATOR="perl python3 make autoconf g++ flex bison ccache libgoogle-perftools-dev numactl perl-doc libfl2 libfl-dev zlib1g zlib1g-dev help2man"
RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_VERILATOR

ARG verilator_version="v5.020"
RUN git clone https://github.com/verilator/verilator verilator \
&& cd verilator \
&& git checkout $verilator_version \
&& autoconf \
&& ./configure --prefix $PREFIX \
&& make PREFIX=$PREFIX -j$(nproc) \
&& make PREFIX=$PREFIX install \
&& cd ../.. \
&& rm -Rf verilator

FROM builder AS build-ghc

ARG ghcup_version="0.1.22.0"

# Must be explicitly set
ARG ghc_version
ARG cabal_version

RUN curl "https://downloads.haskell.org/~ghcup/$ghcup_version/x86_64-linux-ghcup-$ghcup_version" --output /usr/bin/ghcup \
&& chmod +x /usr/bin/ghcup \
&& ghcup install ghc $ghc_version --set \
&& ghcup install cabal $cabal_version --set

FROM builder AS run

LABEL vendor="QBayLogic B.V." maintainer="devops@qbaylogic.com"
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 PATH="$PATH:/opt/bin:/root/.ghcup/bin"

ARG DEPS_RUNTIME="gnupg pkg-config openjdk-8-jdk gdb picocom libtinfo5 build-essential curl"
RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_RUNTIME \
&& echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list \
&& echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list \
&& curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add \
&& apt-get update \
&& apt-get install -y --no-install-recommends sbt \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build-verilator /opt /opt
COPY --from=build-openocd-vexriscv /opt /opt
COPY --from=build-ghc /root/.ghcup /root/.ghcup
48 changes: 48 additions & 0 deletions .github/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2024 Google LLC

# SPDX-License-Identifier: CC0-1.0
set -xeo pipefail

REPO="ghcr.io/clash-lang"
NAME="clash-vexriscv-ci"
DIR=$(dirname "$0")
now=$(date +%Y%m%d)

if [[ "$1" == "-y" ]]; then
push=y
elif [[ "$1" != "" ]]; then
echo "Unrecognized argument: $1" >&2
exit 1
fi

UBUNTU_VERSION=jammy-20240125
GHC_VERSIONS=( "9.4.8" "9.2.8" "9.0.2")
CABAL_VERSIONS=("3.10.2.0" "3.10.2.0" "3.10.2.0")

for i in "${!GHC_VERSIONS[@]}"
do
GHC_VERSION="${GHC_VERSIONS[i]}"
CABAL_VERSION="${CABAL_VERSIONS[i]}"

docker buildx build \
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
--build-arg cabal_version=${CABAL_VERSION} \
--build-arg ghc_version=${GHC_VERSION} \
-t "${REPO}/${NAME}:${GHC_VERSION}-$now" \
"$DIR"
done

if [[ "${push}" == "" ]]; then
read -p "Push to GitHub? (y/N) " push
fi

if [[ $push =~ ^[Yy]$ ]]; then
for i in "${!GHC_VERSIONS[@]}"
do
GHC_VERSION="${GHC_VERSIONS[i]}"
docker push "${REPO}/${NAME}:${GHC_VERSION}-$now"
done
else
echo "Skipping push to container registry"
fi
29 changes: 3 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
apt-get update
apt-get install -y curl build-essential
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.67 # See Note [Updating Rust versions]
Expand Down Expand Up @@ -69,7 +65,6 @@ jobs:
run: |
apt-get update
apt-get install -y curl build-essential
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.67.1 # See Note [Updating Rust versions]
Expand Down Expand Up @@ -116,7 +111,7 @@ jobs:
- "9.4.8"

container:
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20240221
image: ghcr.io/clash-lang/clash-vexriscv-ci:${{ matrix.ghc }}-20240329

steps:
- name: Checkout
Expand All @@ -132,27 +127,9 @@ jobs:
with:
path: |
~/.local/state/cabal/store/
key: packages-cachebust-2-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal.project') }}
restore-keys: packages-cachebust-2-${{ matrix.ghc }}
key: packages-cachebust-3-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal.project') }}
restore-keys: packages-cachebust-3-${{ matrix.ghc }}

- name: Install build deps
run: |
apt-get update
apt-get install gnupg pkg-config -y
- name: Install Java
run: |
# install Java 8
apt-get update
apt-get install openjdk-8-jdk -y
update-alternatives --config java
update-alternatives --config javac
- name: Install SBT
run: |
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
apt-get update
apt-get install sbt -y
- name: Stash existing VexRiscv.v
run: |
cp clash-vexriscv/example-cpu/VexRiscv.v clash-vexriscv/example-cpu/VexRiscv.v.comitted
Expand Down

0 comments on commit de29654

Please sign in to comment.