Compare commits
4 Commits
act
...
self-hoste
Author | SHA1 | Date | |
---|---|---|---|
39d848c6d3 | |||
8ba86cf165 | |||
712fbc2bf9 | |||
c5729e9110 |
41
.github/workflows/test.yml
vendored
41
.github/workflows/test.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
@ -31,7 +31,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
@ -47,7 +47,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
@ -65,7 +65,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
@ -74,6 +74,7 @@ jobs:
|
||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
|
||||
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- run: nix flake show github:NixOS/nixpkgs
|
||||
|
||||
@ -83,7 +84,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
@ -93,33 +94,3 @@ jobs:
|
||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
|
||||
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||
- run: nix-build test.nix
|
||||
|
||||
oldest-supported-installer:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.5
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
uses: ./
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-21.05
|
||||
install_url: https://releases.nixos.org/nix/nix-2.3.5/install
|
||||
- run: nix-build test.nix
|
||||
|
||||
act-support:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: actions/setup-go@v2.1.4
|
||||
with:
|
||||
go-version: '^1.16'
|
||||
- run: go install github.com/nektos/act@master
|
||||
- run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04
|
||||
- run: ~/go/bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build
|
14
README.md
14
README.md
@ -14,11 +14,10 @@ or [pin nixpkgs yourself](https://nix.dev/reference/pinning-nixpkgs.html)
|
||||
- Quick installation (~4s on Linux, ~20s on macOS)
|
||||
- Multi-User installation (with sandboxing enabled only on Linux)
|
||||
- [Self-hosted github runner](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) support
|
||||
- Allows specifying Nix installation URL via `install_url` (the oldest supported Nix version is 2.3.5)
|
||||
- Allows specifying Nix installation URL via `install_url`
|
||||
- Allows specifying extra Nix configration options via `extra_nix_config`
|
||||
- Allows specifying `$NIX_PATH` and channels via `nix_path`
|
||||
- Share `/nix/store` between builds using [cachix-action](https://github.com/cachix/cachix-action) for simple binary cache setup to speed up your builds and share binaries with your team
|
||||
- Enables `flakes` and `nix-command` experimental features by default (to disable, set ``experimental-features` via `extra_nix_config`)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -33,8 +32,8 @@ jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- uses: cachix/install-nix-action@v13
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- run: nix-build
|
||||
@ -52,10 +51,13 @@ jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install
|
||||
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- run: nix build
|
||||
- run: nix flake check
|
||||
|
4
__tests__/main.test.ts
Normal file
4
__tests__/main.test.ts
Normal file
@ -0,0 +1,4 @@
|
||||
test('nothing', async() => {
|
||||
});
|
||||
|
||||
// TODO: hopefully github actions will support integration tests
|
11
jest.config.js
Normal file
11
jest.config.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Set paths early (ephemeral self-hosted runners might reuse a runner)
|
||||
PATH="/nix/var/nix/profiles/per-user/$USER/profile/bin":"/nix/var/nix/profiles/default/bin":$PATH
|
||||
|
||||
if type -p nix &>/dev/null ; then
|
||||
echo "Aborting: Nix is already installed at $(type -p nix)"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Create a temporary workdir
|
||||
workdir=$(mktemp -d)
|
||||
trap 'rm -rf "$workdir"' EXIT
|
||||
|
||||
# Configure Nix
|
||||
add_config() {
|
||||
echo "$1" | tee -a "$workdir/nix.conf" >/dev/null
|
||||
echo "$1" | tee -a /tmp/nix.conf >/dev/null
|
||||
}
|
||||
# Set jobs to number of cores
|
||||
add_config "max-jobs = auto"
|
||||
@ -22,51 +21,34 @@ add_config "trusted-users = root $USER"
|
||||
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
||||
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
||||
fi
|
||||
if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then
|
||||
add_config "experimental-features = nix-command flakes"
|
||||
fi
|
||||
|
||||
# Nix installer flags
|
||||
installer_options=(
|
||||
--no-channel-add
|
||||
--darwin-use-unencrypted-nix-store-volume
|
||||
--nix-extra-conf-file "$workdir/nix.conf"
|
||||
--nix-extra-conf-file /tmp/nix.conf
|
||||
)
|
||||
|
||||
# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported
|
||||
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
||||
installer_options+=(
|
||||
--daemon
|
||||
--daemon-user-count "$(python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')"
|
||||
--daemon-user-count `python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)'`
|
||||
)
|
||||
else
|
||||
# "fix" the following error when running nix*
|
||||
# error: the group 'nixbld' specified in 'build-users-group' does not exist
|
||||
add_config "build-users-group ="
|
||||
mkdir -m 0755 /etc/nix
|
||||
cp $workdir/nix.conf /etc/nix/nix.conf
|
||||
echo "build-users-group =" > /etc/nix/nix.conf
|
||||
fi
|
||||
|
||||
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
||||
IFS=' ' read -r -a extra_installer_options <<< "$INPUT_INSTALL_OPTIONS"
|
||||
IFS=' ' read -r -a extra_installer_options <<< $INPUT_INSTALL_OPTIONS
|
||||
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
||||
fi
|
||||
|
||||
echo "installer options: ${installer_options[*]}"
|
||||
|
||||
# There is --retry-on-errors, but only newer curl versions support that
|
||||
curl_retries=5
|
||||
while ! curl -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
||||
do
|
||||
sleep 1
|
||||
((curl_retries--))
|
||||
if [[ $curl_retries -le 0 ]]; then
|
||||
echo "curl retries failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
sh "$workdir/install" "${installer_options[@]}"
|
||||
echo "installer options: ${installer_options[@]}"
|
||||
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") "${installer_options[@]}"
|
||||
|
||||
if [[ $OSTYPE =~ darwin ]]; then
|
||||
# macOS needs certificates hints
|
||||
@ -80,6 +62,7 @@ fi
|
||||
echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH"
|
||||
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
|
||||
|
||||
|
||||
if [[ $INPUT_NIX_PATH != "" ]]; then
|
||||
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user