-
Notifications
You must be signed in to change notification settings - Fork 0
32 lines (31 loc) · 1.09 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Test
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Run Go Tests
runs-on: ubuntu-latest
steps:
- name: Checkout the Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # needed for go-change-delta to work correctly
- name: Load Nix
uses: ./.github/actions/load-nix
- name: Get previous commit SHA
if: github.ref == 'refs/heads/main' # Ensures this job only runs on pushes to main
id: previous_commit
run: echo "prev_sha=$(git rev-parse HEAD~1)" >> $GITHUB_OUTPUT
- name: Get Affected Packages
uses: ./.github/actions/go-change-delta
id: delta
with:
use-nix: 'true'
base-ref: ${{ steps.previous_commit.outputs.prev_sha || github.base_ref }}
nix-flake-attribute: ".#ci-runtests"
- name: Run Tests In Nix
if: steps.delta.outputs.packages != ''
run: nix develop .#ci-runtests -c sh -c "go test -timeout 5m -cover -covermode=count ${{ steps.delta.outputs.packages }}"