Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ jobs:

- name: Build
run: pnpm run build
- name: Git Status
run: pnpm run test:git
- name: Unit Tests
run: pnpm run test


next:
name: 'Publish @next'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ jobs:
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm test:git
- run: pnpm test
- run: git status
- run: git diff

- run: pnpm config set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
env:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"slack:notify": "cd tools/slack && pnpm notify",
"test:imports": "cd tools/import-tests && pnpm test",
"test": "pnpm lint && pnpm --filter \"./packages/**\" test && pnpm test:imports",
"test:git": "pnpm exec scripts/status-check.sh",
"version": "pnpm changeset version && pnpm run changelog"
},
"author": "Open Function Group",
Expand Down
98 changes: 98 additions & 0 deletions scripts/status-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this AI generated? It looks a lot more involved and complicated than I expect

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's mostly ai generate. I was facing some challenge with actions/checkout@v3. Went to AI for help

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK but make sure to really scrutinise what the AI is telling you. It's like you've handed the work out to an external contractor - sure they've delivered something that looks cool, but is it really what we want? Will the maintenance cost outweigh the development cost?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, thanks for the feedback


# Check if git working tree is clean
# This script will fail if there are uncommitted changes

set -e

echo "Checking if git working tree is clean..."

# Check if we're in a CI environment
Comment thread
mtuchi marked this conversation as resolved.
Outdated
if [ -n "$CI" ] || [ -n "$GITHUB_ACTIONS" ]; then
echo "Running in CI environment, checking git status..."

# Debug information for CI
echo "CI environment variables:"
Comment thread
mtuchi marked this conversation as resolved.
Outdated
echo " CI: $CI"
echo " GITHUB_ACTIONS: $GITHUB_ACTIONS"
echo " GITHUB_WORKSPACE: $GITHUB_WORKSPACE"

# In CI, we might have a shallow clone or different git state
# First check if we're in a git repository
Comment thread
mtuchi marked this conversation as resolved.
Outdated
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "Warning: Not in a git repository in CI, skipping git checks"
echo "✓ Git checks skipped in CI environment"
exit 0
fi

# Check if we have a valid HEAD (might be detached in CI)
if ! git rev-parse HEAD > /dev/null 2>&1; then
echo "Warning: No valid HEAD in CI, skipping git checks"
echo "✓ Git checks skipped in CI environment"
exit 0
fi

# Check if this is a shallow clone (common with actions/checkout@v3)
if [ -f ".git/shallow" ]; then
Comment thread
hunterachieng marked this conversation as resolved.
Outdated
echo "Warning: Shallow clone detected in CI, this may affect git checks"
fi

# In CI, try to check git status but be more lenient
echo "CI environment detected - performing basic git checks..."

# Show git status for debugging
echo "Git status:"
git status --porcelain || echo "Could not get git status"
echo ""

# In CI, we'll be more lenient and just check for obvious uncommitted changes
# rather than using diff-index which can be problematic with shallow clones
if git diff --name-only HEAD 2>/dev/null | grep -q .; then
echo "Error: Working tree has uncommitted changes:"
echo ""
git status --porcelain
echo ""
echo "Please commit or stash these changes before proceeding."
exit 1
fi

# Check for untracked files
untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | head -10)
if [ -n "$untracked_files" ]; then
echo "Warning: Found untracked files in CI:"
echo "$untracked_files"
echo ""
echo "Continuing with build in CI environment..."
fi

echo "✓ Git checks passed in CI environment"
exit 0
fi

# For non-CI environments, use the original strict checking
# Check if there are any uncommitted changes
if ! git diff-index --quiet HEAD -- 2>/dev/null; then
echo "Error: Working tree has uncommitted changes:"
echo ""
git status --porcelain
echo ""
echo "Please commit or stash these changes before proceeding."
Comment thread
mtuchi marked this conversation as resolved.
exit 1
fi

# Check if there are any untracked files that should be tracked
# Look for common files that should be committed after build
untracked_important_files=$(git ls-files --others --exclude-standard 2>/dev/null | grep -E '\.(json|js|ts|md)$' | head -10)
Comment thread
mtuchi marked this conversation as resolved.
Outdated

if [ -n "$untracked_important_files" ]; then
echo "Warning: Found untracked files that might need to be committed:"
echo "$untracked_important_files"
echo ""
echo "If these are build artifacts, consider adding them to .gitignore"
echo "If they should be committed, please add and commit them."
echo ""
echo "Continuing with build..."
fi

echo "✓ Git working tree is clean"
exit 0