Skip to content

Commit

Permalink
Setup GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Jul 1, 2020
1 parent 0efcb8d commit 309f84b
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .ci/fold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash

# adapted from: https://gist.github.com/prisis/e050c4da44c6ee7fa1519912eac19563

set -e -o pipefail

nanoseconds() {
local cmd="date"
local format="+%s%N"
local os=$(uname)

if hash gdate > /dev/null 2>&1; then
cmd="gdate"
elif [[ "$os" = Darwin ]]; then
format="+%s000000000"
fi

$cmd -u $format
}

# Arguments:
# $1 fold name
# $2 command to execute
travisfold () (
set -e -o pipefail
local title=$1
shift
local fold=$(echo "$title" | sed -r 's/[^-_A-Za-z\d]+/./g')
local id=$(printf %08x $(( RANDOM * RANDOM )))
local start=$(nanoseconds)

function travisfoldend() {
local end=$(nanoseconds)
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
if [ "$1" == "true" ]; then
echo -e "\\e[41mKO\\e[0m $title\\n"
else
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold"
fi
}

echo -e "travis_fold:start:$fold"
echo -e "travis_time:start:$id"
echo -e "\\e[1;34m$title\\e[0m"

trap "travisfoldend true" EXIT
$*
trap - EXIT
travisfoldend
)

function githubfold () (
set -e -o pipefail
local name=$1
shift

echo "::group::$name"
$*
echo "::endgroup::"
)

function nullfold () (
set -e -o pipefail
shift
$*
)

function cifold () (
set -e -o pipefail
if [[ ! -z "${TRAVIS}" ]]; then
travisfold "$@"
elif [[ ! -z "${GITHUB_RUN_ID}" ]]; then
githubfold "$@"
else
nullfold "$@"
fi
)
53 changes: 53 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.git/
**/.*project
**/*~
**/.c9
**/.deps
**/.dirstamp
**/.idea
**/.libs
**/.settings
**/autom4te.cache
**/*.a
**/*.la
**/*.lo
**/*.log
**/*.o
**/*.out
**/build
**/modules
**/tests/*.diff
**/tests/*.exp
**/tests/*.php
**/tests/*.sh
**/Makefile
**/Makefile.fragments
**/Makefile.global
**/Makefile.objects
**/acinclude.m4
**/aclocal.m4
**/config.guess
**/config.h
**/config.h.in
**/config.log
**/config.nice
**/config.status
**/config.sub
**/configure
**/configure.in
**/install-sh
**/libtool
**/ltmain.sh
**/missing
**/mkinstalldirs
**/run-tests.php
**/tmp-php.ini
result*/

# ci and docker
.github
.travis.*
**/*.nix
**/*Dockerfile
**/.dockerignore
**/nix/**
20 changes: 20 additions & 0 deletions .github/php-alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG PHP_VERSION=7.4
ARG PHP_TYPE=alpine
ARG BASE_IMAGE=php:${PHP_VERSION}-${PHP_TYPE}

# image0
FROM ${BASE_IMAGE}
WORKDIR /build/php-oath
RUN apk --no-cache add alpine-sdk automake autoconf libtool oath-toolkit-dev
ADD . .
RUN phpize
RUN ./configure CFLAGS="-O3"
RUN make
RUN make install

# image1
FROM ${BASE_IMAGE}
RUN apk --no-cache add oath-toolkit-dev
COPY --from=0 /usr/local/lib/php/extensions /usr/local/lib/php/extensions
RUN docker-php-ext-enable oath
ENTRYPOINT ["docker-php-entrypoint"]
28 changes: 28 additions & 0 deletions .github/php-debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

ARG PHP_VERSION=7.4
ARG BASE_IMAGE=php:$PHP_VERSION

# image0
FROM ${BASE_IMAGE}
RUN apt-get update && apt-get install -y \
autoconf \
automake \
gcc \
liboath-dev \
libtool \
m4 \
make \
pkg-config
WORKDIR /build/php-oath
ADD . .
RUN phpize
RUN ./configure CFLAGS="-O3"
RUN make
RUN make install

# image1
FROM ${BASE_IMAGE}
RUN apt-get update && apt-get install -y liboath0
COPY --from=0 /usr/local/lib/php/extensions /usr/local/lib/php/extensions
RUN docker-php-ext-enable oath
ENTRYPOINT ["docker-php-entrypoint"]
29 changes: 29 additions & 0 deletions .github/php-fedora.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

ARG BASE_IMAGE=fedora:latest

# image0
FROM ${BASE_IMAGE}
RUN dnf groupinstall 'Development Tools' -y
RUN dnf install \
gcc \
automake \
autoconf \
libtool \
liboath-devel \
php-devel \
-y
WORKDIR /build/php-oath
ADD . .
RUN phpize
RUN ./configure CFLAGS="-O3"
RUN make
RUN make install

# image1
FROM ${BASE_IMAGE}
RUN dnf install php-cli liboath -y
# this probably won't work on other arches
COPY --from=0 /usr/lib64/php/modules/oath.so /usr/lib64/php/modules/oath.so
# please forgive me
COPY --from=0 /usr/lib64/php/build/run-tests.php /usr/local/lib/php/build/run-tests.php
RUN echo extension=oath.so | sudo tee /etc/php.d/90-oath.ini
32 changes: 32 additions & 0 deletions .github/workflows/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e -o pipefail
source .ci/fold.sh

# config
export DOCKER_NAME=${DOCKER_NAME:-"alpine"}
export PHP_VERSION=${PHP_VERSION:-"7.4"}
export TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE:-"/usr/local/bin/php"}
export RUN_TESTS_PHP=${RUN_TESTS_PHP:-"/usr/local/lib/php/build/run-tests.php"}

function docker_build() (
docker build \
-f .github/php-${DOCKER_NAME}.Dockerfile \
-t php-oath \
--build-arg PHP_VERSION=${PHP_VERSION} \
.
)

function docker_run() (
set -x
docker run \
--env NO_INTERACTION=1 \
--env REPORT_EXIT_STATUS=1 \
--env TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE} \
-v "$PWD/tests:/mnt" \
php-oath \
php ${RUN_TESTS_PHP} /mnt
)

cifold "docker build" docker_build
cifold "docker run" docker_run
95 changes: 95 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

name: docker

on:
push:
branches:
- master
- github-actions
- ci
pull_request:
branches:
- master

jobs:
debian_php72:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.2"
DOCKER_NAME: debian
run: bash ./.github/workflows/docker.sh
debian_php73:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.3"
DOCKER_NAME: debian
run: bash ./.github/workflows/docker.sh
debian_php74:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.4"
DOCKER_NAME: debian
run: bash ./.github/workflows/docker.sh
debian_php80:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "8.0-rc"
DOCKER_NAME: debian
run: bash ./.github/workflows/docker.sh
alpine_php72:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.2"
DOCKER_NAME: alpine
run: bash ./.github/workflows/docker.sh
alpine_php73:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.3"
DOCKER_NAME: alpine
run: bash ./.github/workflows/docker.sh
alpine_php74:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "7.4"
DOCKER_NAME: alpine
run: bash ./.github/workflows/docker.sh
alpine_php80:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: "8.0-rc"
DOCKER_NAME: alpine
run: bash ./.github/workflows/docker.sh
fedora_phpdefault:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
DOCKER_NAME: fedora
TEST_PHP_EXECUTABLE: /usr/bin/php
run: bash ./.github/workflows/docker.sh
22 changes: 22 additions & 0 deletions .github/workflows/linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e -o pipefail
source .ci/fold.sh

# config
export PHP_VERSION=${PHP_VERSION:-"7.4"}
export COVERAGE=${COVERAGE:-false}
export DEBIAN_FRONTEND=noninteractive
export SUDO=sudo

function install_apt_packages() (
${SUDO} add-apt-repository ppa:ondrej/php
${SUDO} apt-get update
${SUDO} apt-get install -y php${PHP_VERSION}-dev liboath-dev
)

cifold "install apt packages" install_apt_packages

# source and execute script used in travis
source .ci/travis_php.sh
run_all

0 comments on commit 309f84b

Please sign in to comment.