Skip to content

Commit

Permalink
Merge pull request #13 from openmetrics-php/development
Browse files Browse the repository at this point in the history
Version 0.4
  • Loading branch information
hollodotme committed May 4, 2024
2 parents 867e569 + 2774dfd commit 880a8de
Show file tree
Hide file tree
Showing 50 changed files with 695 additions and 1,397 deletions.
14 changes: 9 additions & 5 deletions .docker/composer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM composer
ENV XDEBUG_VERSION 2.7.2

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

# Update system
RUN apk update && apk upgrade && apk add --no-cache git $PHPIZE_DEPS procps \
&& pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug
RUN set -ex && apk update && apk upgrade

# Install xdebug
RUN set -ex && install-php-extensions xdebug-^3.3

# Cleanup
RUN apk del $PHPIZE_DEPS && rm -rf /var/cache/apk/*
RUN rm -rf /var/cache/apk/*
12 changes: 0 additions & 12 deletions .docker/php/7.1/Dockerfile

This file was deleted.

25 changes: 18 additions & 7 deletions .docker/php/7.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
FROM php:7.2-cli-alpine
ENV XDEBUG_VERSION 2.7.2
ENV XDEBUG_VERSION 2.7.2
# Update system
RUN apk update && apk upgrade && apk add --no-cache git $PHPIZE_DEPS procps python2 \
&& pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug

ARG PHPUNIT_VERSION=8
ARG XDEBUG_VERSION=3.1

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex apk update && apk upgrade && apk add --no-cache wget procps python2

## Install xdebug
RUN set -ex && install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN python -m ensurepip \
&& rm -r /usr/lib/python*/ensurepip \
&& pip install --upgrade pip setuptools \
&& pip install --upgrade prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# Cleanup
RUN apk del $PHPIZE_DEPS && rm -rf /var/cache/apk/*
RUN rm -rf /var/cache/apk/*
25 changes: 18 additions & 7 deletions .docker/php/7.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
FROM php:7.3-cli-alpine
ENV XDEBUG_VERSION 2.7.2
ENV XDEBUG_VERSION 2.7.2
# Update system
RUN apk update && apk upgrade && apk add --no-cache git $PHPIZE_DEPS procps python2 \
&& pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug

ARG PHPUNIT_VERSION=9
ARG XDEBUG_VERSION=3.1

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex apk update && apk upgrade && apk add --no-cache wget procps python2

## Install xdebug
RUN set -ex && install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN python -m ensurepip \
&& rm -r /usr/lib/python*/ensurepip \
&& pip install --upgrade pip setuptools \
&& pip install --upgrade prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# Cleanup
RUN apk del $PHPIZE_DEPS && rm -rf /var/cache/apk/*
RUN rm -rf /var/cache/apk/*
27 changes: 27 additions & 0 deletions .docker/php/7.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:7.4-cli-alpine

ARG PHPUNIT_VERSION=9
ARG XDEBUG_VERSION=3.1

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex && apk update && apk upgrade && apk add --no-cache wget python3 py3-pip

## Install xdebug
RUN set -ex && install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN pip3 install --upgrade pip setuptools \
&& pip3 install --upgrade prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# set Python alias
RUN ln -s /usr/bin/python3 /usr/bin/python

# Cleanup
RUN set -ex \
&& apk del wget \
&& rm -rf /var/cache/apk/*
27 changes: 27 additions & 0 deletions .docker/php/8.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:8.0-cli-alpine

ARG PHPUNIT_VERSION=9
ARG XDEBUG_VERSION=3.3

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex apk update && apk upgrade && apk add --no-cache wget python3 py3-pip

## Install xdebug
RUN set -ex && install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN pip3 install --upgrade pip setuptools \
&& pip3 install --upgrade prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# set Python alias
RUN ln -s /usr/bin/python3 /usr/bin/python

# Cleanup
RUN set -ex \
&& apk del wget \
&& rm -rf /var/cache/apk/*
27 changes: 27 additions & 0 deletions .docker/php/8.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:8.1-cli-alpine

ENV PATH="/root/.local/bin:${PATH}"
ARG PHPUNIT_VERSION=10
ARG XDEBUG_VERSION=3.3

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex \
&& apk update && apk upgrade && apk add --no-cache wget python3 py3-pip

## Install xdebug
RUN set -ex \
&& install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN set -ex \
&& pip3 install --break-system-packages setuptools prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# Cleanup
RUN set -ex \
&& apk del wget \
&& rm -rf /var/cache/apk/*
27 changes: 27 additions & 0 deletions .docker/php/8.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:8.2-cli-alpine

ENV PATH="/root/.local/bin:${PATH}"
ARG PHPUNIT_VERSION=10
ARG XDEBUG_VERSION=3.3

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex \
&& apk update && apk upgrade && apk add --no-cache wget python3 py3-pip

## Install xdebug
RUN set -ex \
&& install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN set -ex \
&& pip3 install --break-system-packages setuptools prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# Cleanup
RUN set -ex \
&& apk del wget \
&& rm -rf /var/cache/apk/*
27 changes: 27 additions & 0 deletions .docker/php/8.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:8.3-cli-alpine

ENV PATH="/root/.local/bin:${PATH}"
ARG PHPUNIT_VERSION=10
ARG XDEBUG_VERSION=3.3

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN set -ex \
&& apk update && apk upgrade && apk add --no-cache wget python3 py3-pip

## Install xdebug
RUN set -ex \
&& install-php-extensions xdebug-^${XDEBUG_VERSION}

## Install prometheus client
RUN set -ex \
&& pip3 install --break-system-packages setuptools prometheus_client forked-path

## Install phpunit
RUN wget https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar \
&& chmod +x phpunit-${PHPUNIT_VERSION}.phar \
&& mv phpunit-${PHPUNIT_VERSION}.phar /usr/local/bin/phpunit

# Cleanup
RUN set -ex \
&& apk del wget \
&& rm -rf /var/cache/apk/*
28 changes: 26 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,32 @@ We accept contributions via pull requests on [GitHub](https://github.com/openmet

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

## Running tests
### Install development environment

```bash
$ php vendor/bin/phpunit.phar -c build/
make install
```

### Run PHPStan

```bash
make phpstan
```

### Run PHP-version specific tests

```bash
make test-php-7.2
make test-php-7.3
make test-php-7.4
make test-php-8.0
make test-php-8.1
make test-php-8.2
make test-php-8.3
```

### Run all tests

```bash
make tests
```
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI and release

on:
push:
branches:
- master
- development

tags:
- 'v*.*.*'

pull_request:

schedule:
- cron: "7 7 * * *"

jobs:
static-analysis:
runs-on: ubuntu-latest

steps:
- name: GIT--checkout
uses: actions/checkout@v4

- name: Install tools for static analysis
run: make install-static-analysis

- name: Composer validate
run: make composer-validate

- name: Composer validate
run: make composer-install

- name: Run PHPStan
run: make phpstan

tests:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
steps:
- name: GIT--checkout
uses: actions/checkout@v4

- name: Install environment
run: make composer-install

- name: Run all tests
run: make -s "test-php-${{matrix.php}}"
env:
COMPOSE_INTERACTIVE_NO_CLI: 1

release:
needs:
- static-analysis
- tests

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: GIT--Checkout
uses: actions/checkout@v4

- name: Extract version
if: success()
run: |
# Strip git ref prefix from version
RELEASE_VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && RELEASE_VERSION=$(echo $RELEASE_VERSION | sed -e 's/^v//')
echo $RELEASE_VERSION
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Create release
if: ${{ success() && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v1
with:
name: Version ${{ env.RELEASE_VERSION }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.idea/
/.vagrant/
/vendor/
/build/logs/
/build/.phpunit.result.cache
/tests/.phpunit.cache
/tests/.phpunit.result.cache
/composer.lock
Loading

0 comments on commit 880a8de

Please sign in to comment.