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

feat: automate the build #3

Closed
wants to merge 3 commits into from
Closed
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
60 changes: 60 additions & 0 deletions .build/centos6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Take a copy of the source files to build in an isolated directory
mkdir -p /build
cp -R /vmod-queryfilter/* /build
cd /build

cat << EOF > /etc/yum.repos.d/varnish.repo
[varnish]
name=Varnish Repository
baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/\$basearch
enabled=1
fastestmirror_enabled=0
gpgcheck=0
gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
EOF

yum -q makecache -y --disablerepo='*' --enablerepo='varnish'
yum install varnish -y

# Varnish version installed
VERSION=$(rpm --queryformat "%{VERSION}" -q varnish)

# Grab the source for the Varnish version installed
wget "https://github.com/varnishcache/varnish-cache/archive/varnish-$VERSION.tar.gz"
tar -xzf "varnish-$VERSION.tar.gz"

# Build the source
cd "varnish-cache-varnish-$VERSION"
export VARNISHSRC=$(pwd)
./autogen.sh && ./configure && make

cd ..

# Build the vmod
./autogen.sh
./configure VARNISHSRC=$VARNISHSRC
make
make install

# Copy the vmod to where CentOS 6.x wants it
cp -R /usr/local/lib/varnish/vmods/* /usr/lib64/varnish/vmods/.

# Add a varnish file configured to use the plugin
cat << EOF > /etc/varnish/default.vcl
vcl 4.0;

import queryfilter;

backend default {
.host = "127.0.0.1";
.port = "8080";
}

sub vcl_recv {
set req.url = queryfilter.filterparams(req.url, "id,q");
}
EOF

service varnish start
20 changes: 20 additions & 0 deletions .build/debian8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Take a copy of the source files to build in an isolated directory
mkdir -p /build
cp -R /vmod-queryfilter/* /build
cd /build

curl -L https://packagecloud.io/varnishcache/varnish52/gpgkey | apt-key add -

cat << EOF > /etc/apt/sources.list.d/varnish.list
deb https://packagecloud.io/varnishcache/varnish5/ubuntu/ trusty main
deb-src https://packagecloud.io/varnishcache/varnish5/ubuntu/ trusty main
EOF

apt-get update -y
apt-get install varnish varnish-dev -y --force-yes

./autogen.sh
./configure --enable-query-arrays VARNISHSRC=/usr/include/varnish/
make
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ vmod_queryfilter.3

# Things not to ignore
!m4/ax_*

# Kitchen CI
.bundle/
.kitchen/
vendor/
Gemfile.lock
46 changes: 46 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
driver:
name: docker
privileged: true
use_sudo: false
# Share the code into the Kitchen Container
volume:
- $(pwd):/vmod-queryfilter

platforms:
- name: centos-6.9
provisioner:
script: .build/centos6.sh
driver_config:
provision_command:
# Update & install epel-release & yum-utils
- yum update -y
- yum install epel-release -y
- yum install pygpgme yum-utils wget python-docutils ncurses-devel pcre-devel libedit-devel -y
# Install build tools
- yum groupinstall 'Development Tools' -y

- name: debian-8
provisioner:
script: .build/debian8.sh
driver_config:
image: debian:8
provision_command:
# Update & install require packages
- apt-get update && apt-get upgrade -y
- apt-get install curl gnupg apt-transport-https debian-archive-keyring -y
# Install build tools
- apt-get install build-essential autotools-dev libtool automake -y


provisioner:
name: shell

verifier:
name: inspec

suites:
- name: centos
excludes: ["debian-8"]
- name: debian
excludes: ["centos-6.9"]
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: ruby
dist: trusty

matrix:
include:
- rvm: 2.3
env: suite=centos-69
# - rvm: 2.3
# env: suite=debian-8

sudo: required
services: docker

before_script:
- gem install bundler
- bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --retry=3

script: bundle exec kitchen test "$suite"
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem 'inspec'
gem 'test-kitchen'
gem 'kitchen-docker'
gem 'kitchen-inspec'

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
libvmod-queryfilter
===================

Travis
-------

[![Build Status](https://travis-ci.org/gsdevme/libvmod-queryfilter.svg?branch=master)](https://travis-ci.org/gsdevme/libvmod-queryfilter)


Overview
--------
This is a simple VMOD for [Varnish Cache](https://www.varnish-cache.org/) which
Expand Down
2 changes: 1 addition & 1 deletion src/vmod_queryfilter.vcc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#==============================================================================
# libvmod-queryfilter: Simple VMOD for filtering/sorting query strings
#
# Copyright © 2014-2018 The New York Times Company
# Copyright 2014-2018 The New York Times Company
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down