Skip to content

Commit

Permalink
Update containers and github actions workflows
Browse files Browse the repository at this point in the history
*   Add Ubuntu 22.04 container configuration

*   Split distro worfklows

*   Add reusable build-and-test workflow

*   Update README badges
  • Loading branch information
e3m3 committed Sep 9, 2024
1 parent 4591bb6 commit 3b7872e
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 40 deletions.
47 changes: 22 additions & 25 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2024, Giordano Salvador
# SPDX-License-Identifier: BSD-3-Clause

name: Build-and-test

on:

workflow_dispatch:
workflow_call:
branches: [ "main" ]
inputs:
build_mode:
Expand All @@ -13,32 +16,26 @@ on:
options:
- debug
- release
distro:
description: OS distribution name
required: true
type: string
os_ver:
description: OS distribution version
required: true
type: string
os:
description: OS string identifier
required: true
type: string

jobs:

build-and-test-ubuntu-2404:
env:
DISTRO: ubuntu
OS: ubuntu-2404
runs-on: ubuntu-24.04
steps:

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

- name: Build source container
run: |
docker build \
-f container/Containerfile.${{ env.DISTRO }} \
-t ${{ env.OS }}-calcc-${{ inputs.build_mode }} \
${{ inputs.build_mode == 'release' && '--build-arg=BUILD_MODE=--release' || '' }} \
.
build-and-test-fedora-40:
env:
DISTRO: fedora
OS: fedora-40
build-and-test:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: ${{ github.workspace }}
steps:

- name: Checkout source
Expand All @@ -47,7 +44,7 @@ jobs:
- name: Build source container
run: |
docker build \
-f container/Containerfile.${{ env.DISTRO }} \
-t ${{ env.OS }}-calcc-${{ inputs.build_mode }} \
-f container/Containerfile.${{ inputs.distro }}${{ inputs.os_ver }} \
-t ${{ inputs.os }}-calcc-${{ inputs.build_mode }} \
${{ inputs.build_mode == 'release' && '--build-arg=BUILD_MODE=--release' || '' }} \
.
35 changes: 35 additions & 0 deletions .github/workflows/fedora-40.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024, Giordano Salvador
# SPDX-License-Identifier: BSD-3-Clause

name: Fedora 40

on:

workflow_dispatch:
branches: [ "main" ]
inputs:
build_mode:
description: Build optimization level
required: true
default: debug
type: choice
options:
- debug
- release

env:

DISTRO: fedora
OS_VER: 40
OS: fedora-40

jobs:

run:
runs-on: ubuntu-24.04
uses: e3m3/calcc-rust/.github/workflows/build-and-test.yaml@main
with:
build_mode: debug
distro: ${{ env.DISTRO }}
os_ver: ${{ env.OS_VER }}
os: ${{ env.OS }}
35 changes: 35 additions & 0 deletions .github/workflows/ubuntu-2204.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024, Giordano Salvador
# SPDX-License-Identifier: BSD-3-Clause

name: Ubuntu 22.04

on:

workflow_dispatch:
branches: [ "main" ]
inputs:
build_mode:
description: Build optimization level
required: true
default: debug
type: choice
options:
- debug
- release

env:

DISTRO: ubuntu
OS_VER: 22
OS: ubuntu-2204

jobs:

run:
runs-on: ubuntu-24.04
uses: e3m3/calcc-rust/.github/workflows/build-and-test.yaml@main
with:
build_mode: debug
distro: ${{ env.DISTRO }}
os_ver: ${{ env.OS_VER }}
os: ${{ env.OS }}
35 changes: 35 additions & 0 deletions .github/workflows/ubuntu-2404.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024, Giordano Salvador
# SPDX-License-Identifier: BSD-3-Clause

name: Ubuntu 24.04

on:

workflow_dispatch:
branches: [ "main" ]
inputs:
build_mode:
description: Build optimization level
required: true
default: debug
type: choice
options:
- debug
- release

env:

DISTRO: ubuntu
OS_VER: 24
OS: ubuntu-2404

jobs:

run:
runs-on: ubuntu-24.04
uses: e3m3/calcc-rust/.github/workflows/build-and-test.yaml@main
with:
build_mode: debug
distro: ${{ env.DISTRO }}
os_ver: ${{ env.OS_VER }}
os: ${{ env.OS }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Author/Maintainer: Giordano Salvador <[email protected]>

# Description (calcc language)

[![Ubuntu 22.04](https://github.com/e3m3/calcc-rust/actions/workflows/ubuntu-2204.yaml/badge.svg?event=workflow_dispatch)](https://github.com/e3m3/calcc-rust/actions/workflows/ubuntu-2204.yaml)
[![Ubuntu 24.04](https://github.com/e3m3/calcc-rust/actions/workflows/ubuntu-2404.yaml/badge.svg?event=workflow_dispatch)](https://github.com/e3m3/calcc-rust/actions/workflows/ubuntu-2204.yaml)
[![Fedora 40](https://github.com/e3m3/calcc-rust/actions/workflows/fedora-40.yaml/badge.svg?event=workflow_dispatch)](https://github.com/e3m3/calcc-rust/actions/workflows/fedora-40.yaml)

Learning [Rust][1] [[1]] by implementing the calc langauge using the [llvm-sys][2] [[2]] crate.
Implements the calc language, inspired by the [C++][3] [[3]] implementation presented by Macke and Kwan in [[4]] and [[5]].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ RUN dnf clean -y all
ENV RUST_CHANNEL=stable

RUN rustup-init -y
RUN source ${CARGO_ENV} && rustup toolchain install ${RUST_CHANNEL}
RUN source ${CARGO_ENV} && rustup override set ${RUST_CHANNEL}
RUN source ${CARGO_ENV} && rustup toolchain install ${RUST_CHANNEL}
RUN source ${CARGO_ENV} && rustup override set ${RUST_CHANNEL}

RUN mkdir -p ${PROJECT_DIR}
RUN mkdir -p ${PROJECT_DIR}/src
Expand All @@ -31,5 +31,5 @@ COPY tests ${PROJECT_DIR}/tests/
ARG BUILD_MODE=

WORKDIR ${PROJECT_DIR}
RUN source ${CARGO_ENV} && cargo build --verbose ${BUILD_MODE}
RUN source ${CARGO_ENV} && cargo test --verbose ${BUILD_MODE} -- --nocapture
RUN source ${CARGO_ENV} && cargo build --verbose ${BUILD_MODE}
RUN source ${CARGO_ENV} && cargo test --verbose ${BUILD_MODE} -- --nocapture
32 changes: 21 additions & 11 deletions container/Containerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/ubuntu:24.04
FROM docker.io/ubuntu:22.04

LABEL maintainer="Giordano Salvador <[email protected]>"
USER root
Expand All @@ -10,29 +10,39 @@ ENV SSL_CONF_TMP=/etc/apt/apt.conf.d/99_tmp_ssl-verify-off.conf
ENV SED_HTTPS='s%http://(.*archive|security).ubuntu.com%https://mirrors.edge.kernel.org%g'

RUN echo 'Acquire::https::Verify-Peer "false";' >${SSL_CONF_TMP} && \
sed --in-place=.orig --regexp-extended ${SED_HTTPS} /etc/apt/sources.list.d/* && \
sed --in-place=.orig --regexp-extended ${SED_HTTPS} /etc/apt/sources.list && \
apt-get update && apt-get install ca-certificates -y && \
rm ${SSL_CONF_TMP}

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libstdc++-14-dev gcc llvm llvm-dev clang rustup python3-pip python3-venv
RUN apt-get install -y libstdc++-12-dev gcc python3-pip python3-venv curl git
RUN apt-get clean

ENV PYTHON_VENV_PATH=/root/.python/venv
RUN python3 -m venv ${PYTHON_VENV_PATH}
ENV PATH=${PYTHON_VENV_PATH}/bin:${PATH}
RUN pip install lit

ENV SPACK_GIT=https://github.com/spack/spack
ENV SPACK_VER=v0.22.1
ENV SPACK_HOME=/root/spack
ENV SPACK_SETUP=${SPACK_HOME}/share/spack/setup-env.sh
ENV LLVM_VER=18.1.3

RUN git clone --recursive --branch ${SPACK_VER} ${SPACK_GIT} ${SPACK_HOME}
RUN . ${SPACK_SETUP} && spack install llvm@${LLVM_VER} +clang

ENV RUST_CHANNEL=stable
ENV RUSTUP_HOME=/root/.rustup
ENV TOOLCHAIN=${RUST_CHANNEL}-x86_64-unknown-linux-gnu
ENV CARGO_ENV=/root/.cargo/env

RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -o rustup-boostrap.sh && \
sh rustup-boostrap.sh -y

RUN rustup set auto-self-update disable
RUN rustup toolchain install ${RUST_CHANNEL}
RUN rustup override set ${RUST_CHANNEL}
ENV PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/bin:${PATH}
ENV PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/libexec:${PATH}
ENV LD_LIBRARY_PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/lib:${LD_LIBRARY_PATH}
RUN . ${SPACK_SETUP} && . ${CARGO_ENV} && rustup update
RUN . ${SPACK_SETUP} && . ${CARGO_ENV} && rustup toolchain install ${RUST_CHANNEL}
RUN . ${SPACK_SETUP} && . ${CARGO_ENV} && rustup override set ${RUST_CHANNEL}

RUN mkdir -p ${PROJECT_DIR}
RUN mkdir -p ${PROJECT_DIR}/src
Expand All @@ -48,5 +58,5 @@ COPY tests ${PROJECT_DIR}/tests/
ARG BUILD_MODE=

WORKDIR ${PROJECT_DIR}
RUN cargo build --verbose ${BUILD_MODE}
RUN cargo test --verbose ${BUILD_MODE} -- --nocapture
RUN . ${SPACK_SETUP} && . ${CARGO_ENV} && cargo build --verbose ${BUILD_MODE}
RUN . ${SPACK_SETUP} && . ${CARGO_ENV} && cargo test --verbose ${BUILD_MODE} -- --nocapture
52 changes: 52 additions & 0 deletions container/Containerfile.ubuntu24
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM docker.io/ubuntu:24.04

LABEL maintainer="Giordano Salvador <[email protected]>"
USER root

ENV TERM=xterm-256color
ENV PROJECT_DIR=${HOME}/project

ENV SSL_CONF_TMP=/etc/apt/apt.conf.d/99_tmp_ssl-verify-off.conf
ENV SED_HTTPS='s%http://(.*archive|security).ubuntu.com%https://mirrors.edge.kernel.org%g'

RUN echo 'Acquire::https::Verify-Peer "false";' >${SSL_CONF_TMP} && \
sed --in-place=.orig --regexp-extended ${SED_HTTPS} /etc/apt/sources.list.d/* && \
apt-get update && apt-get install ca-certificates -y && \
rm ${SSL_CONF_TMP}

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libstdc++-14-dev gcc llvm llvm-dev clang rustup python3-pip python3-venv
RUN apt-get clean

ENV PYTHON_VENV_PATH=/root/.python/venv
RUN python3 -m venv ${PYTHON_VENV_PATH}
ENV PATH=${PYTHON_VENV_PATH}/bin:${PATH}
RUN pip install lit

ENV RUST_CHANNEL=stable
ENV RUSTUP_HOME=/root/.rustup
ENV TOOLCHAIN=${RUST_CHANNEL}-x86_64-unknown-linux-gnu

RUN rustup set auto-self-update disable
RUN rustup toolchain install ${RUST_CHANNEL}
RUN rustup override set ${RUST_CHANNEL}
ENV PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/bin:${PATH}
ENV PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/libexec:${PATH}
ENV LD_LIBRARY_PATH=${RUSTUP_HOME}/toolchains/${TOOLCHAIN}/lib:${LD_LIBRARY_PATH}

RUN mkdir -p ${PROJECT_DIR}
RUN mkdir -p ${PROJECT_DIR}/src
RUN mkdir -p ${PROJECT_DIR}/tests

COPY Cargo.toml ${PROJECT_DIR}/
COPY rust-toolchain.toml ${PROJECT_DIR}/
COPY LICENSE ${PROJECT_DIR}/
COPY README.md ${PROJECT_DIR}/
COPY src ${PROJECT_DIR}/src/
COPY tests ${PROJECT_DIR}/tests/

ARG BUILD_MODE=

WORKDIR ${PROJECT_DIR}
RUN cargo build --verbose ${BUILD_MODE}
RUN cargo test --verbose ${BUILD_MODE} -- --nocapture

0 comments on commit 3b7872e

Please sign in to comment.