diff --git a/.gitea/workflows/test-and-build.yml b/.gitea/workflows/test-and-build.yml new file mode 100644 index 0000000..6ba4b30 --- /dev/null +++ b/.gitea/workflows/test-and-build.yml @@ -0,0 +1,86 @@ +name: Test and Build + +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + +jobs: + test: + container: + image: docker.matri.cx/nix-runner:latest + credentials: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up cache for Cabal + uses: actions/cache@v4 + with: + path: | + ~/.cabal + ~/.ghc + key: cabal-${{ runner.os }}-${{ hashFiles('tricu.cabal') }} + restore-keys: | + cabal-${{ runner.os }}- + + - name: Set up cache for Nix + uses: actions/cache@v4 + with: + path: | + /nix/store + /nix/var/nix/cache + key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + restore-keys: | + nix-${{ runner.os }}- + + - name: Initialize Cabal and update package list + run: | + nix develop --command cabal update + + - name: Install dependencies and run tests + run: | + nix develop --command cabal test + + build: + needs: test + container: + image: docker.matri.cx/nix-runner:latest + credentials: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up cache for Cabal + uses: actions/cache@v4 + with: + path: | + ~/.cabal + ~/.ghc + key: cabal-${{ runner.os }}-${{ hashFiles('tricu.cabal') }} + restore-keys: | + cabal-${{ runner.os }}- + + - name: Set up cache for Nix + uses: actions/cache@v4 + with: + path: | + /nix/store + /nix/var/nix/cache + key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + restore-keys: | + nix-${{ runner.os }}- + + - name: Build binary + run: | + nix build + ls -alh ./result/bin/tricu +