mirror of
https://github.com/moons-14/dotfiles.git
synced 2026-10-06 05:48:12 +09:00
flake: add coding-agent validation workflow
This commit is contained in:
+159
-10
@@ -1,36 +1,50 @@
|
||||
# Reference: https://github.com/ryoppippi/dotfiles/blob/main/.github/workflows/nix-build.yaml
|
||||
name: "CI: NixOS"
|
||||
name: "CI: Nix"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .gitignore
|
||||
- AGENTS.md
|
||||
- README.md
|
||||
- "docs/**"
|
||||
- flake.nix
|
||||
- flake.lock
|
||||
- ".codex/**"
|
||||
- ".github/**"
|
||||
- ".vscode/**"
|
||||
- "flake/**"
|
||||
- "hosts/**"
|
||||
- "libs/**"
|
||||
- "modules/**"
|
||||
- "opencode.json"
|
||||
- "overlays/**"
|
||||
- "scripts/**"
|
||||
- "shells/**"
|
||||
- "skills/**"
|
||||
- "tests/**"
|
||||
- ".github/actions/check-nixos/**"
|
||||
- ".github/actions/setup-nix/**"
|
||||
- ".github/workflows/nixos.yaml"
|
||||
pull_request:
|
||||
paths:
|
||||
- .gitignore
|
||||
- AGENTS.md
|
||||
- README.md
|
||||
- "docs/**"
|
||||
- flake.nix
|
||||
- flake.lock
|
||||
- ".codex/**"
|
||||
- ".github/**"
|
||||
- ".vscode/**"
|
||||
- "flake/**"
|
||||
- "hosts/**"
|
||||
- "libs/**"
|
||||
- "modules/**"
|
||||
- "opencode.json"
|
||||
- "overlays/**"
|
||||
- "scripts/**"
|
||||
- "shells/**"
|
||||
- "skills/**"
|
||||
- "tests/**"
|
||||
- ".github/actions/check-nixos/**"
|
||||
- ".github/actions/setup-nix/**"
|
||||
- ".github/workflows/nixos.yaml"
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -38,14 +52,149 @@ concurrency:
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
check:
|
||||
name: Check all NixOS configurations
|
||||
validate:
|
||||
name: Plan, lint, and evaluate
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 120
|
||||
outputs:
|
||||
build_linux: ${{ steps.plan.outputs.build_linux }}
|
||||
build_darwin: ${{ steps.plan.outputs.build_darwin }}
|
||||
nix_validation: ${{ steps.plan.outputs.nix_validation }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nix
|
||||
uses: ./.github/actions/setup-nix
|
||||
- name: Check NixOS configurations
|
||||
- name: Plan validation
|
||||
id: plan
|
||||
env:
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
PUSH_BASE_SHA: ${{ github.event.before }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
case "${{ github.event_name }}" in
|
||||
pull_request)
|
||||
plan="$(nix run .#check -- plan --base "$PR_BASE_SHA" --json)"
|
||||
;;
|
||||
push)
|
||||
plan="$(nix run .#check -- plan --base "$PUSH_BASE_SHA" --json)"
|
||||
;;
|
||||
*)
|
||||
plan="$(nix run .#check -- plan --all-files --all-hosts --json)"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf '%s\n' "$plan"
|
||||
nix_validation="$(jq -r '.requiresNixValidation' <<<"$plan")"
|
||||
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
build_linux="$(jq -r '.nativeBuildSystems["x86_64-linux"] // false' <<<"$plan")"
|
||||
build_darwin="$(jq -r '.nativeBuildSystems["aarch64-darwin"] // false' <<<"$plan")"
|
||||
else
|
||||
build_linux="$nix_validation"
|
||||
build_darwin="$nix_validation"
|
||||
fi
|
||||
|
||||
{
|
||||
echo "nix_validation=$nix_validation"
|
||||
echo "build_linux=$build_linux"
|
||||
echo "build_darwin=$build_darwin"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
- name: Run fast checks
|
||||
env:
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
PUSH_BASE_SHA: ${{ github.event.before }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
case "${{ github.event_name }}" in
|
||||
pull_request)
|
||||
nix run .#check -- fast --base "$PR_BASE_SHA"
|
||||
;;
|
||||
push)
|
||||
nix run .#check -- fast --base "$PUSH_BASE_SHA"
|
||||
;;
|
||||
*)
|
||||
nix run .#check -- fast --all-files
|
||||
;;
|
||||
esac
|
||||
- name: Evaluate configurations
|
||||
if: steps.plan.outputs.nix_validation == 'true' || github.event_name == 'workflow_dispatch'
|
||||
env:
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
PUSH_BASE_SHA: ${{ github.event.before }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
case "${{ github.event_name }}" in
|
||||
pull_request)
|
||||
nix run .#check -- eval --base "$PR_BASE_SHA"
|
||||
;;
|
||||
push)
|
||||
nix run .#check -- eval --base "$PUSH_BASE_SHA" --all-systems
|
||||
;;
|
||||
*)
|
||||
nix run .#check -- eval --all-hosts --all-systems
|
||||
;;
|
||||
esac
|
||||
|
||||
build-linux:
|
||||
name: Build Linux checks
|
||||
needs: validate
|
||||
if: needs.validate.outputs.build_linux == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 180
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nix
|
||||
uses: ./.github/actions/setup-nix
|
||||
- name: Build affected Linux checks
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix run .#check -- build --base "$PR_BASE_SHA"
|
||||
- name: Build all Linux checks
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: ./.github/actions/check-nixos
|
||||
|
||||
build-darwin:
|
||||
name: Build Darwin checks
|
||||
needs: validate
|
||||
if: needs.validate.outputs.build_darwin == 'true'
|
||||
runs-on: macos-15
|
||||
timeout-minutes: 180
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nix
|
||||
uses: ./.github/actions/setup-nix
|
||||
- name: Build affected Darwin checks
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix run .#check -- build --base "$PR_BASE_SHA"
|
||||
- name: Build all Darwin checks
|
||||
if: github.event_name != 'pull_request'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix run .#nix-fast-build -- \
|
||||
--flake .#checks.aarch64-darwin \
|
||||
--skip-cached \
|
||||
--no-nom \
|
||||
--no-link
|
||||
|
||||
@@ -12,9 +12,11 @@ permissions:
|
||||
pull-requests: write
|
||||
jobs:
|
||||
update:
|
||||
name: Update and validate flake inputs
|
||||
name: Update and check Linux
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 120
|
||||
timeout-minutes: 180
|
||||
outputs:
|
||||
changed: ${{ steps.update.outputs.changed }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
@@ -22,18 +24,78 @@ jobs:
|
||||
uses: ./.github/actions/setup-nix
|
||||
- name: Update flake inputs
|
||||
id: update
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix flake update
|
||||
if git diff --quiet -- flake.lock; then
|
||||
echo 'changed=false' >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo 'changed=true' >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Check updated NixOS configurations
|
||||
- name: Evaluate every flake system
|
||||
if: steps.update.outputs.changed == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix flake check \
|
||||
--no-build \
|
||||
--all-systems \
|
||||
--keep-going \
|
||||
--show-trace
|
||||
- name: Build Linux checks
|
||||
if: steps.update.outputs.changed == 'true'
|
||||
uses: ./.github/actions/check-nixos
|
||||
- name: Create update pull request
|
||||
- name: Upload updated lock file
|
||||
if: steps.update.outputs.changed == 'true'
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: flake-lock
|
||||
path: flake.lock
|
||||
if-no-files-found: error
|
||||
|
||||
check-darwin:
|
||||
name: Check Darwin
|
||||
needs: update
|
||||
if: needs.update.outputs.changed == 'true'
|
||||
runs-on: macos-15
|
||||
timeout-minutes: 180
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- name: Download updated lock file
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: flake-lock
|
||||
path: .
|
||||
- name: Setup Nix
|
||||
uses: ./.github/actions/setup-nix
|
||||
- name: Build Darwin checks
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nix run .#nix-fast-build -- \
|
||||
--flake .#checks.aarch64-darwin \
|
||||
--skip-cached \
|
||||
--no-nom \
|
||||
--no-link
|
||||
|
||||
pull-request:
|
||||
name: Create update pull request
|
||||
needs:
|
||||
- update
|
||||
- check-darwin
|
||||
if: needs.update.outputs.changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- name: Download validated lock file
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: flake-lock
|
||||
path: .
|
||||
- name: Create update pull request
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -45,4 +107,5 @@ jobs:
|
||||
body: |
|
||||
Automated update of `flake.lock`.
|
||||
|
||||
The updated inputs passed the Registry tests and a build of every NixOS configuration.
|
||||
The updated inputs passed all-system evaluation and native builds of
|
||||
the Linux and Darwin check sets.
|
||||
|
||||
Reference in New Issue
Block a user