update #115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Templates Check | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate-templates: | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| platform: linux | |
| arch: x86_64 | |
| runner: ubuntu-latest | |
| system: x86_64-linux | |
| # macOS aarch64 (Apple Silicon M1/M2) | |
| - os: macos-14 | |
| platform: macos | |
| arch: aarch64 | |
| runner: macos-14 | |
| system: aarch64-darwin | |
| runs-on: ${{ matrix.runner }} | |
| name: Validate Templates (${{ matrix.platform }}-${{ matrix.arch }}) | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: DeterminateSystems/determinate-nix-action@v3 | |
| - name: Validate templates with flake check | |
| run: | | |
| cd templates | |
| failed=() | |
| # Dynamically discover all templates with flake.nix | |
| templates=() | |
| for dir in */; do | |
| if [ -f "$dir/flake.nix" ]; then | |
| templates+=("${dir%/}") | |
| fi | |
| done | |
| echo "Found ${#templates[@]} templates to validate: ${templates[*]}" | |
| for template in "${templates[@]}"; do | |
| echo "::group::Checking $template" | |
| # Create a temporary directory for testing | |
| test_dir=$(mktemp -d) | |
| # Copy template to temp directory (including hidden files) | |
| cp -r "$template"/. "$test_dir/" | |
| cd "$test_dir" | |
| # Run nix flake check | |
| if nix flake check 2>&1; then | |
| echo "✓ $template flake check succeeded" | |
| else | |
| echo "✗ $template flake check failed" | |
| failed+=("$template") | |
| fi | |
| cd - > /dev/null | |
| rm -rf "$test_dir" | |
| echo "::endgroup::" | |
| done | |
| if [ ${#failed[@]} -ne 0 ]; then | |
| echo "::error::The following templates failed flake check: ${failed[*]}" | |
| exit 1 | |
| fi | |
| - name: Show validation info | |
| run: | | |
| echo "Platform: ${{ matrix.platform }}" | |
| echo "Architecture: ${{ matrix.arch }}" | |
| echo "System: ${{ matrix.system }}" | |
| echo "Runner: ${{ matrix.runner }}" | |
| uname -a | |
| nix --version |