Skip to content

CI/CD using GitHub Actions #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 27, 2020
Merged
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
5 changes: 4 additions & 1 deletion .ci-macosx.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh

set -e

brew update
brew install pkg-config
brew install opam
brew install libev
opam init -y --compiler=4.05.0
eval $(opam env)

opam install -y . --deps-only --locked
opam install -y -j 2 . --deps-only --locked
make && make opaminstall
42 changes: 42 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
build_test_server:
name: Build learn-ocaml and run tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build Docker images
run: "make docker-images"
- name: Run learn-ocaml build on demo-repository
run: "docker run --rm -v $(pwd)/demo-repository:/repository learn-ocaml -- build"
- name: Clone learn-ocaml-corpus
run: "mkdir tests/corpuses && cd tests/corpuses && git clone --depth=1 https://github.com/ocaml-sf/learn-ocaml-corpus.git && cd ../.."
- name: Run learn-ocaml build on learn-ocaml-corpus
run: "cd tests && bash -c ./runtests.sh"

build_extra_tests:
name: Run dockerized tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dockerfile:
- 'Dockerfile.test-client'
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Run docker build
run: 'file=${{ matrix.dockerfile }} && docker build -t "learn-ocaml-${file#*.}" -f "$file" .'

# The Gitter webhook https://webhooks.gitter.im/e/f9e05a2b18ee814cbde2
# was not ported to GitHub Actions syntax.
19 changes: 19 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: macOS

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
build:
name: Build learn-ocaml on macOS
runs-on: macos-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build learn-ocaml
run: 'sh .ci-macosx.sh'
40 changes: 40 additions & 0 deletions .github/workflows/deploy-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Note: you may want to update this file and deploy-tags.yml at once
name: Publish dev (Docker image of master)
on:
push:
branches:
- master
jobs:
push_server:
name: Push learn-ocaml image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=master"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ocamlsf/learn-ocaml
tags: master
push_client:
name: Push learn-ocaml-client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=master"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ocamlsf/learn-ocaml-client
target: client
tags: master
48 changes: 48 additions & 0 deletions .github/workflows/deploy-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Note: you may want to update this file and deploy-master.yml at once
name: Publish latest (Docker image of tags)
on:
push:
tags:
- '*'
jobs:
push_server:
name: Push learn-ocaml image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Get tag name
run: tag="${{ github.ref }}"; echo "::set-output name=tag::${tag#refs/tags/}"
id: tag
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=${{ steps.tag.outputs.tag }}"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ocamlsf/learn-ocaml
tags: latest
tag_with_ref: true
push_client:
name: Push learn-ocaml-client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Get tag name
run: tag="${{ github.ref }}"; echo "::set-output name=tag::${tag#refs/tags/}"
id: tag
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=${{ steps.tag.outputs.tag }}"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ocamlsf/learn-ocaml-client
target: client
tags: latest
tag_with_ref: true
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

41 changes: 11 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,12 @@ COPY dune dune
RUN sudo chown -R opam:nogroup .

ENV OPAMVERBOSE 1
RUN cat /proc/cpuinfo /proc/meminfo
RUN opam install . --destdir /home/opam/install-prefix --locked



FROM alpine:3.7 as client

ARG BUILD_DATE
ARG VCS_BRANCH
ARG VCS_REF

LABEL org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.name="learn-ocaml-client" \
org.label-schema.description="learn-ocaml command-line client" \
org.label-schema.url="https://ocaml-sf.org/" \
org.label-schema.vendor="The OCaml Software Foundation" \
org.label-schema.version="${VCS_BRANCH}" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.vcs-url="https://github.com/ocaml-sf/learn-ocaml" \
org.label-schema.schema-version="1.0"

RUN apk update \
&& apk add ncurses-libs libev dumb-init \
&& addgroup learn-ocaml \
Expand All @@ -58,24 +44,14 @@ COPY --from=compilation /home/opam/install-prefix/bin/learn-ocaml-client /usr/bi

ENTRYPOINT ["dumb-init","learn-ocaml-client"]

LABEL org.opencontainers.image.title="learn-ocaml-client"
LABEL org.opencontainers.image.description="learn-ocaml command-line client"
LABEL org.opencontainers.image.url="https://ocaml-sf.org/"
LABEL org.opencontainers.image.vendor="The OCaml Software Foundation"


FROM alpine:3.7 as program

ARG BUILD_DATE
ARG VCS_BRANCH
ARG VCS_REF

LABEL org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.name="learn-ocaml" \
org.label-schema.description="learn-ocaml app manager" \
org.label-schema.url="https://ocaml-sf.org/" \
org.label-schema.vendor="The OCaml Software Foundation" \
org.label-schema.version="${VCS_BRANCH}" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.vcs-url="https://github.com/ocaml-sf/learn-ocaml" \
org.label-schema.schema-version="1.0"

RUN apk update \
&& apk add ncurses-libs libev dumb-init git \
&& addgroup learn-ocaml \
Expand All @@ -92,5 +68,10 @@ WORKDIR /home/learn-ocaml

COPY --from=compilation /home/opam/install-prefix /usr

CMD ["build","serve"]
ENTRYPOINT ["dumb-init","learn-ocaml","--sync-dir=/sync","--repo=/repository"]
CMD ["build","serve"]

LABEL org.opencontainers.image.title="learn-ocaml"
LABEL org.opencontainers.image.description="learn-ocaml app manager"
LABEL org.opencontainers.image.url="https://ocaml-sf.org/"
LABEL org.opencontainers.image.vendor="The OCaml Software Foundation"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ lessons and tutorials.

A demo is available at: (http://learn-ocaml.hackojo.org/).

[![Build Status](https://travis-ci.org/ocaml-sf/learn-ocaml.svg?branch=master)](https://travis-ci.org/ocaml-sf/learn-ocaml)
[![CI](https://github.com/ocaml-sf/learn-ocaml/workflows/CI/badge.svg?branch=master)](https://github.com/ocaml-sf/learn-ocaml/actions?query=workflow%3ACI)
[![macOS](https://github.com/ocaml-sf/learn-ocaml/workflows/macOS/badge.svg?branch=master)](https://github.com/ocaml-sf/learn-ocaml/actions?query=workflow%3AmacOS)
[![learn-ocaml](https://img.shields.io/badge/docker-ocamlsf%2Flearn--ocaml-blue.svg)](https://hub.docker.com/r/ocamlsf/learn-ocaml "Docker image of learn-ocaml")
[![learn-ocaml-client](https://img.shields.io/badge/docker-ocamlsf%2Flearn--ocaml--client-blue.svg)](https://hub.docker.com/r/ocamlsf/learn-ocaml-client "Docker image of learn-ocaml-client")

Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 1.7)
(name learn-ocaml)
(version 0.11)
(version 0.12)