fix(ci): replace Cachix with Attic in GitHub workflows #3
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
| # GitHub Actions: Nix Build with Attic Cache | |
| # Mirrors GitLab CI with greedy cache push/pull pattern | |
| # | |
| # Architecture: | |
| # nix-build ─┬─> nix-check | |
| # └─> bazel-validation | |
| # | |
| # Cache Strategy: | |
| # - Attic: Pull always, push on main branch only | |
| # - Greedy pattern: Push derivations as they complete | |
| name: nix-matrix | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| ATTIC_SERVER: https://nix-cache.fuzzy-dev.tinyland.dev | |
| ATTIC_CACHE: main | |
| NIX_CONFIG: | | |
| experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| jobs: | |
| # ============================================================= | |
| # Primary build with Attic cache integration | |
| # ============================================================= | |
| nix-build: | |
| name: Build (x86_64-linux) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| env: | |
| RENV_ACTIVATE_PROJECT: "FALSE" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Remove renv .Rprofile | |
| run: rm -f .Rprofile | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| - name: Setup Attic | |
| run: | | |
| nix profile install nixpkgs#attic-client | |
| attic login production ${{ env.ATTIC_SERVER }} "${{ secrets.ATTIC_TOKEN }}" | |
| attic use ${{ env.ATTIC_CACHE }} | |
| - name: Show Nix info | |
| run: | | |
| nix --version | |
| nix flake show | |
| - name: Build R dependencies (cached) | |
| run: nix build .#rDeps --out-link result-rdeps | |
| - name: Build C++ objects (cached) | |
| run: nix build .#cppBuild --out-link result-cpp | |
| - name: Build tarball | |
| run: | | |
| nix build .#tarball --out-link result-tarball | |
| VERSION=$(grep "^Version:" DESCRIPTION | cut -d' ' -f2) | |
| cp result-tarball gnucashr_${VERSION}.tar.gz | |
| ls -la gnucashr_*.tar.gz | |
| - name: Push to Attic cache | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| attic push ${{ env.ATTIC_CACHE }} result-rdeps result-cpp result-tarball || true | |
| - name: Upload tarball artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tarball-x86_64-linux | |
| path: gnucashr_*.tar.gz | |
| retention-days: 7 | |
| # ============================================================= | |
| # R CMD check via Nix | |
| # ============================================================= | |
| nix-check: | |
| name: R CMD check | |
| needs: nix-build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| RENV_ACTIVATE_PROJECT: "FALSE" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Remove renv .Rprofile | |
| run: rm -f .Rprofile | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| - name: Setup Attic (pull only) | |
| run: | | |
| nix profile install nixpkgs#attic-client | |
| attic login production ${{ env.ATTIC_SERVER }} "${{ secrets.ATTIC_TOKEN }}" | |
| attic use ${{ env.ATTIC_CACHE }} | |
| - name: Download tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tarball-x86_64-linux | |
| - name: Run R CMD check | |
| run: | | |
| nix build .#checks.x86_64-linux.r-cmd-check --out-link result-check 2>&1 | tail -50 | |
| ls -la result-check/ | |
| - name: Upload check results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: check-results-x86_64-linux | |
| path: result-check/ | |
| retention-days: 7 | |
| # ============================================================= | |
| # Bazel validation (build graph only) | |
| # ============================================================= | |
| bazel-validation: | |
| name: Bazel validation | |
| needs: nix-build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| - name: Install Bazel via Nix | |
| run: nix profile install nixpkgs#bazel_7 | |
| - name: Bazel version | |
| run: bazel --version | |
| - name: Query build graph | |
| run: bazel query //... --enable_workspace | |
| # ============================================================= | |
| # Coverage (main branch only) | |
| # ============================================================= | |
| nix-coverage: | |
| name: Coverage | |
| needs: nix-build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| if: github.ref == 'refs/heads/main' | |
| env: | |
| RENV_ACTIVATE_PROJECT: "FALSE" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Remove renv .Rprofile | |
| run: rm -f .Rprofile | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| - name: Setup Attic (pull only) | |
| run: | | |
| nix profile install nixpkgs#attic-client | |
| attic login production ${{ env.ATTIC_SERVER }} "${{ secrets.ATTIC_TOKEN }}" | |
| attic use ${{ env.ATTIC_CACHE }} | |
| - name: Run coverage | |
| run: | | |
| nix develop --command bash -c ' | |
| Rscript -e " | |
| cov <- covr::package_coverage(type = \"tests\", line_exclusions = list(\"src/RcppExports.cpp\")) | |
| total_coverage <- covr::percent_coverage(cov) | |
| message(sprintf(\"Total coverage: %.1f%%\", total_coverage)) | |
| covr::to_cobertura(cov, filename = \"coverage.xml\") | |
| " | |
| ' | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.xml | |
| fail_ci_if_error: false |