diff --git a/.forgejo/workflows/check-since.sh b/.forgejo/workflows/check-since.sh new file mode 100755 index 0000000..123eb59 --- /dev/null +++ b/.forgejo/workflows/check-since.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +git rev-list "$1"..HEAD | while read -r ref; do + git switch "$ref" + nix flake check --accept-flake-config +done diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index d36c6e0..0872da2 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -11,14 +11,40 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: https://github.com/docker/setup-qemu-action@v3 - - uses: actions/checkout@v4 - - uses: https://github.com/cachix/install-nix-action@v26 + - name: Checkout + run: | + set -x + git init /workspace/kitchen/rice + cd /workspace/kitchen/rice + git remote add origin ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }} + if [[ ${{ github.event_name }} == pull_request ]]; then + ref="refs/remotes/pull/${{ github.event.pull_request.number }}/head" + else + ref="refs/remotes/${{ github.event.base_ref }}" + fi + git fetch origin :"$ref" + git switch --detach "$ref" + - name: Setup qemu + uses: https://github.com/docker/setup-qemu-action@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - name: Install nix + uses: https://github.com/cachix/install-nix-action@v26 with: nix_path: nixpkgs=channel:nixos-unstable github_access_token: '${{ secrets.GH_TOKEN }}' - - uses: https://github.com/cachix/cachix-action@v14 + - name: Setup cachix + uses: https://github.com/cachix/cachix-action@v14 with: name: kitchen authToken: '${{ secrets.CACHIX_TOKEN }}' - - run: nix flake check --accept-flake-config + - name: Run tests + run: | + set -x + if [[ ${{ github.event_name }} == push ]]; then + ref="HEAD~$(echo "${{ toJSON(github.event.commits) }}" | nix run nixpkgs#jq length)" + else + ref="${{ github.event.base_ref }}" + fi + "$PWD"/.forgejo/workflows/check-since.sh "$ref"