Skip to content

Commit

Permalink
Modernize Github Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Jun 20, 2024
1 parent 47c6d04 commit 8d5f4c2
Show file tree
Hide file tree
Showing 14 changed files with 332 additions and 405 deletions.
63 changes: 7 additions & 56 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,56 +1,7 @@
.git/

**/.*project
**/*~
**/.deps
**/.dirstamp
**/.libs
**/.idea
**/autom4te.cache
**/gmon*
**/*.a
**/*.la
**/*.lo
**/*.log
**/*.o
**/*.out
**/nbproject
**/build
**/modules
**/test.php
**/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
**/specs
**/result*/**

# ci and docker
.github
.travis.*
**/*.nix
**/*Dockerfile
**/.dockerignore
**/nix/**
*
!config.m4
!m4/*.m4
!php_stemmer.h
!*.c
!tests/*.phpt
!tests/**/*.phpt
10 changes: 10 additions & 0 deletions .github/attrs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
system ? builtins.currentSystem,
lib ? import <nixpkgs/lib>,
prefix,
}: attrs:
lib.pipe attrs.${system} [
builtins.attrNames
(builtins.map (x: "${prefix}.${system}.${x}"))
(builtins.concatStringsSep "\n")
]
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
20 changes: 0 additions & 20 deletions .github/php-alpine.Dockerfile

This file was deleted.

24 changes: 9 additions & 15 deletions .github/php-debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@

ARG PHP_VERSION=7.4
ARG BASE_IMAGE=php:$PHP_VERSION
ARG PHP_VERSION=8.1
ARG PHP_TYPE=bookworm
ARG BASE_IMAGE=php:$PHP_VERSION-cli-$PHP_TYPE

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

# image1
FROM ${BASE_IMAGE}
RUN apt-get update && apt-get install -y \
libstemmer-dev
ENV BIN_PACKAGES="libstemmer0d"
RUN apt-get update && apt-get install -y ${BIN_PACKAGES}
COPY --from=0 /usr/local/lib/php/extensions /usr/local/lib/php/extensions
RUN docker-php-ext-enable stemmer
ENTRYPOINT ["docker-php-entrypoint"]
12 changes: 8 additions & 4 deletions .github/php-fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ ARG BASE_IMAGE=fedora:latest

# image0
FROM ${BASE_IMAGE}
WORKDIR /build

RUN dnf groupinstall 'Development Tools' -y
RUN dnf install \
git-all \
gcc \
automake \
autoconf \
libstemmer-devel \
libtool \
php-devel \
libstemmer-devel \
-y
WORKDIR /build/php-stemmer

WORKDIR /build
ADD . .
RUN phpize
RUN ./configure CFLAGS="-O3"
RUN ./configure
RUN make
RUN make install

# image1
FROM ${BASE_IMAGE}
RUN dnf install php-cli libstemmer-devel -y
RUN dnf install php-cli libstemmer -y
# this probably won't work on other arches
COPY --from=0 /usr/lib64/php/modules/stemmer.so /usr/lib64/php/modules/stemmer.so
# please forgive me
Expand Down
57 changes: 21 additions & 36 deletions .github/scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
#!/usr/bin/env bash

set -e -o pipefail
source .github/scripts/fold.sh
set -ex -o pipefail

# 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"}
export PHP_VERSION="${PHP_VERSION:-"8.1"}"
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"}"
export IMAGE_TAG="${IMAGE_TAG:-"php-stemmer-${DOCKER_NAME}"}"

function docker_build() (
docker build \
-f .github/php-${DOCKER_NAME}.Dockerfile \
-t php-stemmer \
--build-arg PHP_VERSION=${PHP_VERSION} \
.
)
docker build \
-f ".github/php-${DOCKER_NAME}.Dockerfile" \
-t "${IMAGE_TAG}" \
--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-stemmer \
php ${RUN_TESTS_PHP} /mnt
)
trap 'catch' ERR

function install_apt_packages() (
${SUDO} add-apt-repository ppa:ondrej/php
${SUDO} apt-get update
${SUDO} apt-get install -y php${PHP_VERSION}-dev
)
catch() {
find tests -print0 -name '*.log' | xargs -0 -n1 cat
}

function generate_tests() (
php generate_tests.php
)

# cifold "install apt packages" install_apt_packages
# cifold "generate tests" generate_tests
cifold "docker build" docker_build
cifold "docker run" docker_run
docker run \
--env NO_INTERACTION=1 \
--env REPORT_EXIT_STATUS=1 \
--env "TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE}" \
-v "${PWD}/tests:/mnt" \
"${IMAGE_TAG}" \
php "${RUN_TESTS_PHP}" /mnt
77 changes: 0 additions & 77 deletions .github/scripts/fold.sh

This file was deleted.

22 changes: 0 additions & 22 deletions .github/scripts/linux.sh

This file was deleted.

Loading

0 comments on commit 8d5f4c2

Please sign in to comment.