-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
217 additions
and
119 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
inputs: | ||
expression: | ||
description: 'Nix expression to build' | ||
required: true | ||
|
||
outputs: | ||
derivation: | ||
description: 'Path to the built derivation' | ||
value: ${{ steps.build.outputs.derivation }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install Nix ❄️ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Build ${{ inputs.expression }} 🛠️ | ||
id: build | ||
shell: bash | ||
run: | | ||
JSON=$(mktemp) | ||
(nix build -L ${{ inputs.expression }} --no-link --json >$JSON) |& sed -uE 's/^(trace: +)?warning:(\s+|$)/::warning::/;s/^(trace: +)?error:(\s+|$)/::error::/;s/^trace:(\s+|$)/::notice::trace: /' | ||
DRV=$(jq -r .[0].outputs.out <$JSON) | ||
echo "derivation=$DRV" >> $GITHUB_OUTPUT | ||
echo "- Built \`$DRV\`" >> $GITHUB_STEP_SUMMARY | ||
echo " - $(nix show-derivation -r $DRV | jq 'keys[]' | wc -l) derivations in closure" >> $GITHUB_STEP_SUMMARY | ||
echo " - $(nix path-info -S --json $DRV | jq -r '.[0].closureSize' | xargs numfmt --to=iec-i --suffix=B --format='%.3f') total size" >> $GITHUB_STEP_SUMMARY |
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,20 @@ | ||
inputs: | ||
config: | ||
description: 'System configuration to build' | ||
required: true | ||
filename: | ||
description: 'Filename to save the image as' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Build tarball builder 🛠️ | ||
id: buildBuilder | ||
uses: ./.github/actions/build-nix-expression | ||
with: | ||
expression: '.#nixosConfigurations.${{ inputs.config }}.config.system.build.tarballBuilder' | ||
|
||
- name: Build tarball 📦 | ||
shell: bash | ||
run: sudo ${{ steps.buildBuilder.outputs.derivation }}/bin/nixos-wsl-tarball-builder ${{ inputs.filename }} |
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,19 @@ | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check for nix ✅ | ||
id: check-nix | ||
shell: bash | ||
run: | | ||
if command -v nix &> /dev/null | ||
then | ||
echo "nix-found=true" | tee -a $GITHUB_OUTPUT | ||
else | ||
echo "nix-found=false" | tee -a $GITHUB_OUTPUT | ||
fi | ||
- name: Install Nix ❄️ | ||
if: ${{ steps.check-nix.outputs.nix-found != 'true' }} | ||
uses: cachix/install-nix-action@v22 | ||
with: | ||
github_access_token: ${{ github.token }} |
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,48 @@ | ||
name: Build Tarballs 🛠️ | ||
|
||
on: | ||
workflow_call: {} | ||
|
||
jobs: | ||
build: | ||
name: Build 🛠️ | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
config: | ||
- modern | ||
- legacy | ||
- test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix ❄️ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Generate Version 🏷️ | ||
id: version | ||
run: | | ||
TAG_COUNT=$(git rev-list --tags --no-walk --count) # Count all tags | ||
COMMIT_COUNT=$(git rev-list --use-bitmap-index --count $(git rev-list --tags --no-walk --max-count=1)..HEAD) # Count all commits since the last tag | ||
NIXOS_VERSION=$(nix-instantiate --eval -E '(import ./.).inputs.nixpkgs.lib.version' | sed -E 's/"(.+\...).*"/\1/') # Get NixOS version from nixpkgs | ||
NIXOS_VERSION_MS=$(echo $NIXOS_VERSION | sed -E 's/\.0*(.+)/\.\1/') # Remove the leading 0 from the minor version (if it exists) | ||
NIXOS_WSL_VERSION=${NIXOS_VERSION_MS}.${TAG_COUNT}.${COMMIT_COUNT} # Compose the NixOS-WSL version number | ||
echo "version=$NIXOS_WSL_VERSION" >> $GITHUB_OUTPUT | ||
echo $NIXOS_WSL_VERSION > ./VERSION | ||
echo $(git rev-parse HEAD) >> ./VERSION | ||
- name: Build Tarball 🛠️ | ||
uses: ./.github/actions/build-wsl-tarball | ||
with: | ||
config: ${{ matrix.config }} | ||
filename: nixos-wsl.tar.gz | ||
|
||
- name: Upload Tarball 📤 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: tarball-${{ matrix.config }} | ||
path: nixos-wsl.tar.gz |
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,46 @@ | ||
name: Flake Checks 📋 | ||
|
||
on: | ||
workflow_call: {} | ||
|
||
jobs: | ||
prepare: | ||
name: Find Checks 🔍 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
checks: ${{ steps.checks.outputs.checks }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix ❄️ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Find Checks 🔍 | ||
id: checks | ||
run: | | ||
nix-instantiate --json --eval --strict -E 'with builtins; attrNames (getFlake (toString ./.)).checks.${currentSystem}' | perl -pe 's|(.*)|checks=\1|' >>$GITHUB_OUTPUT | ||
checks: | ||
name: Check 📋 | ||
needs: | ||
- prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
check: ${{ fromJSON(needs.prepare.outputs.checks) }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix ❄️ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Run Check 📋 | ||
run: | | ||
nix build -L --impure --expr "with builtins; (getFlake (toString ./.)).checks.\${currentSystem}.${{ matrix.check }}" |
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,52 @@ | ||
name: Test 🧪 | ||
|
||
on: | ||
workflow_call: {} | ||
|
||
jobs: | ||
prepare: | ||
name: Find Tests 🔍 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tests: ${{ steps.tests.outputs.tests }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix ❄️ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Find Tests 🔍 | ||
id: tests | ||
run: | | ||
find tests -name '*.Tests.ps1' -print0 | perl -pe 's|(.*?)\x0|"\1",|g;s|,$||;s|(.*)|tests=[\1]|' >> $GITHUB_OUTPUT | ||
tests: | ||
name: Test 🧪 | ||
needs: | ||
- prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: ${{ fromJSON(needs.prepare.outputs.tests) }} | ||
os: | ||
- ubuntu-20.04 | ||
# - windows-latest # doesn't work due to lack of nested virtualization on the runners, hopefully this will work one day | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download Tarball 📥 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: tarball-test | ||
|
||
- name: Execute Test 🧪 | ||
shell: pwsh | ||
run: | | ||
Invoke-Pester -Output Detailed ${{ matrix.test }} |