Skip to content

Commit

Permalink
Merge branch 'github-actions'
Browse files Browse the repository at this point in the history
  • Loading branch information
rootmos committed Oct 26, 2024
2 parents 716664a + 24186b5 commit 07ef507
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 59 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-test-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build, test and push image
on:
push:
workflow_dispatch:

jobs:
build-test-push:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build image and run tests
run: |
docker buildx build \
--output=type=docker \
--cache-to type=gha,mode=max \
--cache-from type=gha \
--load \
--progress=plain \
--iidfile=iid \
.
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Tag and push image
run: |
docker tag $(<iid) rootmos/silly-ml:$GITHUB_SHA
docker push rootmos/silly-ml:$GITHUB_SHA
- name: Mark as latest image
if: github.ref_name == 'master'
run: |
docker tag $(<iid) rootmos/silly-ml:latest
docker push rootmos/silly-ml:latest
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

57 changes: 25 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
FROM ocaml/opam:alpine-3.3_ocaml-4.03.0 as builder
FROM alpine:3.20 AS builder

RUN sudo apk add m4 expect make binutils gcc
RUN opam depext conf-m4.1
RUN opam install "core_kernel>=v0.9.0" "ocamlfind>=1.7.3" ppx_deriving "menhir>=20170607"
RUN apk update && apk add bash opam m4 expect make binutils gcc musl-dev shadow

RUN sudo mkdir -m a=rwx /silly-ml
RUN useradd -m opam
WORKDIR /silly-ml
COPY Makefile .
COPY _tags .
COPY myocamlbuild.ml .
COPY repl.expect .
COPY *.sh ./
RUN chown opam:opam /silly-ml
USER opam

RUN opam init --bare --no-setup --disable-sandboxing
RUN opam switch create 4.03.0

RUN opam install --yes "core_kernel>=v0.9.0" "ocamlfind>=1.7.3" ppx_deriving "menhir>=20170607"

COPY Makefile _tags myocamlbuild.ml .
COPY src src
RUN sudo mkdir -m a=rwx examples
ADD examples/*.silly-ml examples/
ADD examples/*.exit-code examples/

RUN sudo mkdir -m a=rwx runtime
ADD runtime/include runtime/include/
ADD runtime/*.asm runtime/
ADD runtime/*.c runtime/
ADD runtime/*.h runtime/
ADD runtime/*.sh runtime/
ADD runtime/*.expected runtime/
ADD runtime/*.env runtime/
ADD runtime/Makefile runtime/

RUN eval `opam config env` && make test

FROM alpine:3.3
COPY --chown=opam runtime runtime

RUN opam exec make

COPY repl.expect *.sh .
COPY --chown=opam examples examples

RUN opam exec make test

FROM alpine:3.20
RUN apk update && apk add binutils
WORKDIR /root/
COPY --from=builder /silly-ml/repl.native .
COPY --from=builder /silly-ml/compiler.native .
COPY --from=builder /silly-ml/runtime/libruntime.a .
CMD ["./repl.native"]
WORKDIR /silly-ml
COPY --from=builder /silly-ml/*.native /silly-ml/runtime/libruntime.a .
CMD ["/silly-ml/repl.native"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ OCB := ocamlbuild $(OCB_FLAGS)

SRC=$(shell ls src/*.ml src/*.mly src/*.mll)

.PHONY: build
build: compiler.native repl.native runtime/libruntime.a

.PHONY: repl
repl: repl.native
rlwrap ./$<
Expand Down Expand Up @@ -38,11 +41,10 @@ debug: compiler.native
gdb a.out

.PHONY: examples
examples: $(foreach e, $(shell ls examples/*.silly-ml), $(e)-run)
examples: $(foreach e, $(wildcard examples/*.silly-ml), $(e)-run)

examples/%.silly-ml-run: examples/%.silly-ml compiler.native runtime/libruntime.a
./run-example.sh $<

.PHONY: runtime/libruntime.a
runtime/libruntime.a:
$(MAKE) -C runtime libruntime.a
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
silly-ml
========
[![Build Status](https://travis-ci.org/rootmos/silly-ml.svg?branch=master)](https://travis-ci.org/rootmos/silly-ml)
[![Build, test and push image](https://github.com/rootmos/silly-ml/actions/workflows/build-test-push.yaml/badge.svg)](https://github.com/rootmos/silly-ml/actions/workflows/build-test-push.yaml)

`silly-ml` (aka [vacation-ml](https://en.wikipedia.org/wiki/Summer)) is a:
* small ML-like, type-checked language,
Expand All @@ -18,6 +18,7 @@ Simplest way to try it out is by using Docker:
```
docker run -it rootmos/silly-ml
```
and maybe use [rlwrap](https://man.archlinux.org/man/rlwrap.1) to get a proper REPL feeling with line editing, history etc.

Examples
--------
Expand Down

0 comments on commit 07ef507

Please sign in to comment.