Skip to content
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
144 changes: 144 additions & 0 deletions .github/workflows/almalinux-build-toolchain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Container Build (Toolchain)
on:
push:
paths:
- 'containers/labs344-almalinux/**'
- '.github/workflows/almalinux-build-toolchain.yml'
workflow_dispatch:
inputs:
publish:
description: "Publish to the registry"
required: true
default: false
type: boolean

env:
REGISTRY: ghcr.io/bouncmpe
IMAGE_NAME: labs344-almalinux
LABS344_VERSION: latest
CONTAINERS_ROOT: /home/runner/.local/share/containers
TMPDIR: /home/runner/.local/share/containers/tmp
HOSTARCH: amd64
PLATFORM: linux-amd64

permissions:
contents: read
packages: write

jobs:
buildah-build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}
cancel-in-progress: true

steps:
- name: Install container tools
run: sudo apt-get install podman buildah jq

- name: Maximize build space
uses: easimon/maximize-build-space@v10
with:
root-reserve-mb: 2048 # Reserve disk space for repository
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
remove-codeql: "true"
remove-docker-images: "true"
build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build

- run: mkdir -p $TMPDIR

- name: Checkout repository
uses: actions/checkout@v4

- name: Prepare environment variables
run: |
echo "HOSTARCH=$(podman info --format='{{.Host.Arch}}')" >> $GITHUB_ENV
echo "PLATFORM=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g')" >> $GITHUB_ENV
echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Log in to the GitHub Container registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build toolchain container image
id: build-toolchain
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: |
${{ env.LABS344_VERSION }}-toolchain
${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }}
layers: true
oci: true
build-args: |
LABS344_VERSION=${{ env.LABS344_VERSION }}
extra-args: |
--target labs344-toolchain
containerfiles: |
containers/labs344-almalinux/Dockerfile
context: containers

- name: Push to GitHub Container Repository
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish
id: push-toolchain-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.REGISTRY }}
image: ${{ steps.build-toolchain.outputs.image }}
tags: ${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }}
digestfile: ${{ runner.temp }}/digest-labs344-toolchain-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }}

- name: Upload digests
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish
uses: actions/upload-artifact@v4
with:
name: digest-bouncmpe-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }}
path: ${{ runner.temp }}/digest-*
if-no-files-found: error
retention-days: 1
compression-level: 0 # no compression

buildah-merge:
name: Merge container images
runs-on: ubuntu-24.04
needs: buildah-build
if: always() && github.event_name == 'workflow_dispatch' && github.event.inputs.publish
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digest-*
merge-multiple: true

- name: Prepare environment variables
run: |
echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Log in to the GitHub Container registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest list for labs344-toolchain
run: |
MANIFEST=labs344-toolchain
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
buildah manifest create $MANIFEST
for digest in ${{ runner.temp }}/digests/digest-labs344-toolchain-*; do
echo "Adding $(cat $digest)"
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest)
done
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.LABS344_VERSION }}-toolchain
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-toolchain
4 changes: 3 additions & 1 deletion .github/workflows/buildah-build-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
publish:
description: "Publish to the registry"
required: true
default: true
default: false
type: boolean

env:
Expand All @@ -14,6 +14,8 @@ env:
LABS344_VERSION: latest
CONTAINERS_ROOT: /home/runner/.local/share/containers
TMPDIR: /home/runner/.local/share/containers/tmp
HOSTARCH: amd64
PLATFORM: linux-amd64

permissions:
contents: read
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/buildah-build-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
publish:
description: "Publish to the registry"
required: true
default: true
default: false
type: boolean

env:
Expand All @@ -14,6 +14,8 @@ env:
LABS344_VERSION: latest
CONTAINERS_ROOT: /home/runner/.local/share/containers
TMPDIR: /home/runner/.local/share/containers/tmp
HOSTARCH: amd64
PLATFORM: linux-amd64

permissions:
contents: read
Expand Down
78 changes: 78 additions & 0 deletions containers/labs344-almalinux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
ARG LABS344_RHEL_BASE_IMAGE=ghcr.io/almalinux/almalinux
ARG LABS344_RHEL_VERSION=9

ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1

FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344-builder
ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT

RUN dnf install -y git && \
dnf install -y --allowerasing curl && \
dnf clean all

RUN git clone --recurse-submodules https://github.com/openhwgroup/cvw /tmp/cvw && \
cd /tmp/cvw && \
git checkout main && \
export WALLY=$(pwd) && \
export RISCV=/opt/riscv && \
export PYTHON_VERSION=python3.12 && \
bash -c ". $WALLY/bin/wally-environment-check.sh" && \
bash -c ". $WALLY/bin/wally-package-install.sh" && \
cd .. && rm -rf /tmp/cvw && \
dnf clean all

FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344-toolchain
ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT

RUN dnf install -y \
git \
dnf-plugins-core \
dnf-plugin-config-manager \
epel-release \
&& \
dnf config-manager --enable crb && \
dnf clean all

RUN dnf install -y \
autoconf \
automake \
python3.12 \
libmpc-devel \
mpfr-devel \
gmp-devel \
gawk \
bison \
flex \
texinfo \
patchutils \
gcc-toolset-14-gcc \
gcc-toolset-14-gcc-c++ \
zlib-devel \
expat-devel \
libslirp-devel \
make \
cmake \
ninja-build \
&& \
dnf clean all

ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION
ENV LABS344_RISCV_GNU_TOOLCHAIN_VERSION=${LABS344_RISCV_GNU_TOOLCHAIN_VERSION}
ENV LABS344_RISCV_DIR=/opt/riscv
ENV PATH=${LABS344_RISCV_DIR}/riscv-gnu-toolchain/bin:$PATH

RUN . /opt/rh/gcc-toolset-14/enable && \
git clone https://github.com/riscv/riscv-gnu-toolchain /tmp/riscv-gnu-toolchain && \
cd /tmp/riscv-gnu-toolchain && \
./configure --prefix=${LABS344_RISCV_DIR} --enable-multilib --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" && \
make -j$(nproc) && \
make install && \
rm -rf /tmp/riscv-gnu-toolchain

FROM labs344-builder AS labs344-tools
ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT

FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344
ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT

COPY --from=labs344-toolchain /opt/riscv /opt/riscv
Loading