Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 68 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,66 @@ on:
branches: [ "main" ]

jobs:
template:
path-filter:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.any_changed }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: tj-actions/changed-files@v46
id: filter
with:
files: |
modules/**
tests/**
flake.lock
flake.nix
.github/workflows/build.yaml
separator: "\n"

- env:
ALL_CHANGED_FILES: ${{ steps.filter.outputs.all_changed_files }}
run: |
echo $ALL_CHANGED_FILES

tests-matrix:
needs: [ "path-filter" ]
if: needs.path-filter.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: "system-features = nixos-test benchmark big-parallel kvm"
- name: Setup Caching
uses: cachix/cachix-action@v16
with:
name: selfhostblocks
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Generate Matrix
id: generate-matrix
run: |
nix flake show --allow-import-from-derivation --json \
| jq -c '.["checks"]["x86_64-linux"] | keys' > .output

cat .output

echo dynamic_list="$(cat .output)" >> "$GITHUB_OUTPUT"
outputs:
check: ${{ steps.generate-matrix.outputs.dynamic_list }}

tests:
runs-on: ubuntu-latest
needs: [ "tests-matrix" ]
strategy:
matrix:
check: ${{ fromJson(needs.tests-matrix.outputs.check) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -23,12 +81,16 @@ jobs:
- name: Run template test
run: |
(while true; do free -m; df -h; sleep 10; done)&
nix run .#checks.x86_64-linux.template
nix run .#checks.x86_64-linux.${{ matrix.check }}

result:
runs-on: ubuntu-latest
needs:
- template
needs: [ tests ]
if: '!cancelled()'
steps:
- name: success
run: exit 0
- run: |
result="${{ needs.tests.result }}"
if ! [[ $result == "success" || $result == "skipped" ]]; then
exit 1
fi
exit 0