Skip to content
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

Use Github Action for CI and ensure build supports multiple D compiler versions #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
107 changes: 107 additions & 0 deletions .github/workflows/dub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: dub

on:
schedule:
- cron: '30 2 2 * *'
push:
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

name: ${{ matrix.compiler }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
compiler:
- dmd-latest
- ldc-latest
- dmd-2.101.2
- dmd-2.100.2
- dmd-2.099.1
- ldc-1.29.0 # eq to dmd v2.099.1
include:
- { os: ubuntu-latest, compiler: dmd-2.098.1 } # 2021 December
- { os: ubuntu-latest, compiler: dmd-2.097.2 } # 2021
- { os: ubuntu-latest, compiler: dmd-2.095.1 } # 2021
- { os: ubuntu-latest, compiler: dmd-2.090.1 } # 2020 Feb
- { os: ubuntu-latest, compiler: ldc-1.28.1 }

steps:
- uses: actions/checkout@v3

- name: Install D ${{ matrix.compiler }}
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.compiler }}

- name: Install dependencies on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install libsnappy-dev -y

- name: Install dependencies on Mac OSX
if: startsWith(matrix.os, 'macos')
run: brew install snappy

- name: 'dub build'
run: dub build --compiler=$DC

- name: 'dub test'
run: dub test --compiler=$DC

- name: Build the Consumer Example
working-directory: ./examples/consumer
run: dub build

- name: Build the HTTP Log Example
working-directory: ./examples/httplog
run: dub build

- name: Build the Producer Example
working-directory: ./examples/producer
run: dub build

#
# On Ubuntu we can use GDC. The compatibility of gdc is:
# gcc gdc-10 -> 2.076 (default on Ubuntu 20.04)
# gcc gdc-11 -> 2.076
# gcc gdc-12 -> 2.100
# Unfortunately gdc builds are blocked by https://github.com/D-Programming-Deimos/openssl/issues/94
#
# gdc-latest:
# name: ${{ matrix.compiler }} on ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ ubuntu-22.04 ]
# compiler: [ gdc-10, gdc-11, gdc-12 ]
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
#
# - name: Install DMD (so dub is available)
# uses: dlang-community/setup-dlang@v1
# with:
# compiler: dmd-latest
#
# - name: Install ${{ matrix.compiler }}
# run: |
# sudo apt-get update
# sudo apt-get install ${{ matrix.compiler }} -y
# sudo apt-get install libsnappy-dev -y
#
# - name: Show version
# run: |
# ${{ matrix.compiler }} --version
# dub --version
#
# - name: Build with release profile
# env:
# DC: ${{ matrix.compiler }}
# run: dub build --compiler=${{ matrix.compiler }}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ __dummy.html
*.userprefs
*.a
dub.selections.json

# Ignore SublimeText specific files
*.sublime-workspace
kafka-d.sublime-project
examples/consumer/consumer.sublime-project
examples/producer/producer.sublime-project

# Ignore Visual Studio code specific files
launch.json
settings.json
*.userprefs

# Ignore built artifacts
__test__library__
*-test-library
examples/consumer/consumer
examples/httplog/httplog
examples/producer/producer
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Kafka-d is a D Kafka client that depends on the vibe.d framework.
Kafka-d is a D Kafka client that depends on the vibe-core.

[![DUB Package](https://img.shields.io/dub/v/kafka-d.svg)](https://code.dlang.org/packages/kafka-d)
[![Build Status](https://travis-ci.org/tamediadigital/kafka-d.svg?branch=master)](https://travis-ci.org/tamediadigital/kafka-d)

#### Usage
Expand Down
9 changes: 8 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"authors": ["Piotr Szturmaj", "Yannick Koechlin"],
"license" : "MIT",
"dependencies": {
"vibe-d": ">=0.8.4"
"vibe-core": ">=1.16.0"
},
"buildRequirements": [
"allowWarnings"
],
"toolchainRequirements": {
"dub": ">=1.14.0",
"frontend": ">=2.090"
},
"libs": ["snappy"],
"targetType": "library"
Expand Down
3 changes: 1 addition & 2 deletions examples/consumer/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"authors": [ "Piotr Szturmaj" ],
"dependencies": {
"kafka-d": {"version": "~master", "path": "../../"}
},
"dflags" : ["-version=VibeUseOpenSSL11"]
}
}
19 changes: 0 additions & 19 deletions examples/consumer/dub.selections.json

This file was deleted.

9 changes: 6 additions & 3 deletions examples/consumer/source/app.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import std.stdio;
import vibe.vibe;
import kafkad.client;
import std.stdio : writefln;

import vibe.core.core : runTask, runEventLoop, runWorkerTask;
import vibe.core.log : setLogLevel, LogLevel;

import kafkad.client : BrokerAddress, Client, Configuration, Consumer, Offsets;

void main() {
runTask({
Expand Down
3 changes: 2 additions & 1 deletion examples/httplog/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"authors": [ "Piotr Szturmaj" ],
"dependencies": {
"kafka-d": {"version": "~master", "path": "../../"},
"vibe-d": "~>0.7.25"
"vibe-core": ">=1.16.0",
"vibe-d:web": ">=0.9.0"
},
"versions": ["VibeDefaultMain"]
}
19 changes: 13 additions & 6 deletions examples/httplog/source/app.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import std.stdio;
import vibe.vibe;
import kafkad.client;
import std.concurrency : Tid, setMaxMailboxSize, MailboxFull, OnCrowding, send, receive;

import vibe.core.core : runTask;
import vibe.core.task : Task;
import vibe.core.log : setLogLevel, logInfo, LogLevel;
import vibe.http.server : listenHTTP, HTTPServerRequest, HTTPServerResponse, HTTPServerSettings;

import kafkad.client : BrokerAddress, Client, Configuration, Producer;

shared static this()
{
Expand All @@ -11,7 +17,7 @@ shared static this()

listenHTTP(settings, &handleRequest);

producerTid = runTask({
Task task = runTask({
Configuration config;
// adjust config's properties if necessary
config.metadataRefreshRetryCount = 0;
Expand All @@ -30,13 +36,14 @@ shared static this()
}
});

producerTid = task.tid();

setMaxMailboxSize(producerTid, 100, OnCrowding.throwException);
}

shared Tid producerTid;
Tid producerTid;

void handleRequest(HTTPServerRequest req,
HTTPServerResponse res)
void handleRequest(HTTPServerRequest req, HTTPServerResponse res)
{
if (req.path == "/")
res.writeBody("Hello, World!", "text/plain");
Expand Down
3 changes: 1 addition & 2 deletions examples/producer/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"authors": [ "Piotr Szturmaj" ],
"dependencies": {
"kafka-d": {"version": "~master", "path": "../../"}
},
"dflags" : ["-version=VibeUseOpenSSL11"]
}
}
19 changes: 0 additions & 19 deletions examples/producer/dub.selections.json

This file was deleted.

10 changes: 7 additions & 3 deletions examples/producer/source/app.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import std.stdio;
import vibe.vibe;
import kafkad.client;
import std.stdio : writeln, writefln;
import core.time : msecs;

import vibe.core.core : runTask, runEventLoop, runWorkerTask, sleep;
import vibe.core.log : setLogLevel, LogLevel;

import kafkad.client : BrokerAddress, Client, Configuration, Producer;

void main() {
runTask({
Expand Down