Skip to content

feat: version pinning and /opt/onyx init fix #13

feat: version pinning and /opt/onyx init fix

feat: version pinning and /opt/onyx init fix #13

Workflow file for this run

name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.1
- name: Build
run: zig build
- name: Unit tests
run: zig build test
e2e:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.1
- name: Build
run: zig build -Doptimize=ReleaseSmall
- name: Add to PATH
run: |
mkdir -p ~/.local/bin
cp zig-out/bin/onyx ~/.local/bin/onyx
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Setup nix store
run: onyx init --exec
- name: "e2e: install"
run: |
onyx install hello
hello --version
onyx list | grep hello
- name: "e2e: install with version"
run: |
onyx install jq@1.7
jq --version
- name: "e2e: exec"
run: |
onyx exec cowsay -- "moo"
- name: "e2e: exec does not appear in list"
run: |
! onyx list | grep cowsay
- name: "e2e: uninstall"
run: |
onyx uninstall hello
! command -v hello
! onyx list | grep hello
- name: "e2e: gc"
run: onyx gc
- name: "e2e: implode"
run: onyx implode --exec
validate-aliases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache nixpkgs package list
id: cache
uses: actions/cache@v4
with:
path: /tmp/nixpkgs-names.txt
key: nixpkgs-names-${{ hashFiles('.github/workflows/ci.yml') }}
restore-keys: nixpkgs-names-
- name: Download nixpkgs package list
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y brotli
curl -sL "https://channels.nixos.org/nixos-unstable/packages.json.br" \
| brotli -d \
| python3 -c "import json,sys; d=json.load(sys.stdin); print('\n'.join(d['packages'].keys()))" \
> /tmp/nixpkgs-names.txt
echo "$(wc -l < /tmp/nixpkgs-names.txt) packages indexed"
- name: Check aliases don't shadow nixpkgs
run: |
conflicts=0
for alias in $(python3 -c "import json; [print(k) for k in json.load(open('aliases.json'))]"); do
if grep -qx "$alias" /tmp/nixpkgs-names.txt; then
echo "CONFLICT: alias \"$alias\" shadows nixpkgs package"
conflicts=$((conflicts + 1))
fi
done
if [ $conflicts -gt 0 ]; then
echo "$conflicts alias(es) shadow real nixpkgs packages"
exit 1
fi
echo "all aliases ok"
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: [test, e2e]
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
permissions:
contents: write
pull-requests: write
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
strategy:
matrix:
include:
- target: x86_64-linux-musl
name: onyx-x86_64-linux
- target: aarch64-linux-musl
name: onyx-aarch64-linux
- target: aarch64-macos
name: onyx-aarch64-macos
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.1
- name: Build
run: zig build -Dtarget=${{ matrix.target }} -Doptimize=ReleaseSmall
- name: Package
run: |
cp zig-out/bin/onyx ${{ matrix.name }}
tar czf ${{ matrix.name }}.tar.gz ${{ matrix.name }}
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
files: ${{ matrix.name }}.tar.gz