mirror of
https://github.com/unraid/api.git
synced 2026-01-07 09:10:05 -06:00
due to issues and redundancies in vendoring postinstall side-effects, such as compiled bindings for libvirt, we reverted to vendoring `node_modules`, installed via `npm` instead of a global pnpm store generated by `pnpm`. This should resolve runtime issues with e.g. the libvirt bindings because `node_modules` will contain the correct "side-effects." ## Summary by CodeRabbit - **New Features** - Introduced a command to remove stale archive files during the cleanup process. - Added functionality to archive the `node_modules` directory. - Enhanced dependency resolution with new overrides for specific packages. - **Chores** - Updated dependency settings by replacing one key dependency with an alternative and removing two unused ones, ensuring optimal deployment. - Enhanced the installation process to operate strictly in offline mode. - Updated artifact naming conventions for clarity and consistency in workflows. - Modified volume mappings in the Docker Compose configuration to reflect new artifact names. - Improved error handling in the GitHub Actions workflow by adding checks for required files. - Updated references in the build process to use a vendor store instead of the PNPM store. - Removed the management of PNPM store archives from the build process.
370 lines
11 KiB
YAML
370 lines
11 KiB
YAML
name: CI - Main (API)
|
||
|
||
on:
|
||
pull_request:
|
||
push:
|
||
branches:
|
||
- main
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
jobs:
|
||
release-please:
|
||
name: Release Please
|
||
runs-on: ubuntu-latest
|
||
permissions:
|
||
contents: write
|
||
pull-requests: write
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
# Only run release-please on pushes to main
|
||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||
|
||
- id: release
|
||
uses: googleapis/release-please-action@v4
|
||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||
outputs:
|
||
releases_created: ${{ steps.release.outputs.releases_created || 'false' }}
|
||
tag_name: ${{ steps.release.outputs.tag_name || '' }}
|
||
test-api:
|
||
name: Test API
|
||
defaults:
|
||
run:
|
||
working-directory: api
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout repo
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Install Node
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version-file: ".nvmrc"
|
||
|
||
- name: Cache APT Packages
|
||
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
|
||
with:
|
||
packages: bash procps python3 libvirt-dev jq zstd git build-essential libvirt-daemon-system
|
||
version: 1.0
|
||
|
||
- name: Install pnpm
|
||
uses: pnpm/action-setup@v4
|
||
with:
|
||
run_install: false
|
||
|
||
- name: Get pnpm store directory
|
||
id: pnpm-cache
|
||
shell: bash
|
||
run: |
|
||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||
|
||
- uses: actions/cache@v4
|
||
name: Setup pnpm cache
|
||
with:
|
||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-store-
|
||
|
||
- name: PNPM Install
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: Setup libvirt
|
||
run: |
|
||
# Create required groups (if they don't already exist)
|
||
sudo groupadd -f libvirt
|
||
sudo groupadd -f kvm
|
||
|
||
# Create libvirt user if not present, and add it to the kvm group
|
||
sudo useradd -m -s /bin/bash -g libvirt libvirt || true
|
||
sudo usermod -aG kvm libvirt || true
|
||
|
||
# Set up libvirt directories and permissions
|
||
sudo mkdir -p /var/run/libvirt /var/log/libvirt /etc/libvirt
|
||
sudo chown root:libvirt /var/run/libvirt /var/log/libvirt
|
||
sudo chmod g+w /var/run/libvirt /var/log/libvirt
|
||
|
||
# Configure libvirt by appending required settings
|
||
sudo tee -a /etc/libvirt/libvirtd.conf > /dev/null <<EOF
|
||
unix_sock_group = "libvirt"
|
||
unix_sock_rw_perms = "0770"
|
||
auth_unix_rw = "none"
|
||
EOF
|
||
|
||
# Add the current user to libvirt and kvm groups (note: this change won’t apply to the current session)
|
||
sudo usermod -aG libvirt,kvm $USER
|
||
|
||
sudo mkdir -p /var/run/libvirt
|
||
sudo chown root:libvirt /var/run/libvirt
|
||
sudo chmod 775 /var/run/libvirt
|
||
|
||
|
||
# Start libvirtd in the background
|
||
sudo /usr/sbin/libvirtd --daemon
|
||
|
||
# Wait a bit longer for libvirtd to start
|
||
sleep 5
|
||
|
||
# Verify libvirt is running using sudo to bypass group membership delays
|
||
sudo virsh list --all || true
|
||
|
||
- name: Lint
|
||
run: pnpm run lint
|
||
|
||
- name: Test
|
||
run: pnpm run coverage
|
||
|
||
build-api:
|
||
name: Build API
|
||
runs-on: ubuntu-latest
|
||
defaults:
|
||
run:
|
||
working-directory: api
|
||
steps:
|
||
- name: Checkout repo
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Install Node
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version-file: ".nvmrc"
|
||
|
||
- uses: pnpm/action-setup@v4
|
||
name: Install pnpm
|
||
with:
|
||
run_install: false
|
||
|
||
- name: Get pnpm store directory
|
||
id: pnpm-cache
|
||
shell: bash
|
||
run: |
|
||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||
|
||
- uses: actions/cache@v4
|
||
name: Setup pnpm cache
|
||
with:
|
||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-store-
|
||
|
||
- name: Cache APT Packages
|
||
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
|
||
with:
|
||
packages: bash procps python3 libvirt-dev jq zstd git build-essential
|
||
version: 1.0
|
||
|
||
- name: PNPM Install
|
||
run: |
|
||
cd ${{ github.workspace }}
|
||
pnpm install --frozen-lockfile
|
||
|
||
- name: Lint
|
||
run: pnpm run lint
|
||
|
||
- name: Type Check
|
||
run: pnpm run type-check
|
||
|
||
- name: Build
|
||
run: pnpm run build
|
||
|
||
- name: Get Git Short Sha and API version
|
||
id: vars
|
||
run: |
|
||
GIT_SHA=$(git rev-parse --short HEAD)
|
||
IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '')
|
||
PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json)
|
||
API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}")
|
||
export API_VERSION
|
||
|
||
- name: Build
|
||
run: |
|
||
pnpm run build:release
|
||
|
||
tar -czf deploy/unraid-api.tgz -C deploy/pack/ .
|
||
|
||
- name: Upload tgz to Github artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: unraid-api
|
||
path: ${{ github.workspace }}/api/deploy/unraid-api.tgz
|
||
- name: Upload Node Modules to Github artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: packed-node-modules
|
||
path: ${{ github.workspace }}/api/deploy/packed-node-modules.tar.xz
|
||
|
||
build-unraid-ui-webcomponents:
|
||
name: Build Unraid UI Library (Webcomponent Version)
|
||
defaults:
|
||
run:
|
||
working-directory: unraid-ui
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout repo
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Install Node
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version-file: ".nvmrc"
|
||
|
||
- uses: pnpm/action-setup@v4
|
||
name: Install pnpm
|
||
with:
|
||
run_install: false
|
||
|
||
- name: Get pnpm store directory
|
||
id: pnpm-cache
|
||
shell: bash
|
||
run: |
|
||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||
|
||
- uses: actions/cache@v4
|
||
name: Setup pnpm cache
|
||
with:
|
||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-store-
|
||
|
||
- name: Cache APT Packages
|
||
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
|
||
with:
|
||
packages: bash procps python3 libvirt-dev jq zstd git build-essential
|
||
version: 1.0
|
||
|
||
- name: Install dependencies
|
||
run: |
|
||
cd ${{ github.workspace }}
|
||
pnpm install --frozen-lockfile --filter @unraid/ui
|
||
|
||
- name: Lint
|
||
run: pnpm run lint
|
||
|
||
- name: Build
|
||
run: pnpm run build:wc
|
||
|
||
- name: Upload Artifact to Github
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: unraid-wc-ui
|
||
path: unraid-ui/dist-wc/
|
||
|
||
build-web:
|
||
# needs: [build-unraid-ui]
|
||
name: Build Web App
|
||
defaults:
|
||
run:
|
||
working-directory: web
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout repo
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Create env file
|
||
run: |
|
||
touch .env
|
||
echo VITE_ACCOUNT=${{ secrets.VITE_ACCOUNT }} >> .env
|
||
echo VITE_CONNECT=${{ secrets.VITE_CONNECT }} >> .env
|
||
echo VITE_UNRAID_NET=${{ secrets.VITE_UNRAID_NET }} >> .env
|
||
echo VITE_CALLBACK_KEY=${{ secrets.VITE_CALLBACK_KEY }} >> .env
|
||
cat .env
|
||
|
||
- name: Install Node
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version-file: ".nvmrc"
|
||
|
||
- uses: pnpm/action-setup@v4
|
||
name: Install pnpm
|
||
with:
|
||
run_install: false
|
||
|
||
- name: Get pnpm store directory
|
||
id: pnpm-cache
|
||
shell: bash
|
||
run: |
|
||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||
|
||
- uses: actions/cache@v4
|
||
name: Setup pnpm cache
|
||
with:
|
||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-store-
|
||
|
||
- name: PNPM Install
|
||
run: |
|
||
cd ${{ github.workspace }}
|
||
pnpm install --frozen-lockfile --filter @unraid/web --filter @unraid/ui
|
||
|
||
- name: Build Unraid UI
|
||
run: |
|
||
cd ${{ github.workspace }}/unraid-ui
|
||
pnpm run build
|
||
|
||
- name: Lint files
|
||
run: pnpm run lint
|
||
|
||
- name: Type Check
|
||
run: pnpm run type-check
|
||
|
||
- name: Test
|
||
run: pnpm run test:ci
|
||
|
||
- name: Build
|
||
run: pnpm run build
|
||
|
||
- name: Upload build to Github artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: unraid-wc-rich
|
||
path: web/.nuxt/nuxt-custom-elements/dist/unraid-components
|
||
|
||
build-plugin-staging-pr:
|
||
name: Build and Deploy Plugin
|
||
needs:
|
||
- release-please
|
||
- build-api
|
||
- build-web
|
||
- build-unraid-ui-webcomponents
|
||
- test-api
|
||
uses: ./.github/workflows/build-plugin.yml
|
||
with:
|
||
RELEASE_CREATED: false
|
||
TAG: ${{ github.event.pull_request.number && format('PR{0}', github.event.pull_request.number) || '' }}
|
||
BUCKET_PATH: ${{ github.event.pull_request.number && format('unraid-api/tag/PR{0}', github.event.pull_request.number) || 'unraid-api' }}
|
||
BASE_URL: "https://preview.dl.unraid.net/unraid-api"
|
||
secrets:
|
||
CF_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
|
||
CF_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
|
||
CF_BUCKET_PREVIEW: ${{ secrets.CF_BUCKET_PREVIEW }}
|
||
CF_ENDPOINT: ${{ secrets.CF_ENDPOINT }}
|
||
|
||
build-plugin-production:
|
||
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
|
||
name: Build and Deploy Production Plugin
|
||
needs:
|
||
- release-please
|
||
- build-api
|
||
- build-web
|
||
- build-unraid-ui-webcomponents
|
||
- test-api
|
||
uses: ./.github/workflows/build-plugin.yml
|
||
with:
|
||
RELEASE_CREATED: true
|
||
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
|
||
TAG: ""
|
||
BUCKET_PATH: unraid-api
|
||
BASE_URL: "https://stable.dl.unraid.net/unraid-api"
|
||
secrets:
|
||
CF_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
|
||
CF_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
|
||
CF_BUCKET_PREVIEW: ${{ secrets.CF_BUCKET_PREVIEW }}
|
||
CF_ENDPOINT: ${{ secrets.CF_ENDPOINT }}
|