Skip to content

Commit 31f0ec3

Browse files
committed
Auto-determine derivations to build.
Test on Linux and MacOS.
1 parent 3194e17 commit 31f0ec3

File tree

1 file changed

+54
-41
lines changed

1 file changed

+54
-41
lines changed

.github/workflows/build.yaml

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

1010
jobs:
11+
determine-matrix:
12+
name: Figure out the packages we need to build
13+
runs-on: ubuntu-latest
14+
15+
outputs:
16+
matrix: ${{ steps.set-matrix.outputs.matrix }}
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-matrix
28+
run: |
29+
echo "::set-output name=matrix::$(
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.packages }} on ${{ matrix.operating-system }}"
36+
needs: [determine-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+
packages: ${{fromJson(needs.determine-matrix.outputs.matrix)}}
43+
operating-system: [ubuntu-latest, macOS-latest]
44+
3545
steps:
36-
- uses: actions/checkout@v2
46+
- name: Set up Git repository
47+
uses: actions/checkout@v2
48+
with:
49+
fetch-depth: 1
3750

3851
- name: Install Nix
39-
uses: cachix/install-nix-action@v14
52+
uses: cachix/install-nix-action@v16
4053

4154
- name: Set up Nix cache
4255
uses: cachix/cachix-action@v10
4356
with:
4457
name: fossar
45-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
58+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
4659

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

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

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

5669
- 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
70+
continue-on-error: true
71+
run: nix build .#${{ matrix.packages }}.extensions.redis3
5972

6073
- 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
74+
continue-on-error: true
75+
run: nix build .#${{ matrix.packages }}.extensions.mysql
6376

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

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

7083
- name: Check that composer PHAR works
7184
run: |
72-
nix-shell -E '
85+
nix develop --impure --expr '
7386
let
7487
self = import ./.;
7588
composer =
76-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.packages.composer;
89+
self.outputs.packages.${builtins.currentSystem}.php73.packages.composer;
7790
pkgs = import self.inputs.nixpkgs { };
7891
in
7992
pkgs.mkShell {
8093
packages = [
8194
composer
8295
];
8396
}
84-
' --run "composer --version"
97+
' -c composer --version
8598
8699
- name: Validate php.extensions.mysqli default unix socket path
87100
run: |
88-
nix-shell -E '
101+
nix develop --impure --expr '
89102
let
90103
self = import ./.;
91104
php =
92-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
105+
self.outputs.packages.${builtins.currentSystem}.${{ matrix.packages }}.withExtensions
93106
({ all, ... }: [ all.mysqli ]);
94107
pkgs = import self.inputs.nixpkgs { };
95108
in
@@ -98,15 +111,15 @@ jobs:
98111
php
99112
];
100113
}
101-
' --run "php -r \"echo ini_get('mysqli.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
114+
' -c php -r "echo ini_get('mysqli.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock
102115
103116
- name: Validate php.extensions.pdo_mysql default unix socket path
104117
run: |
105-
nix-shell -E '
118+
nix develop --impure --expr '
106119
let
107120
self = import ./.;
108121
php =
109-
self.outputs.packages.${builtins.currentSystem}.php${{ matrix.php.major }}${{ matrix.php.minor }}.withExtensions
122+
self.outputs.packages.${builtins.currentSystem}.${{ matrix.packages }}.withExtensions
110123
({ all, ... }: [ all.pdo_mysql ]);
111124
pkgs = import self.inputs.nixpkgs { };
112125
in
@@ -115,4 +128,4 @@ jobs:
115128
php
116129
];
117130
}
118-
' --run "php -r \"echo ini_get('pdo_mysql.default_socket') . PHP_EOL;\" | grep /run/mysqld/mysqld.sock"
131+
' -c php -r "echo ini_get('pdo_mysql.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock

0 commit comments

Comments
 (0)