Skip to content

Commit

Permalink
use GUID for image name
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Nov 10, 2022
1 parent 3bcd5ba commit 9ffedc9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request, release]

jobs:
find-tests:
name: Find tests 🔍
name: Find Tests 🔍
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.tests.outputs.tests }}
Expand All @@ -19,6 +19,18 @@ jobs:
run: |
find tests -name '*.spec.ps1' -print0 | perl -pe 's|(.*?)\x0|"\1",|g;s|,$||;s|(.*)|tests=[\1]|' >> $GITHUB_OUTPUT
find-checks:
name: Find Flake Checks 🔍
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install nix ❄️
uses: cachix/install-nix-action@v18

build:
name: Build 🛠️
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,6 +74,7 @@ jobs:
- find-tests
- build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
Expand Down
23 changes: 19 additions & 4 deletions tests/lib/lib_linux.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
function WSL-Install() {
$id = [guid]::NewGuid().ToString()

# Build docker image from the provided tarball
$tmpdir = $(mktemp -d)
Copy-Item $PSScriptRoot/Dockerfile $tmpdir
Copy-Item nixos-wsl-installer.tar.gz $tmpdir
docker build -t local:nixos-wsl $tmpdir | Write-Host
docker build -t nixos-wsl:$id $tmpdir | Write-Host
Remove-Item $tmpdir -Recurse -Force

# Spawn a new docker container
$id = docker run -di --privileged --init local:nixos-wsl /bin/sh
docker run -di --privileged --init --name $id nixos-wsl:$id /bin/sh | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "Failed to launch docker container"
throw "Failed to launch container"
}

return $id
Expand All @@ -19,9 +21,22 @@ function WSL-Launch([string]$id, [string]$command) {
docker exec -t $id /nix/nixos-wsl/entrypoint -c "$command"
}

# TODO: WSL-CopyFile

function WSL-Shutdown([string]$id) {
docker stop $id
if ($LASTEXITCODE -ne 0) {
throw "Failed to stop container"
}
}

function WSL-Uninstall([string]$id) {
docker rm -f $id
if ($LASTEXITCODE -ne 0) {
throw "Failed to remove docker container"
throw "Failed to remove container"
}
docker rmi nixos-wsl:$id
if ($LASTEXITCODE -ne 0) {
throw "Failed to remove image"
}
}

0 comments on commit 9ffedc9

Please sign in to comment.