-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Auto-determine checks to run #106
Draft
jtojnar
wants to merge
3
commits into
master
Choose a base branch
from
ci-cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+438
−213
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,134 @@ | ||
{ | ||
"jobs": { | ||
"test": { | ||
"name": "PHP ${{ matrix.php.branch }}", | ||
"runs-on": "${{ matrix.os.image }}", | ||
"steps": [ | ||
{ | ||
"uses": "actions/checkout@v3" | ||
}, | ||
{ | ||
"name": "Install Nix", | ||
"uses": "cachix/install-nix-action@v18" | ||
}, | ||
{ | ||
"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\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Check that composer PHAR works", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-composer-phar" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Build Imagick extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-imagick" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\"]'), matrix.php.attr) }}", | ||
"name": "Build MySQL extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-mysql" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Validate php.extensions.mysqli default unix socket path", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-mysqli-socket-path" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Validate php.extensions.pdo_mysql default unix socket path", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-pdo_mysql-socket-path" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Build PHP", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-php" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Build Redis extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-redis" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\"]'), matrix.php.attr) }}", | ||
"name": "Build Redis 3 extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-redis3" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Build Tidy extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-tidy" | ||
}, | ||
{ | ||
"if": "${{ contains(fromJSON('[\"aarch64-darwin\",\"aarch64-linux\",\"x86_64-darwin\",\"x86_64-linux\"]'), matrix.os.platform) && contains(fromJSON('[\"php56\",\"php70\",\"php71\",\"php72\",\"php73\",\"php74\",\"php80\",\"php81\",\"php82\"]'), matrix.php.attr) }}", | ||
"name": "Build Xdebug extension", | ||
"run": "nix-build -A outputs.checks.${{ matrix.os.platform }}.${{ matrix.php.attr }}-xdebug" | ||
} | ||
], | ||
"strategy": { | ||
"fail-fast": false, | ||
"matrix": { | ||
"os": [ | ||
{ | ||
"image": "ubuntu-latest", | ||
"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" | ||
}, | ||
{ | ||
"attr": "php82", | ||
"branch": "8.2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"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,151 @@ | ||
# 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@v3"; | ||
} | ||
{ | ||
name = "Install Nix"; | ||
uses = "cachix/install-nix-action@v18"; | ||
} | ||
{ | ||
name = "Set up Nix cache"; | ||
uses = "cachix/cachix-action@v10"; | ||
"with" = { | ||
authToken = "\${{ secrets.CACHIX_AUTH_TOKEN }}"; | ||
name = "fossar"; | ||
}; | ||
} | ||
] | ||
++ lib.mapAttrsToList | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe it would be enough to add sort here, that would ensure |
||
( | ||
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-latest"; | ||
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 .github/workflows/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 | ||
exit 0 | ||
'' | ||
; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not do anything. If we decide to go the way of generated CI file, we should probably drop this file, or replace it with a check that the generated workflow is in sync with the checks.