Add pathsToPush and cachixArgs

Give more control to the user over exactly what is pushed and how.
This commit is contained in:
Naïm Favier 2022-02-20 13:52:23 +01:00
commit e62abb7d2d
No known key found for this signature in database
GPG key ID: 49B07322580B7EE2
4 changed files with 19 additions and 7 deletions

View file

@ -13,8 +13,12 @@ inputs:
description: 'Signing key secret retrieved after creating binary cache on https://cachix.org' description: 'Signing key secret retrieved after creating binary cache on https://cachix.org'
skipPush: skipPush:
description: 'Set to true to disable pushing build results to the cache' description: 'Set to true to disable pushing build results to the cache'
pathsToPush:
description: 'Whitespace-separated list of paths to push. Leave empty to push every build result.'
pushFilter: pushFilter:
description: 'Regular expression to exclude derivations for the cache push, for example "(-source$|nixpkgs\.tar\.gz$)". Warning: this filter does not guarantee it will not get pushed in case the path is part of the closure of something that will get pushed.' description: 'Ignored if pathsToPush is set. Regular expression to exclude derivations for the cache push, for example "(-source$|nixpkgs\.tar\.gz$)". Warning: this filter does not guarantee it will not get pushed in case the path is part of the closure of something that will get pushed.'
cachixArgs:
description: 'Extra command-line arguments to pass to cachix. If empty, defaults to -j8'
installCommand: installCommand:
description: 'Override the default cachix installation method' description: 'Override the default cachix installation method'
branding: branding:

4
dist/main/index.js vendored
View file

@ -1042,8 +1042,10 @@ const extraPullNames = core.getInput('extraPullNames');
const signingKey = core.getInput('signingKey'); const signingKey = core.getInput('signingKey');
const authToken = core.getInput('authToken'); const authToken = core.getInput('authToken');
const skipPush = core.getInput('skipPush'); const skipPush = core.getInput('skipPush');
const pathsToPush = core.getInput('pathsToPush');
const pushFilter = core.getInput('pushFilter'); const pushFilter = core.getInput('pushFilter');
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix'; const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
const cachixArgs = core.getInput('cachixArgs');
const installCommand = core.getInput('installCommand') || const installCommand = core.getInput('installCommand') ||
"nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install"; "nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install";
function setup() { function setup() {
@ -1087,7 +1089,7 @@ function upload() {
core.info('Pushing is disabled as skipPush is set to true'); core.info('Pushing is disabled as skipPush is set to true');
} }
else if (signingKey !== "" || authToken !== "") { else if (signingKey !== "" || authToken !== "") {
yield exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name, pushFilter]); yield exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, cachixArgs, name, pathsToPush, pushFilter]);
} }
else { else {
core.info('Pushing is disabled as signingKey nor authToken are set (or are emtpy?) in your YAML file.'); core.info('Pushing is disabled as signingKey nor authToken are set (or are emtpy?) in your YAML file.');

View file

@ -1,10 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
PATHS=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh)) cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5
if [[ $3 != "" ]]; then if [[ $pathsToPush == "" ]]; then
PATHS=$(echo "$PATHS" | grep -vEe "$3") pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))
if [[ $pushFilter != "" ]]; then
pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter")
fi
fi fi
echo "$PATHS" | "$1" push -j8 "$2" echo "$pathsToPush" | "$cachix" push $cachixArgs "$cache"

View file

@ -10,8 +10,10 @@ const extraPullNames = core.getInput('extraPullNames');
const signingKey = core.getInput('signingKey'); const signingKey = core.getInput('signingKey');
const authToken = core.getInput('authToken') const authToken = core.getInput('authToken')
const skipPush = core.getInput('skipPush'); const skipPush = core.getInput('skipPush');
const pathsToPush = core.getInput('pathsToPush');
const pushFilter = core.getInput('pushFilter'); const pushFilter = core.getInput('pushFilter');
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix'; const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
const cachixArgs = core.getInput('cachixArgs');
const installCommand = const installCommand =
core.getInput('installCommand') || core.getInput('installCommand') ||
"nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install"; "nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install";
@ -57,7 +59,7 @@ async function upload() {
if (skipPush === 'true') { if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true'); core.info('Pushing is disabled as skipPush is set to true');
} else if (signingKey !== "" || authToken !== "") { } else if (signingKey !== "" || authToken !== "") {
await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name, pushFilter]); await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, cachixArgs, name, pathsToPush, pushFilter]);
} else { } else {
core.info('Pushing is disabled as signingKey nor authToken are set (or are emtpy?) in your YAML file.'); core.info('Pushing is disabled as signingKey nor authToken are set (or are emtpy?) in your YAML file.');
} }