Skip to content

Commit

Permalink
add skeleton for .github/workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
aryx committed Apr 19, 2024
1 parent eb047c5 commit 7abb8b2
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/Makefile
Original file line number Diff line number Diff line change
@@ -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
102 changes: 102 additions & 0 deletions .github/workflows/build-and-test.jsonnet
Original file line number Diff line number Diff line change
@@ -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,
},
}
37 changes: 37 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/workflows/jsonnet_to_yaml.sh
Original file line number Diff line number Diff line change
@@ -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/'

0 comments on commit 7abb8b2

Please sign in to comment.