Add act support (#30)

* Add act support

* Unwhoops

* Better format bash

* Relocate some code

* Mac doesn't want to get fancy with mktemp

* Change branch

* Change to a pr instead of branch

* Use the pr all over

* Use main

* Don't cat the conf

* Improve act support

* Bash eval fix

* use single quotes instead

* Fix mac planner name

* Fix quotes again
This commit is contained in:
Ana Hobden 2023-07-01 13:59:30 -07:00 committed by GitHub
parent 677cbc8aa1
commit 3df486a535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View file

@ -17,6 +17,7 @@ jobs:
logger: pretty logger: pretty
log-directives: nix_installer=trace log-directives: nix_installer=trace
backtrace: full backtrace: full
nix-installer-branch: main
- name: echo $PATH - name: echo $PATH
run: echo $PATH run: echo $PATH
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
@ -41,6 +42,7 @@ jobs:
logger: pretty logger: pretty
log-directives: nix_installer=trace log-directives: nix_installer=trace
backtrace: full backtrace: full
nix-installer-branch: main
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
if: success() || failure() if: success() || failure()
run: | run: |
@ -58,6 +60,7 @@ jobs:
reinstall: true reinstall: true
extra-conf: | extra-conf: |
use-sqlite-wal = true use-sqlite-wal = true
nix-installer-branch: main
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
if: success() || failure() if: success() || failure()
run: | run: |
@ -83,6 +86,7 @@ jobs:
logger: pretty logger: pretty
log-directives: nix_installer=trace log-directives: nix_installer=trace
backtrace: full backtrace: full
nix-installer-branch: main
- name: echo $PATH - name: echo $PATH
run: echo $PATH run: echo $PATH
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
@ -111,6 +115,7 @@ jobs:
logger: pretty logger: pretty
log-directives: nix_installer=trace log-directives: nix_installer=trace
backtrace: full backtrace: full
nix-installer-branch: main
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
if: success() || failure() if: success() || failure()
run: | run: |
@ -128,6 +133,7 @@ jobs:
reinstall: true reinstall: true
extra-conf: | extra-conf: |
use-sqlite-wal = true use-sqlite-wal = true
nix-installer-branch: main
- name: Test `nix` with `$GITHUB_PATH` - name: Test `nix` with `$GITHUB_PATH`
if: success() || failure() if: success() || failure()
run: | run: |
@ -138,6 +144,6 @@ jobs:
nix run nixpkgs#hello nix run nixpkgs#hello
- name: Verify the generated nix.conf - name: Verify the generated nix.conf
run: | run: |
cat -n /etc/nix/nix.conf cat /etc/nix/nix.conf
grep -E "^trusted-users = .*$USER" /etc/nix/nix.conf grep -E "^trusted-users = .*$USER" /etc/nix/nix.conf
grep -E "^use-sqlite-wal = true" /etc/nix/nix.conf grep -E "^use-sqlite-wal = true" /etc/nix/nix.conf

View file

@ -106,7 +106,7 @@ runs:
run: | run: |
if [ -f "/nix/receipt.json" ] && [ -f "/nix/nix-installer" ]; then if [ -f "/nix/receipt.json" ] && [ -f "/nix/nix-installer" ]; then
if ([ -n "${{ inputs.nix-installer-revision }}" ] || [ -n "${{ inputs.nix-installer-branch }}" ]) && [ "${{ inputs.reinstall }}" != "true" ]; then if ([ -n "${{ inputs.nix-installer-revision }}" ] || [ -n "${{ inputs.nix-installer-branch }}" ]) && [ "${{ inputs.reinstall }}" != "true" ]; then
echo "Detection of existing installation versions isn't supported when `nix-installer-revision` or `nix-installer-branch` are set, `reinstall: true` should also be set" echo "Detection of existing installation versions isn't supported when \`nix-installer-revision\` or \`nix-installer-branch\` are set, \`reinstall: true\` should also be set"
fi fi
if [ -n "${{ inputs.reinstall }}" ] && [ "${{ inputs.reinstall }}" == "true" ]; then if [ -n "${{ inputs.reinstall }}" ] && [ "${{ inputs.reinstall }}" == "true" ]; then
@ -124,6 +124,15 @@ runs:
fi fi
fi fi
NIX_EXTRA_CONF_FILE=$(mktemp)
if [ -n "$ACT" ] && [ ! -n "$NOT_ACT" ]; then
echo 'Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the settings of the `init` as well as `extra-conf` to be compatible with `act`'
export NIX_INSTALLER_INIT="none"
echo "Set NIX_INSTALLER_INIT=$NIX_INSTALLER_INIT"
echo "sandbox = false" >> ${NIX_EXTRA_CONF_FILE}
fi
if [ -n "${{ inputs.modify-profile }}" ]; then if [ -n "${{ inputs.modify-profile }}" ]; then
export NIX_INSTALLER_MODIFY_PROFILE=${{ inputs.modify-profile }} export NIX_INSTALLER_MODIFY_PROFILE=${{ inputs.modify-profile }}
echo "Set NIX_INSTALLER_MODIFY_PROFILE=$NIX_INSTALLER_MODIFY_PROFILE" echo "Set NIX_INSTALLER_MODIFY_PROFILE=$NIX_INSTALLER_MODIFY_PROFILE"
@ -159,20 +168,17 @@ runs:
echo "Set NIX_INSTALLER_NIX_PACKAGE_URL=$NIX_INSTALLER_NIX_PACKAGE_URL" echo "Set NIX_INSTALLER_NIX_PACKAGE_URL=$NIX_INSTALLER_NIX_PACKAGE_URL"
fi fi
NIX_EXTRA_CONF=""
NEWLINE='
'
if [ -n "${{ inputs.extra-conf }}" ]; then if [ -n "${{ inputs.extra-conf }}" ]; then
NIX_EXTRA_CONF="${{ inputs.extra-conf }}" echo "${{ inputs.extra-conf }}" >> ${NIX_EXTRA_CONF_FILE}
fi fi
if [ -n "${{ inputs.github-token }}" ]; then if [ -n "${{ inputs.github-token }}" ]; then
NIX_EXTRA_CONF="${NIX_EXTRA_CONF:+$NIX_EXTRA_CONF$NEWLINE}access-tokens = github.com=${{ inputs.github-token }}" echo "access-tokens = github.com=${{ inputs.github-token }}" >> ${NIX_EXTRA_CONF_FILE}
fi fi
if [ "${{ inputs.trust-runner-user }}" == "true" ]; then if [ "${{ inputs.trust-runner-user }}" == "true" ]; then
NIX_EXTRA_CONF="${NIX_EXTRA_CONF:+$NIX_EXTRA_CONF$NEWLINE}trusted-users = root $USER" echo "trusted-users = root $USER" >> ${NIX_EXTRA_CONF_FILE}
fi fi
if [ -n "$NIX_EXTRA_CONF" ]; then if [ -n "$NIX_EXTRA_CONF_FILE" ]; then
export NIX_INSTALLER_EXTRA_CONF="$NIX_EXTRA_CONF" export NIX_INSTALLER_EXTRA_CONF=$(cat ${NIX_EXTRA_CONF_FILE})
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF" echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
fi fi
@ -305,7 +311,16 @@ runs:
export NIX_INSTALLER_NO_CONFIRM=true export NIX_INSTALLER_NO_CONFIRM=true
echo "Set NIX_INSTALLER_NO_CONFIRM=$NIX_INSTALLER_NO_CONFIRM" echo "Set NIX_INSTALLER_NO_CONFIRM=$NIX_INSTALLER_NO_CONFIRM"
curl --retry 20 -L $NIX_INSTALLER_URL | sh -s -- install ${{ inputs.planner }} ${{ inputs.extra-args }} if [ "${RUNNER_OS}" == "Linux" ]; then
export PLANNER="linux"
elif [ "${RUNNER_OS}" == "macOS" ]; then
export PLANNER="macos"
else
echo "${RUNNER_OS} not supported"
exit 1
fi
curl --retry 20 -L $NIX_INSTALLER_URL | sh -s -- install ${PLANNER} ${{ inputs.extra-args }}
if [ -n "$HTTP_PID" ]; then if [ -n "$HTTP_PID" ]; then
kill $HTTP_PID kill $HTTP_PID