Răsfoiți Sursa

CI: add FreeBSD workflow in freebsd.yml

Thomas Waldmann 1 lună în urmă
părinte
comite
5855ca4135
1 a modificat fișierele cu 119 adăugiri și 0 ștergeri
  1. 119 0
      .github/workflows/freebsd.yml

+ 119 - 0
.github/workflows/freebsd.yml

@@ -0,0 +1,119 @@
+name: CI FreeBSD
+
+on:
+  push:
+    branches: [ master ]
+    tags:
+    - '2.*'
+  pull_request:
+    branches: [ master ]
+    paths:
+    - '**.py'
+    - '**.pyx'
+    - '**.c'
+    - '**.h'
+    - '**.yml'
+    - '**.toml'
+    - '**.cfg'
+    - '**.ini'
+    - 'requirements.d/*'
+    - '!docs/**'
+
+jobs:
+  freebsd_tests:
+    name: FreeBSD tests and build
+    permissions:
+      contents: read
+      id-token: write
+      attestations: write
+    runs-on: ubuntu-24.04
+    continue-on-error: true
+    steps:
+      - name: Check out repository
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          fetch-tags: true
+
+      - name: Run on FreeBSD
+        id: freebsd
+        uses: cross-platform-actions/action@v0.29.0
+        with:
+          operating_system: freebsd
+          version: '14.3'
+          shell: bash
+          # Increase resources a bit for building Cython extensions
+          cpu_count: 3
+          memory: 8G
+          run: |
+            set -euxo pipefail
+            # Update package catalog and install dependencies
+            export IGNORE_OSVERSION=yes
+            sudo -E pkg update -f
+            sudo -E pkg install -y xxhash liblz4 zstd pkgconf
+            sudo -E pkg install -y fusefs-libs || true
+            sudo -E pkg install -y fusefs-libs3 || true
+            sudo -E pkg install -y rust
+            sudo -E pkg install -y git  # fakeroot causes lots of troubles on freebsd
+            sudo -E pkg install -y python310 py310-sqlite3
+            sudo -E pkg install -y python311 py311-sqlite3 py311-pip py311-virtualenv
+
+            # Ensure python3 and pip point to the chosen version
+            sudo ln -sf /usr/local/bin/python3.11 /usr/local/bin/python3 || true
+            sudo ln -sf /usr/local/bin/python3.11 /usr/local/bin/python || true
+            sudo ln -sf /usr/local/bin/pip3.11 /usr/local/bin/pip3 || true
+            sudo ln -sf /usr/local/bin/pip3.11 /usr/local/bin/pip || true
+
+            # Create and activate venv
+            python -m venv .venv
+            . .venv/bin/activate
+
+            # Build prerequisites
+            python -V
+            pip -V
+            python -m pip install --upgrade pip wheel
+            # Install dev requirements and project in editable mode
+            pip install -r requirements.d/development.txt
+            pip install -e .
+
+            # Run tests (skip benchmarks which are slow on CI)
+            pytest -v -n auto --benchmark-skip
+
+            # Only build PyInstaller binaries for tags
+            if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
+              python -m pip install 'pyinstaller==6.14.2'
+              mkdir -p dist/binary
+              pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
+              # Smoke-test the built binaries and package dir-mode as tarball
+              pushd dist/binary
+              echo "single-file binary"
+              chmod +x borg.exe
+              ./borg.exe -V
+              echo "single-directory binary"
+              chmod +x borg-dir/borg.exe
+              ./borg-dir/borg.exe -V
+              tar czf borg.tgz borg-dir
+              popd
+              # Prepare artifacts
+              mkdir -p artifacts
+              if [ -f dist/binary/borg.exe ]; then
+                cp -v dist/binary/borg.exe artifacts/borg-freebsd-14-x86_64-gh
+              fi
+              if [ -f dist/binary/borg.tgz ]; then
+                cp -v dist/binary/borg.tgz artifacts/borg-freebsd-14-x86_64-gh.tgz
+              fi
+            fi
+
+      - name: Upload FreeBSD artifacts
+        if: startsWith(github.ref, 'refs/tags/')
+        uses: actions/upload-artifact@v4
+        with:
+          name: freebsd14-dist
+          path: artifacts/*
+          if-no-files-found: ignore
+
+      - name: Attest provenance for FreeBSD artifacts
+        if: startsWith(github.ref, 'refs/tags/')
+        uses: actions/attest-build-provenance@v3
+        with:
+          subject-path: 'artifacts/*'