Skip to content

Update flake input: crane #580

Update flake input: crane

Update flake input: crane #580

Workflow file for this run

name: "Template"
on:
workflow_dispatch:
inputs:
debug_enabled:
description: "Run the workflow with tmate.io debugging enabled"
required: true
type: boolean
default: false
force_run:
description: "Force execution even if already successful for this commit"
required: false
type: boolean
default: false
pull_request:
types: [opened, reopened, synchronize]
paths-ignore:
- "**/*.md"
- "*"
- "!flake.nix"
- "!flake.lock"
- "!pyproject.toml"
- "!justfile"
- "!packages/*/uv.lock"
- "!packages/*/pyproject.toml"
push:
branches:
- "main"
- "beta"
paths-ignore:
- "**/*.md"
- "*"
- "!flake.nix"
- "!flake.lock"
- "!pyproject.toml"
- "!justfile"
- "!packages/*/uv.lock"
- "!packages/*/pyproject.toml"
concurrency:
group: template-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
defaults:
run:
shell: bash
permissions:
contents: read
actions: write
jobs:
set-variables:
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.set-variables.outputs.debug }}
skip_ci: ${{ steps.set-variables.outputs.skip_ci }}
checkout_ref: ${{ steps.set-variables.outputs.checkout_ref }}
checkout_rev: ${{ steps.set-variables.outputs.checkout_rev }}
steps:
- name: Set action variables
id: set-variables
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
DEBUG="false"
SKIP_CI="false"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
DEBUG="${{ inputs.debug_enabled }}"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-ci') }}; then
SKIP_CI="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'actions-debug') }}; then
DEBUG="true"
fi
CHECKOUT_REF="$PR_HEAD_REF"
CHECKOUT_REV="${{ github.event.pull_request.head.sha }}"
else
CHECKOUT_REF="${{ github.ref_name }}"
CHECKOUT_REV="${{ github.sha }}"
fi
echo "DEBUG=$DEBUG"
echo "SKIP_CI=$SKIP_CI"
echo "CHECKOUT_REF=$CHECKOUT_REF"
echo "CHECKOUT_REV=$CHECKOUT_REV"
{
echo "debug=$DEBUG"
echo "skip_ci=$SKIP_CI"
echo "checkout_ref=$CHECKOUT_REF"
echo "checkout_rev=$CHECKOUT_REV"
} >> "$GITHUB_OUTPUT"
test-omnix-template:
needs: [set-variables]
runs-on: ubuntu-latest
if: |
!cancelled() &&
needs.set-variables.outputs.skip_ci != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Check execution cache
id: cache
uses: ./.github/actions/cached-ci-job
with:
hash-sources: 'flake.nix flake.lock modules/**/*.nix .github/workflows/template.yaml .github/actions/setup-nix/action.yml .github/actions/cached-ci-job/action.yaml'
force-run: ${{ inputs.force_run || 'false' }}
- name: Setup Nix
if: steps.cache.outputs.should-run == 'true'
uses: ./.github/actions/setup-nix
with:
installer: full
system: x86_64-linux
enable-cachix: true
cachix-name: ${{ vars.CACHIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Setup tmate debug session
if: steps.cache.outputs.should-run == 'true' && needs.set-variables.outputs.debug == 'true'
uses: mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3
- name: Install omnix
if: steps.cache.outputs.should-run == 'true'
run: nix --accept-flake-config profile install "github:juspay/omnix/v1.3.2"
- name: Test monorepo template initialization
if: steps.cache.outputs.should-run == 'true'
run: |
REPO_REF="github:sciexp/python-nix-template/${{ needs.set-variables.outputs.checkout_rev }}"
echo "Using repository reference: $REPO_REF"
pwd
rm -fr pnt-mono
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- init "$REPO_REF" -o pnt-mono --non-interactive --params '{
"package-name-kebab-case": "pnt-mono",
"package-name-snake-case": "pnt_mono",
"package-name-camel-case": "pntMono",
"repo-name": "pnt-mono",
"monorepo-package": true,
"git-org": "pnt-mono",
"author": "Pnt Mono",
"author-email": "mono@pnt.org",
"project-description": "Test monorepo template project",
"vscode": true,
"github-ci": true,
"docs": true,
"nix-template": true
}'
cd pnt-mono
git init
git config --local user.email "test@example.com"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"
for pkg in packages/*/; do
if [ -f "$pkg/pyproject.toml" ]; then
echo "Locking $pkg"
(cd "$pkg" && nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock)
fi
done
git add .
nix flake check --accept-flake-config
nix develop --accept-flake-config -c just test-all
- name: Test single-package template initialization
if: steps.cache.outputs.should-run == 'true'
run: |
REPO_REF="github:sciexp/python-nix-template/${{ needs.set-variables.outputs.checkout_rev }}"
echo "Using repository reference: $REPO_REF"
pwd
rm -fr pnt-new
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- init "$REPO_REF" -o pnt-new --non-interactive --params '{
"package-name-kebab-case": "pnt-new",
"package-name-snake-case": "pnt_new",
"package-name-camel-case": "pntNew",
"repo-name": "pnt-new",
"monorepo-package": false,
"git-org": "pnt-new",
"author": "Pnt New",
"author-email": "new@pnt.org",
"project-description": "Test single-package template project",
"vscode": true,
"github-ci": true,
"docs": false,
"nix-template": false
}'
cd pnt-new
git init
git config --local user.email "test@example.com"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"
for pkg in packages/*/; do
if [ -f "$pkg/pyproject.toml" ]; then
echo "Locking $pkg"
(cd "$pkg" && nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock)
fi
done
git add .
nix flake check --accept-flake-config
nix develop --accept-flake-config -c just test-all
- name: Create job result marker
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
shell: bash
run: |
mkdir -p "${{ steps.cache.outputs.cache-path }}"
cat > "${{ steps.cache.outputs.cache-path }}/marker" <<EOF
job: test-omnix-template
workflow: ${{ github.workflow }}
run_id: ${{ github.run_id }}
run_number: ${{ github.run_number }}
sha: ${{ needs.set-variables.outputs.checkout_rev }}
ref: ${{ needs.set-variables.outputs.checkout_ref }}
timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)
EOF
- name: Save execution cache
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
uses: actions/cache/save@565629816435f6c0b50676926c9b05c254113c0c # ratchet:actions/cache/save@v4
with:
path: ${{ steps.cache.outputs.cache-path }}
key: ${{ steps.cache.outputs.cache-key }}