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
84 changes: 67 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
name: Build

on:
push:
branches:
- main
pull_request:

permissions:
contents: read
concurrency: ${{ github.workflow }}-${{ github.ref }}

concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ github.job}}

jobs:
build:
name: build
templates:
name: templates-to-build
runs-on: ubuntu-latest
outputs:
allTemplates: ${{ steps.list.outputs.ALL_TEMPLATES }}
changedTemplates: ${{ steps.list.outputs.CHANGED_TEMPLATES }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- name: List templates
id: list
run: |
echo "CHANGED_TEMPLATES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | awk -F/ '/^[a-z]*\// {print $1}' | sort -u | jq -Rnc '[inputs]')" >> "$GITHUB_OUTPUT"
echo "ALL_TEMPLATES=$(find ./ -name Dockerfile | awk -F/ '/^\.\/[a-z]*\// {print $2}' | sort -u | jq -Rnc '[inputs]')" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT

build-on-main:
name: Build main
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.templates.outputs.allTemplates != '' && toJson(fromjson(needs.templates.outputs.allTemplates)) != '[]') }}
needs: templates
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
template:
[
cpp,
cpp-low-level,
go,
javascript,
lua,
python,
ruby,
rust,
typescript,
]
allTemplates: ${{ fromJson(needs.templates.outputs.allTemplates) }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -44,5 +59,40 @@ jobs:
run: cartesi doctor

- name: Build
run: cartesi build
working-directory: ${{ matrix.template }}
run: |
cartesi build
cartesi hash
working-directory: ${{ matrix.allTemplates }}

build-on-pr:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having different jobs for main and PR why don't you just manipulate the matrix based on that, and use the same job?

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 create two variables to be used as matrix, I could think of how to use both in a single job.

name: Build PR
if: ${{ github.event_name == 'pull_request' && (needs.templates.outputs.changedTemplates != '' && toJson(fromjson(needs.templates.outputs.changedTemplates)) != '[]') }}
needs: templates
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
changedTemplates: ${{ fromJson(needs.templates.outputs.changedTemplates) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: current

- name: Install Cartesi CLI
run: npm install -g @cartesi/cli

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Check system requirements
run: cartesi doctor

- name: Build
run: |
cartesi build
cartesi hash
working-directory: ${{ matrix.changedTemplates }}
5 changes: 3 additions & 2 deletions go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker.io/docker/dockerfile:1
FROM ubuntu:22.04 AS build-stage
FROM ubuntu:24.04 AS build-stage

ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
Expand All @@ -9,7 +9,8 @@ apt install -y --no-install-recommends \
build-essential=12.9ubuntu3 \
ca-certificates \
g++-riscv64-linux-gnu=4:11.2.0--1ubuntu1 \
wget
wget \
curl
EOF

ARG GOVERSION=1.20.5
Expand Down
4 changes: 3 additions & 1 deletion lua/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ apt-get install -y --no-install-recommends \
lua5.4=5.4.4-1 \
liblua5.4-dev=5.4.4-1 \
luarocks=3.8.0+dfsg1-1
rm -rf /var/lib/apt/lists/*

rm -rf /var/lib/apt/lists/*

luarocks install --lua-version=5.4 luasocket 3.1.0-1
luarocks install --lua-version=5.4 dkjson 2.6-1

EOF

FROM --platform=linux/riscv64 ubuntu:22.04
Expand Down