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 2e988f1
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 352 deletions.
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.

26 changes: 10 additions & 16 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="libcap-dev libpfm4-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="libcap2 libpfm4"
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
RUN docker-php-ext-enable perfidious
ENTRYPOINT ["docker-php-entrypoint"]
17 changes: 11 additions & 6 deletions .github/php-fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ 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 \
libcap-devel \
libpfm-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 libcap libpfm -y
# this probably won't work on other arches
COPY --from=0 /usr/lib64/php/modules/stemmer.so /usr/lib64/php/modules/stemmer.so
COPY --from=0 /usr/lib64/php/modules/perfidious.so /usr/lib64/php/modules/perfidious.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=stemmer.so | sudo tee /etc/php.d/90-stemmer.ini
RUN echo extension=perfidious.so | sudo tee /etc/php.d/90-perfidious.ini
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.

95 changes: 0 additions & 95 deletions .github/scripts/suite.sh

This file was deleted.

Loading

0 comments on commit 2e988f1

Please sign in to comment.