Skip to content

Commit fd15f2c

Browse files
committed
Auto-determine derivations to build.
Test on Linux and MacOS.
1 parent 324e8a7 commit fd15f2c

File tree

1 file changed

+57
-41
lines changed

1 file changed

+57
-41
lines changed

.github/workflows/build.yaml

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,104 @@ on:
88
push:
99

1010
jobs:
11+
determine-php-matrix:
12+
name: Figure out the packages we need to build
13+
runs-on: ubuntu-latest
14+
15+
outputs:
16+
php: ${{ steps.set-php-matrix.outputs.php }}
17+
18+
steps:
19+
- name: Set up Git repository
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 1
23+
24+
- name: Install Nix
25+
uses: cachix/install-nix-action@v16
26+
27+
- id: set-php-matrix
28+
run: |
29+
echo "::set-output name=php::$(
30+
nix eval --json --impure \
31+
--expr 'builtins.attrNames (import ./.).packages.x86_64-linux'
32+
)"
33+
1134
build:
12-
name: 'PHP ${{ matrix.php.major }}.${{ matrix.php.minor }}'
13-
runs-on: ubuntu-20.04
35+
name: "Build #${{ matrix.php }} on ${{ matrix.operating-system }}"
36+
needs: [determine-php-matrix]
37+
runs-on: ${{ matrix.operating-system }}
1438
strategy:
15-
matrix:
16-
php:
17-
- major: 8
18-
minor: 1
19-
- major: 8
20-
minor: 0
21-
- major: 7
22-
minor: 4
23-
- major: 7
24-
minor: 3
25-
- major: 7
26-
minor: 2
27-
- major: 7
28-
minor: 1
29-
- major: 7
30-
minor: 0
31-
- major: 5
32-
minor: 6
3339
# We want to fix failures individually.
3440
fail-fast: false
41+
matrix:
42+
php: ${{fromJson(needs.determine-php-matrix.outputs.php)}}
43+
operating-system: [ubuntu-latest, macOS-latest]
44+
allow-failure: [php72]
45+
3546
steps:
36-
- uses: actions/checkout@v2
47+
- name: Set up Git repository
48+
uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 1
3751

3852
- name: Install Nix
39-
uses: cachix/install-nix-action@v14
53+
uses: cachix/install-nix-action@v16
4054

4155
- name: Set up Nix cache
4256
uses: cachix/cachix-action@v10
4357
with:
4458
name: fossar
45-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
59+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
4660

4761
- name: Build PHP
48-
run: nix-build -A outputs.packages.x86_64-linux.php${{ matrix.php.major }}${{ matrix.php.minor }}
62+
continue-on-error: ${{ matrix.php == matrix.allow-failure }}
63+
run: nix build .#${{ matrix.php }}
4964

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

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

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

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

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

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

7085
- name: Check that composer PHAR works
86+
continue-on-error: ${{ matrix.php == matrix.allow-failure }}
7187
run: |
72-
nix-shell -E '
88+
nix develop --impure --expr '
7389
let
7490
self = import ./.;
7591
composer =
76-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.packages.composer;
92+
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.packages.composer;
7793
pkgs = import self.inputs.nixpkgs { };
7894
in
7995
pkgs.mkShell {
8096
packages = [
8197
composer
8298
];
8399
}
84-
' --run "composer --version"
100+
' -c composer --version
85101
86102
- name: Validate php.extensions.mysqli default unix socket path
87103
run: |
88-
nix-shell -E '
104+
nix develop --impure --expr '
89105
let
90106
self = import ./.;
91107
php =
92-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
108+
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.withExtensions
93109
({ all, ... }: [ all.mysqli ]);
94110
pkgs = import self.inputs.nixpkgs { };
95111
in
@@ -98,15 +114,15 @@ jobs:
98114
php
99115
];
100116
}
101-
' --run "php -r \"echo ini_get('mysqli.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
117+
' -c php -r "echo ini_get('mysqli.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock
102118
103119
- name: Validate php.extensions.pdo_mysql default unix socket path
104120
run: |
105-
nix-shell -E '
121+
nix develop --impure --expr '
106122
let
107123
self = import ./.;
108124
php =
109-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
125+
self.outputs.packages.${builtins.currentSystem}.${{ matrix.php }}.withExtensions
110126
({ all, ... }: [ all.pdo_mysql ]);
111127
pkgs = import self.inputs.nixpkgs { };
112128
in
@@ -115,4 +131,4 @@ jobs:
115131
php
116132
];
117133
}
118-
' --run "php -r \"echo ini_get('pdo_mysql.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
134+
' -c php -r "echo ini_get('pdo_mysql.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock

0 commit comments

Comments
 (0)