-
Notifications
You must be signed in to change notification settings - Fork 0
feat!/major api improvements #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9535bac
feat: majorly improve the api, add integration test
elibosley 62003f2
feat: docker integration tests
elibosley d74d868
chore: cleanup unused line
elibosley 2e28759
feat: domain destruction
elibosley bf8b112
chore: remove integration tests from main.yml
elibosley 2144db2
feat: many more tests
elibosley 3f8ca21
chore: docstrings and type cleanup
elibosley 215b769
fix: back to enums
elibosley add8eb3
feat: 100% code coverage
elibosley 63c7a2a
chore: combine test steps
elibosley 3f865a3
chore: swap to coveragetesting
elibosley 20ea85a
chore: update tests to cache and improve local dev
elibosley c6a3624
fix: buildx cache location
elibosley fcbe382
fix: attempt to fix caching with gha
elibosley 8e95d4f
fix: try to cleanup before running subsequent tests
elibosley edece47
chore: try to fix integration tests
elibosley e21d123
feat!: update the readme
elibosley a67e052
chore: update content
elibosley c46d209
fix: coverage tst
elibosley b1e3926
chore: try to copy coverage out of the container
elibosley b5e6e4e
feat: coverage badge
elibosley 98e1957
chore: remove arm64 from integration testing until speed can be improved
elibosley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,85 @@ | ||
| name: Docker Integration Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| docker-integration: | ||
| name: Docker Integration Tests | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| arch: [amd64] # arm64 works but is very slow | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| with: | ||
| install: true | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| with: | ||
| platforms: linux/amd64,linux/arm64 | ||
|
|
||
| - name: Create libvirt directories | ||
| run: | | ||
| sudo mkdir -p /var/run/libvirt | ||
| sudo mkdir -p /var/lib/libvirt | ||
| sudo chmod -R 777 /var/run/libvirt | ||
| sudo chmod -R 777 /var/lib/libvirt | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y qemu-user-static | ||
|
|
||
| - name: Build and run tests | ||
| run: | | ||
| # Create test artifacts directory | ||
| mkdir -p test-artifacts | ||
|
|
||
| # Build the Docker image with GitHub Actions cache | ||
| docker buildx build \ | ||
| --platform linux/${{ matrix.arch }} \ | ||
| --build-arg BASE_IMAGE=node:20-slim \ | ||
| -t libvirt-test-${{ matrix.arch }} \ | ||
| --cache-from type=gha \ | ||
| --cache-to type=gha,mode=max \ | ||
| --load \ | ||
| . | ||
|
|
||
| # Run the container with necessary privileges | ||
| docker run \ | ||
| --platform linux/${{ matrix.arch }} \ | ||
| --privileged \ | ||
| -v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \ | ||
| -v /var/lib/libvirt:/var/lib/libvirt \ | ||
| -v $(pwd)/test-artifacts:/app/test-artifacts \ | ||
| --name test-container \ | ||
| libvirt-test-${{ matrix.arch }} | ||
|
|
||
| # Copy coverage data from the container | ||
| docker cp test-container:/app/coverage ./coverage | ||
| docker rm test-container | ||
|
|
||
| - name: Upload coverage reports to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
|
|
||
| - name: Upload coverage report | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-report-${{ matrix.arch }} | ||
| path: coverage/ | ||
| retention-days: 14 |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -10,4 +10,9 @@ | |
| *.tgz | ||
|
|
||
| # tsbuildinfo | ||
| tsconfig.tsbuildinfo | ||
| tsconfig.tsbuildinfo | ||
|
|
||
| # coverage | ||
| coverage | ||
|
|
||
| test-artifacts/ | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,90 @@ | ||
| FROM node:22-bookworm-slim AS development | ||
| # Install build tools | ||
| RUN apt-get update -y && apt-get install -y \ | ||
| # Build stage | ||
| FROM node:20-slim AS builder | ||
|
|
||
| # Prevent interactive prompts during package installation | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Install build dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| build-essential \ | ||
| python3 \ | ||
| libvirt-dev \ | ||
| jq | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set up the build environment | ||
| WORKDIR /app | ||
|
|
||
| # Copy package files first to leverage caching | ||
| COPY package*.json ./ | ||
| COPY pnpm-lock.yaml ./ | ||
|
|
||
| # Install pnpm globally using npm | ||
| RUN npm install -g pnpm@latest | ||
| # Install pnpm and dependencies | ||
| RUN npm install -g pnpm && \ | ||
| pnpm install --frozen-lockfile | ||
|
|
||
| # Copy source files | ||
| COPY . . | ||
|
|
||
| # Build the project | ||
| RUN pnpm run build | ||
|
|
||
| # Test stage | ||
| FROM node:20-slim AS test | ||
|
|
||
| # Prevent interactive prompts during package installation | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Install test dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| build-essential \ | ||
| python3 \ | ||
| qemu-system-x86 \ | ||
| qemu-system-arm \ | ||
| qemu-efi \ | ||
| qemu-efi-aarch64 \ | ||
| qemu-utils \ | ||
| ovmf \ | ||
| libvirt-daemon-system \ | ||
| libvirt-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create a non-root user for libvirt and set up permissions | ||
| RUN useradd -m -s /bin/bash -g libvirt libvirt && \ | ||
| usermod -aG kvm libvirt && \ | ||
| mkdir -p /var/run/libvirt && \ | ||
| chown root:libvirt /var/run/libvirt && \ | ||
| chmod g+w /var/run/libvirt | ||
|
|
||
| # Set up the test environment | ||
| WORKDIR /app | ||
|
|
||
| # Copy package files and install all dependencies (including dev) | ||
| COPY package*.json ./ | ||
| COPY pnpm-lock.yaml ./ | ||
| RUN npm install -g pnpm && \ | ||
| pnpm install --frozen-lockfile | ||
|
|
||
| # Copy built files and test files from builder stage | ||
| COPY --from=builder /app/dist ./dist | ||
| COPY --from=builder /app/lib ./lib | ||
| COPY --from=builder /app/__tests__ ./__tests__ | ||
| COPY --from=builder /app/vitest.config.ts ./vitest.config.ts | ||
| COPY --from=builder /app/build ./build | ||
|
|
||
| # Set up libvirt configuration | ||
| RUN mkdir -p /etc/libvirt && \ | ||
| echo 'unix_sock_group = "libvirt"' >> /etc/libvirt/libvirtd.conf && \ | ||
| echo 'unix_sock_rw_perms = "0770"' >> /etc/libvirt/libvirtd.conf && \ | ||
| echo 'auth_unix_rw = "none"' >> /etc/libvirt/libvirtd.conf | ||
|
|
||
| # Create necessary directories with correct permissions | ||
| RUN mkdir -p /home/libvirt/.config/libvirt && \ | ||
| echo 'uri_default = "qemu:///session"' > /home/libvirt/.config/libvirt/libvirt.conf && \ | ||
| chown -R libvirt:libvirt /home/libvirt/.config && \ | ||
| chown -R libvirt:libvirt /app | ||
|
|
||
| # Switch to non-root user | ||
| USER libvirt | ||
|
|
||
| # Start libvirtd and run tests | ||
| CMD ["/bin/sh", "-c", "/usr/sbin/libvirtd --daemon && sleep 2 && pnpm test:coverage"] | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.