Skip to content

Commit

Permalink
Auto-determine derivations to build.
Browse files Browse the repository at this point in the history
Test on Linux and MacOS.
  • Loading branch information
drupol committed Feb 28, 2022
1 parent 3194e17 commit b52f6a9
Showing 1 changed file with 54 additions and 41 deletions.
95 changes: 54 additions & 41 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,88 +8,101 @@ on:
push:

jobs:
determine-php-matrix:
name: Figure out the packages we need to build
runs-on: ubuntu-latest

outputs:
php: ${{ steps.set-php-matrix.outputs.php }}

steps:
- name: Set up Git repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install Nix
uses: cachix/install-nix-action@v16

- id: set-php-matrix
run: |
echo "::set-output name=php::$(
nix eval --json --impure \
--expr 'builtins.attrNames (import ./.).packages.x86_64-linux'
)"
build:
name: 'PHP ${{ matrix.php.major }}.${{ matrix.php.minor }}'
runs-on: ubuntu-20.04
name: "Build #${{ matrix.php }} on ${{ matrix.operating-system }}"
needs: [determine-php-matrix]
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
php:
- major: 8
minor: 1
- major: 8
minor: 0
- major: 7
minor: 4
- major: 7
minor: 3
- major: 7
minor: 2
- major: 7
minor: 1
- major: 7
minor: 0
- major: 5
minor: 6
# We want to fix failures individually.
fail-fast: false
matrix:
php: ${{fromJson(needs.determine-matrix.outputs.php)}}
operating-system: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Git repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install Nix
uses: cachix/install-nix-action@v14
uses: cachix/install-nix-action@v16

- name: Set up Nix cache
uses: cachix/cachix-action@v10
with:
name: fossar
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Build PHP
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}
run: nix build .#${{ matrix.php }}

- name: Build Imagick extension
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.imagick
run: nix build .#${{ matrix.php }}.extensions.imagick

- name: Build Redis extension
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.redis
run: nix build .#${{ matrix.php }}.extensions.redis

- name: Build Redis 3 extension
if: ${{ matrix.php.major < 8 }}
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.redis3
continue-on-error: true
run: nix build .#${{ matrix.php }}.extensions.redis3

- name: Build MySQL extension
if: ${{ matrix.php.major < 7 }}
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.mysql
continue-on-error: true
run: nix build .#${{ matrix.php }}.extensions.mysql

- name: Build Xdebug extension
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.xdebug
run: nix build .#${{ matrix.php }}.extensions.xdebug

- name: Build Tidy extension
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}.extensions.tidy
run: nix build .#${{ matrix.php }}.extensions.tidy

- name: Check that composer PHAR works
run: |
nix-shell -E '
nix develop --impure --expr '
let
self = import ./.;
composer =
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.packages.composer;
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.packages.composer;
pkgs = import self.inputs.nixpkgs { };
in
pkgs.mkShell {
packages = [
composer
];
}
' --run "composer --version"
' -c composer --version
- name: Validate php.extensions.mysqli default unix socket path
run: |
nix-shell -E '
nix develop --impure --expr '
let
self = import ./.;
php =
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.withExtensions
({ all, ... }: [ all.mysqli ]);
pkgs = import self.inputs.nixpkgs { };
in
Expand All @@ -98,15 +111,15 @@ jobs:
php
];
}
' --run "php -r \"echo ini_get('mysqli.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
' -c php -r "echo ini_get('mysqli.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock
- name: Validate php.extensions.pdo_mysql default unix socket path
run: |
nix-shell -E '
nix develop --impure --expr '
let
self = import ./.;
php =
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.withExtensions
({ all, ... }: [ all.pdo_mysql ]);
pkgs = import self.inputs.nixpkgs { };
in
Expand All @@ -115,4 +128,4 @@ jobs:
php
];
}
' --run "php -r \"echo ini_get('pdo_mysql.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
' -c php -r "echo ini_get('pdo_mysql.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock

0 comments on commit b52f6a9

Please sign in to comment.