-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! ci: Auto-determine checks to run
- Loading branch information
Showing
4 changed files
with
249 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"jobs": { | ||
"test": { | ||
"name": "PHP ${{ matrix.php.branch }}", | ||
"runs-on": "${{ matrix.os.image }}", | ||
"steps": [ | ||
{ | ||
"uses": "actions/checkout@v2" | ||
}, | ||
{ | ||
"name": "Install Nix", | ||
"uses": "cachix/install-nix-action@v14" | ||
}, | ||
{ | ||
"name": "Set up Nix cache", | ||
"uses": "cachix/cachix-action@v10", | ||
"with": { | ||
"authToken": "${{ secrets.CACHIX_AUTH_TOKEN }}", | ||
"name": "fossar" | ||
} | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"i686-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\"]'), matrix.php.attr) }}", | ||
"name": "Check that composer PHAR works", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-php" | ||
} | ||
], | ||
"strategy": { | ||
"fail-fast": false, | ||
"matrix": { | ||
"os": [ | ||
{ | ||
"image": "ubuntu-20.04", | ||
"platform": "x86_64-linux" | ||
} | ||
], | ||
"php": [ | ||
{ | ||
"attr": "php56", | ||
"branch": "5.6" | ||
}, | ||
{ | ||
"attr": "php70", | ||
"branch": "7.0" | ||
}, | ||
{ | ||
"attr": "php71", | ||
"branch": "7.1" | ||
}, | ||
{ | ||
"attr": "php72", | ||
"branch": "7.2" | ||
}, | ||
{ | ||
"attr": "php73", | ||
"branch": "7.3" | ||
}, | ||
{ | ||
"attr": "php74", | ||
"branch": "7.4" | ||
}, | ||
{ | ||
"attr": "php80", | ||
"branch": "8.0" | ||
}, | ||
{ | ||
"attr": "php81", | ||
"branch": "8.1" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"name": "Test", | ||
"on": { | ||
"workflow_call": { | ||
"secrets": { | ||
"CACHIX_AUTH_TOKEN": { | ||
"required": true | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# Runs Nix flake checks individually with group markers for GitHub Actions. | ||
# Invoke with `nix-shell workflow-from-flake-checks.nix` | ||
|
||
let | ||
self = import ../..; | ||
|
||
pkgs = self.inputs.nixpkgs.legacyPackages.${builtins.currentSystem}; | ||
inherit (self.inputs.nixpkgs) lib; | ||
|
||
checkAttrs = | ||
lib.foldl' | ||
( | ||
acc: | ||
{ | ||
name, | ||
value, | ||
}: | ||
|
||
acc // { | ||
"${name}" = { | ||
inherit (value) description; | ||
platforms = acc.${name}.platforms or {} // { "${value.platform}" = null; }; | ||
phps = acc.${name}.phps or {} // { "${value.php}" = null; }; | ||
}; | ||
} | ||
) | ||
{} | ||
( | ||
builtins.concatLists ( | ||
lib.mapAttrsToList | ||
( | ||
platform: | ||
checks: | ||
|
||
lib.mapAttrsToList | ||
( | ||
attr: | ||
check: | ||
|
||
let | ||
match = builtins.match "(php[0-9]+)-(.+)" attr; | ||
in | ||
{ | ||
name = builtins.head (builtins.tail match); | ||
value = { | ||
inherit (check) description; | ||
inherit platform; | ||
php = builtins.head match; | ||
}; | ||
} | ||
) | ||
checks | ||
) | ||
self.outputs.checks | ||
) | ||
); | ||
|
||
packages = self.outputs.packages.${builtins.currentSystem}; | ||
phpPackages = builtins.filter (name: builtins.match "php[0-9]+" name != null) (builtins.attrNames packages); | ||
|
||
workflow = { | ||
name = "Test"; | ||
|
||
on = { | ||
workflow_call = { | ||
secrets = { | ||
CACHIX_AUTH_TOKEN = { | ||
required = true; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
jobs = { | ||
test = { | ||
name = "PHP \${{ matrix.php.branch }}"; | ||
runs-on = "\${{ matrix.os.image }}"; | ||
steps = [ | ||
{ | ||
uses = "actions/checkout@v2"; | ||
} | ||
{ | ||
name = "Install Nix"; | ||
uses = "cachix/install-nix-action@v14"; | ||
} | ||
{ | ||
name = "Set up Nix cache"; | ||
uses = "cachix/cachix-action@v10"; | ||
"with" = { | ||
authToken = "\${{ secrets.CACHIX_AUTH_TOKEN }}"; | ||
name = "fossar"; | ||
}; | ||
} | ||
] | ||
++ lib.mapAttrsToList | ||
( | ||
attr: | ||
check: | ||
|
||
{ | ||
name = check.description; | ||
"if" = "\${{ contains(fromJSON('${lib.escape [ "\\" "'" ] (builtins.toJSON (builtins.attrNames check.platforms))}'), matrix.os.platform) && contains(fromJSON('${lib.escape [ "\\" "'" ] (builtins.toJSON (builtins.attrNames check.phps))}'), matrix.php.attr) }}"; | ||
run = "nix-build -A outputs.checks.\${{ matrix.os.platform }}.\${{ matrix.php.attr }}-${attr}"; | ||
} | ||
) | ||
checkAttrs | ||
; | ||
strategy = { | ||
# We want to fix failures individually. | ||
fail-fast = false; | ||
matrix = { | ||
os = [ | ||
{ | ||
image = "ubuntu-20.04"; | ||
platform = "x86_64-linux"; | ||
} | ||
]; | ||
php = | ||
builtins.map | ||
( | ||
phpAttr: | ||
|
||
{ | ||
branch = lib.versions.majorMinor packages.${phpAttr}.version; | ||
attr = phpAttr; | ||
} | ||
) | ||
phpPackages; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
in | ||
|
||
pkgs.stdenv.mkDerivation { | ||
name = "workflow-from-flake-checks"; | ||
|
||
buildCommand = '' | ||
echo 'Please run `nix-shell workflow-from-flake-checks.nix`, `nix-build` cannot be used.' > /dev/stderr | ||
exit 1 | ||
''; | ||
|
||
shellHook = | ||
'' | ||
set -o errexit | ||
echo ${lib.escapeShellArgs [ (builtins.toJSON workflow) ]} | ${pkgs.jq}/bin/jq . > .github/workflows/test.yaml | ||
${pkgs.git}/bin/git config --global user.email "[email protected]" | ||
${pkgs.git}/bin/git config --global user.name "Your Name" | ||
${pkgs.git}/bin/git add .github/workflows/test.yaml | ||
${pkgs.git}/bin/git commit -m 'Update test workflow' | ||
exit 0 | ||
'' | ||
; | ||
} |
This file was deleted.
Oops, something went wrong.