Skip to content

feat!: derive unix socket paths from runtime manifest and cached share directory #1672

feat!: derive unix socket paths from runtime manifest and cached share directory

feat!: derive unix socket paths from runtime manifest and cached share directory #1672

Workflow file for this run

name: Snap CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allow manual trigger
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SNAP_NAME: stack-utils
jobs:
unit-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version: '1.26.x'
- name: Run tests
run: go test -v ./...
build:
needs: [ unit-test ]
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Build snap
uses: snapcore/action-build@v1
id: snapcraft
- name: Upload snap artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.SNAP_NAME }}-${{ runner.arch }}
path: |
*.snap
*.comp
if-no-files-found: error
retention-days: 7
smoke-test:
needs: [ build ]
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- name: Refresh/Install snapd
shell: bash
run: |
sudo snap refresh snapd || sudo snap install snapd
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.SNAP_NAME }}-${{ runner.arch }}
- name: Install the snap
shell: bash
run: |
sudo snap install --dangerous ./*.snap ./*.comp
sudo snap connect ${{ env.SNAP_NAME }}:hardware-observe
- name: Run smoke tests
uses: canonical/inference-snaps-dev/.github/actions/smoke-test@v2
with:
snap-name: ${{ env.SNAP_NAME }}
engine: cpu
features: openai_models, openai_chat_text
publish:
needs: [ smoke-test ]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
steps:
- name: Download snap artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ env.SNAP_NAME }}-*
path: artifacts
- name: Install snapcraft
shell: bash
run: |
sudo snap install snapcraft --classic
# Upload snap with components
# Adapted from https://github.com/canonical/inference-snaps-dev/blob/f744b98984a29c377b61d3f7141df79cbad1f67d/.github/workflows/build-publish-snap.yaml#L54-L86
- name: Publish snap
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
CHANNEL: latest/edge
run: |
channel="${{ env.CHANNEL }}"
echo -e "Channel:\n\t$channel"
# Each artifact directory holds the snap+components built for one architecture
for dir in artifacts/*/; do
(
cd "$dir"
snap_file="$(ls *.snap)"
snap_size=$(du -h "$snap_file" | cut -f1)
echo -e "Snap file:\n\t$snap_file $snap_size"
# Build components argument list
component_args=()
echo "Snap components:"
for comp_file in *.comp; do
comp_size=$(du -h "$comp_file" | cut -f1)
# Component file name patterns:
# <snap_name>+<comp_name>_<comp_version>.comp
# <snap_name>+<comp_name>.comp
comp_name=$(echo "$comp_file" |
cut -d'+' -f2 | # drop snap name
cut -d'.' -f1 | # drop file extension
cut -d'_' -f1) # split by _, take 1st part
echo -e "\t$comp_file $comp_size"
component_args+=(--component "$comp_name=$comp_file")
done
echo -e "\nUploading snap..."
set -x
snapcraft upload "$snap_file" "${component_args[@]}" --release="$channel"
)
done