88 lines
2.1 KiB
YAML
88 lines
2.1 KiB
YAML
name: Test and Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- feat/cicd
|
|
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@v3
|
|
with:
|
|
path: |
|
|
~/.cabal
|
|
~/.ghc
|
|
key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project') }}
|
|
restore-keys: |
|
|
cabal-${{ runner.os }}-
|
|
|
|
- name: Set up cache for Nix
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
/nix/store
|
|
/nix/var/nix/cache
|
|
key: nix-${{ runner.os }}-${{ hashFiles('flake.nix') }}
|
|
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@v3
|
|
with:
|
|
path: |
|
|
~/.cabal
|
|
~/.ghc
|
|
key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project') }}
|
|
restore-keys: |
|
|
cabal-${{ runner.os }}-
|
|
|
|
- name: Set up cache for Nix
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
/nix/store
|
|
/nix/var/nix/cache
|
|
key: nix-${{ runner.os }}-${{ hashFiles('flake.nix') }}
|
|
restore-keys: |
|
|
nix-${{ runner.os }}-
|
|
|
|
- name: Build binary
|
|
run: |
|
|
nix build
|
|
ls -alh ./result/bin/tricu
|
|
|