diff --git a/.github/workflows/Makefile b/.github/workflows/Makefile new file mode 100644 index 0000000..a345bbf --- /dev/null +++ b/.github/workflows/Makefile @@ -0,0 +1,22 @@ +# Makefile to automatically convert the .jsonnet GHA workflows +# to .yml (GHA accepts only the YAML format). + +LIBS = +OBJS = build-and-test.yml + +all: $(OBJS) + +%.yml: %.jsonnet $(LIBS) + echo "# AUTOGENERATED FROM $< DO NOT MODIFY" > $@ + ./jsonnet_to_yaml.sh $< >> $@ || { rm -f $@; exit 1; } + +clean: + rm -f $(OBJS) + +# for pad's codemap +.PHONY: gen-codemapignore +gen-codemapignore: $(OBJS) + rm -f .codemapignore + for i in $(OBJS); do \ + echo $$i >> .codemapignore; \ + done diff --git a/.github/workflows/build-and-test.jsonnet b/.github/workflows/build-and-test.jsonnet new file mode 100644 index 0000000..f32ccf1 --- /dev/null +++ b/.github/workflows/build-and-test.jsonnet @@ -0,0 +1,102 @@ +// ---------------------------------------------------------------------------- +// Helpers +// ---------------------------------------------------------------------------- + +local checkout = { + uses: 'actions/checkout@v3', +}; + +local build_script = ||| + ./configure + . ./env + mk + mk install +|||; + +// ---------------------------------------------------------------------------- +// The jobs +// ---------------------------------------------------------------------------- + +// Arch +local build_x86_linux_arch_job = { + 'runs-on': 'ubuntu-latest', + container: 'archlinux', + steps: [ + checkout, + { + name: 'Install dependencies', + run: ||| + pacman -Sy --noconfirm gcc lib32-glibc lib32-gcc-libs + |||, + }, + { + name: 'Build', + run: build_script, + } + ] +}; + +// Alpine +//local build_x86_linux_alpine_job = { +// 'runs-on': 'ubuntu-latest', +// // alpine does not support gcc-multilib like ubuntu/arch +// // so simpler to start from a 32 bits alpine image +// // But this does not seem to work well with GHA :( +// container: 'i386/alpine', +// steps: [ +// checkout, +// { +// name: 'Install dependencies', +// run: ||| +// apk add bash gcc +// |||, +// }, +// { +// name: 'Build', +// run: build_script, +// } +// ] +//}; + +// Ubuntu +local build_x86_linux_ubuntu_job = { + 'runs-on': 'ubuntu-latest', + steps: [ + checkout, + { + name: 'Install dependencies', + run: ||| + sudo apt update + sudo apt-get install -y gcc-multilib + |||, + }, + { + name: 'Build', + run: build_script, + } + ] +}; + +// ---------------------------------------------------------------------------- +// The workflow +// ---------------------------------------------------------------------------- +{ + name: 'build-and-test', + on: { + // can be run manually from the GHA dashboard + workflow_dispatch: null, + // on the PR + pull_request: null, + // and another time once the PR is merged on master + push: { + branches: [ + 'master', + ], + }, + }, + jobs: { + 'build-x86-linux-arch': build_x86_linux_arch_job, + //'build-x86-linux-alpine': build_x86_linux_alpine_job, + 'build-x86-linux-ubuntu': build_x86_linux_ubuntu_job, + }, +} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..b7e4153 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,37 @@ +# AUTOGENERATED FROM build-and-test.jsonnet DO NOT MODIFY +jobs: + build-x86-linux-arch: + container: archlinux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + pacman -Sy --noconfirm gcc lib32-glibc lib32-gcc-libs + - name: Build + run: | + ./configure + . ./env + mk + mk install + build-x86-linux-ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt update + sudo apt-get install -y gcc-multilib + - name: Build + run: | + ./configure + . ./env + mk + mk install +name: build-and-test +on: + pull_request: null + push: + branches: + - master + workflow_dispatch: null diff --git a/.github/workflows/jsonnet_to_yaml.sh b/.github/workflows/jsonnet_to_yaml.sh new file mode 100755 index 0000000..38594ef --- /dev/null +++ b/.github/workflows/jsonnet_to_yaml.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# This script requires to have: +# - jsonnet (any jsonnet should work, e.g., go-jsonnet) +# - yq (a.k.a go-yq) from https://github.com/mikefarah/yq +# Note that many distributions come with a default yq that is not +# as powerful as https://github.com/mikefarah/yq so follow +# the instructions there to install yq on your machine +# +# The sed command is because 'on' is printed with or without quotes depending +# on the version. It's a dirty hack that may break some input. + +jsonnet "$@" \ +| yq eval -P \ +| sed -e 's/^\( *\)"on":/\1on:/' \ +| sed -e 's/: "yes"$/: yes/'