Skip to content

Commit d6e1fbb

Browse files
committed
Initial import of project
0 parents  commit d6e1fbb

File tree

19 files changed

+1913
-0
lines changed

19 files changed

+1913
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Cache Cleanup
2+
3+
on:
4+
schedule:
5+
# Run every Sunday at 2 AM UTC
6+
- cron: '0 2 * * 0'
7+
workflow_dispatch:
8+
inputs:
9+
age_limit:
10+
description: 'Cache age limit in days'
11+
required: false
12+
default: '7'
13+
type: string
14+
15+
permissions:
16+
actions: write
17+
18+
jobs:
19+
cleanup:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Cleanup old caches
23+
run: |
24+
echo "Repository: ${{ github.repository }}"
25+
echo "Default branch: ${{ github.event.repository.default_branch }}"
26+
27+
# Set age limit
28+
AGE_LIMIT="${{ github.event.inputs.age_limit || '7' }}"
29+
echo "Age limit: ${AGE_LIMIT} days"
30+
31+
# Get current cache usage
32+
echo "Current cache usage:"
33+
gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r '.actions_caches[] | "\(.key) - \(.size_in_bytes) bytes - \(.created_at)"' | head -20
34+
35+
# Calculate cutoff date
36+
CUTOFF_DATE=$(date -d "${AGE_LIMIT} days ago" -u +"%Y-%m-%dT%H:%M:%SZ")
37+
echo "Cutoff date: ${CUTOFF_DATE}"
38+
39+
# Get list of caches to delete
40+
CACHES_TO_DELETE=$(gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r --arg cutoff "$CUTOFF_DATE" '.actions_caches[] | select(.created_at < $cutoff) | .id')
41+
42+
# Count caches to delete
43+
CACHE_COUNT=$(echo "$CACHES_TO_DELETE" | wc -l)
44+
if [ -z "$CACHES_TO_DELETE" ] || [ "$CACHE_COUNT" -eq 0 ]; then
45+
echo "No caches found older than ${AGE_LIMIT} days"
46+
else
47+
echo "Found ${CACHE_COUNT} caches to delete"
48+
49+
# Delete old caches
50+
for cache_id in $CACHES_TO_DELETE; do
51+
if [ -n "$cache_id" ]; then
52+
echo "Deleting cache ID: ${cache_id}"
53+
gh api --method DELETE repos/${{ github.repository }}/actions/caches/${cache_id} || echo "Failed to delete cache ${cache_id}"
54+
fi
55+
done
56+
fi
57+
58+
# Get list of all branches
59+
ALL_BRANCHES=$(gh api repos/${{ github.repository }}/branches --paginate | jq -r '.[].name')
60+
61+
# Get list of caches
62+
ALL_CACHE_REFS=$(gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r '.actions_caches[].ref')
63+
64+
# Find caches for deleted branches
65+
echo "Checking for caches from deleted branches..."
66+
for cache_ref in $ALL_CACHE_REFS; do
67+
# Extract branch name from ref (format: refs/heads/branch-name)
68+
BRANCH_NAME=$(echo "$cache_ref" | sed 's|refs/heads/||')
69+
70+
# Skip if it's a pull request ref or tag ref
71+
if [[ "$cache_ref" =~ refs/pull/ ]] || [[ "$cache_ref" =~ refs/tags/ ]]; then
72+
continue
73+
fi
74+
75+
# Check if branch still exists
76+
if ! echo "$ALL_BRANCHES" | grep -q "^${BRANCH_NAME}$"; then
77+
echo "Found caches for deleted branch: ${BRANCH_NAME}"
78+
79+
# Get cache IDs for this branch
80+
BRANCH_CACHE_IDS=$(gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r --arg ref "$cache_ref" '.actions_caches[] | select(.ref == $ref) | .id')
81+
82+
# Delete caches for this branch
83+
for cache_id in $BRANCH_CACHE_IDS; do
84+
if [ -n "$cache_id" ]; then
85+
echo "Deleting cache ID ${cache_id} for deleted branch ${BRANCH_NAME}"
86+
gh api --method DELETE repos/${{ github.repository }}/actions/caches/${cache_id} || echo "Failed to delete cache ${cache_id}"
87+
fi
88+
done
89+
fi
90+
done
91+
92+
echo "Cache cleanup completed"
93+
94+
# Show final cache usage
95+
echo "Final cache usage:"
96+
gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r '.actions_caches[] | "\(.key) - \(.size_in_bytes) bytes - \(.created_at)"' | head -10
97+
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- name: "macOS Universal"
20+
runner: macos-15
21+
platform: "macOS"
22+
xcode: "16.4"
23+
arch: "universal"
24+
comprehensive_test: true
25+
lint_check: true
26+
- name: "Linux x86_64"
27+
runner: ubuntu-latest
28+
platform: "Linux"
29+
arch: "x86_64"
30+
triple: "x86_64-unknown-linux-gnu"
31+
comprehensive_test: true
32+
lint_check: true
33+
- name: "Linux ARM64"
34+
runner: ubuntu-24.04-arm
35+
platform: "Linux"
36+
arch: "aarch64"
37+
triple: "aarch64-unknown-linux-gnu"
38+
comprehensive_test: true
39+
lint_check: true
40+
41+
runs-on: ${{ matrix.runner }}
42+
name: ${{ matrix.name }}
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Setup Xcode
49+
if: matrix.platform == 'macOS'
50+
uses: maxim-lobanov/setup-xcode@v1
51+
with:
52+
xcode-version: ${{ matrix.xcode }}
53+
54+
- name: Setup Swift (Linux only)
55+
if: matrix.platform == 'Linux'
56+
run: |
57+
# Check if Swift is already available
58+
if command -v swift >/dev/null 2>&1; then
59+
echo "Swift is already available:"
60+
swift --version
61+
else
62+
echo "Installing Swift using Swiftly..."
63+
64+
# Install Swiftly
65+
curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash
66+
67+
# Add Swiftly to PATH for current session
68+
export PATH="$HOME/.local/bin:$PATH"
69+
echo "$HOME/.local/bin" >> $GITHUB_PATH
70+
71+
# Install latest Swift toolchain
72+
swiftly install latest
73+
swiftly use latest
74+
75+
echo "Swift installation completed:"
76+
swift --version
77+
fi
78+
79+
- name: Cache Swift Package Manager
80+
uses: actions/cache@v4
81+
with:
82+
path: |
83+
.build
84+
~/.cache/org.swift.swiftpm
85+
key: ${{ runner.os }}-${{ matrix.arch }}-spm-${{ hashFiles('Package.swift', 'Package.resolved') }}-ci
86+
restore-keys: |
87+
${{ runner.os }}-${{ matrix.arch }}-spm-
88+
89+
- name: Swift format lint (check only)
90+
if: matrix.lint_check
91+
run: |
92+
if command -v swift-format >/dev/null 2>&1; then
93+
swift-format lint --recursive Sources/ Plugins/
94+
else
95+
echo "swift-format not available, skipping lint check"
96+
fi
97+
98+
- name: Build package
99+
run: |
100+
if [ "${{ matrix.platform }}" = "macOS" ] && [ "${{ matrix.arch }}" = "universal" ]; then
101+
# Build universal binary for macOS
102+
swift build --configuration release --arch arm64
103+
swift build --configuration release --arch x86_64
104+
elif [ "${{ matrix.platform }}" = "Linux" ]; then
105+
swift build --configuration release --triple ${{ matrix.triple }} --static-swift-stdlib
106+
else
107+
swift build --configuration release
108+
fi
109+
110+
- name: Run tests
111+
if: matrix.comprehensive_test
112+
run: swift test
113+
114+
- name: Smoke test CLI tools
115+
if: matrix.comprehensive_test
116+
run: |
117+
# Basic smoke tests - just verify help works
118+
swift run BuildEnvironmentExtractor --help
119+
swift run GitInfoExtractor --help

0 commit comments

Comments
 (0)