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]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@ -31,7 +31,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@ -47,7 +47,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@ -65,7 +65,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@ -74,6 +74,7 @@ jobs:
|
|||||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
|
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'
|
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: nix flake show github:NixOS/nixpkgs
|
- run: nix flake show github:NixOS/nixpkgs
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
@ -93,33 +94,3 @@ jobs:
|
|||||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
|
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'
|
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
||||||
- run: nix-build test.nix
|
- 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)
|
- Quick installation (~4s on Linux, ~20s on macOS)
|
||||||
- Multi-User installation (with sandboxing enabled only on Linux)
|
- 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
|
- [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 extra Nix configration options via `extra_nix_config`
|
||||||
- Allows specifying `$NIX_PATH` and channels via `nix_path`
|
- 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
|
- 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
|
## Usage
|
||||||
|
|
||||||
@ -33,8 +32,8 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- uses: cachix/install-nix-action@v15
|
- uses: cachix/install-nix-action@v13
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
- run: nix-build
|
- run: nix-build
|
||||||
@ -52,10 +51,13 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.3.4
|
||||||
- uses: cachix/install-nix-action@v15
|
- uses: cachix/install-nix-action@v14
|
||||||
with:
|
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: |
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: nix build
|
- run: nix build
|
||||||
- run: nix flake check
|
- 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
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
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
|
if type -p nix &>/dev/null ; then
|
||||||
echo "Aborting: Nix is already installed at $(type -p nix)"
|
echo "Aborting: Nix is already installed at $(type -p nix)"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a temporary workdir
|
|
||||||
workdir=$(mktemp -d)
|
|
||||||
trap 'rm -rf "$workdir"' EXIT
|
|
||||||
|
|
||||||
# Configure Nix
|
# Configure Nix
|
||||||
add_config() {
|
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
|
# Set jobs to number of cores
|
||||||
add_config "max-jobs = auto"
|
add_config "max-jobs = auto"
|
||||||
@ -22,51 +21,34 @@ add_config "trusted-users = root $USER"
|
|||||||
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
||||||
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
||||||
fi
|
fi
|
||||||
if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then
|
|
||||||
add_config "experimental-features = nix-command flakes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Nix installer flags
|
# Nix installer flags
|
||||||
installer_options=(
|
installer_options=(
|
||||||
--no-channel-add
|
--no-channel-add
|
||||||
--darwin-use-unencrypted-nix-store-volume
|
--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
|
# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported
|
||||||
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
||||||
installer_options+=(
|
installer_options+=(
|
||||||
--daemon
|
--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
|
else
|
||||||
# "fix" the following error when running nix*
|
# "fix" the following error when running nix*
|
||||||
# error: the group 'nixbld' specified in 'build-users-group' does not exist
|
# error: the group 'nixbld' specified in 'build-users-group' does not exist
|
||||||
add_config "build-users-group ="
|
|
||||||
mkdir -m 0755 /etc/nix
|
mkdir -m 0755 /etc/nix
|
||||||
cp $workdir/nix.conf /etc/nix/nix.conf
|
echo "build-users-group =" > /etc/nix/nix.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
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[@]}")
|
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "installer options: ${installer_options[*]}"
|
echo "installer options: ${installer_options[@]}"
|
||||||
|
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") "${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[@]}"
|
|
||||||
|
|
||||||
if [[ $OSTYPE =~ darwin ]]; then
|
if [[ $OSTYPE =~ darwin ]]; then
|
||||||
# macOS needs certificates hints
|
# 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/per-user/$USER/profile/bin" >> "$GITHUB_PATH"
|
||||||
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
|
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
|
||||||
if [[ $INPUT_NIX_PATH != "" ]]; then
|
if [[ $INPUT_NIX_PATH != "" ]]; then
|
||||||
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
|
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user