Skip to content

Commit

Permalink
Merge pull request #1 from bodo-run/quick-install
Browse files Browse the repository at this point in the history
Quick install from bodo.run
  • Loading branch information
mohsen1 authored Jan 19, 2025
2 parents 98dfb65 + 689bc4a commit 13ca234
Show file tree
Hide file tree
Showing 13 changed files with 1,048 additions and 279 deletions.
14 changes: 14 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-cpu=x86-64-v2"]

[target.x86_64-apple-darwin]
rustflags = ["-C", "target-cpu=x86-64-v2"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "target-cpu=apple-m1"]

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-cpu=x86-64-v2"]

[target.aarch64-pc-windows-msvc]
rustflags = ["-C", "target-cpu=generic"]
106 changes: 91 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,54 @@ name: CI

on:
push:
branches: [ main ]
tags: [ 'v*' ]
branches: [main]
tags: ["v*"]
pull_request:
branches: [ main ]
branches: [main]

env:
CARGO_TERM_COLOR: always
# Build optimizations
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_PANIC: abort
CARGO_PROFILE_RELEASE_OPT_LEVEL: 3
CARGO_PROFILE_RELEASE_STRIP: true
# Cache settings
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short

permissions:
contents: write

jobs:
test:
name: Test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install Node (Windows)
if: startsWith(matrix.os, 'windows-')
run: choco install nodejs-lts --no-progress

- name: Show Node version
run: node --version || echo "No Node"

- name: Run tests
run: cargo test
run: cargo test --verbose

lint:
name: Lint
Expand All @@ -33,6 +60,8 @@ jobs:
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format check
Expand All @@ -56,43 +85,90 @@ jobs:
target: aarch64-apple-darwin
artifact_name: yek
asset_name: yek-aarch64-apple-darwin.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: yek.exe
asset_name: yek-x86_64-pc-windows-msvc.zip
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.target }}
- name: Build target
run: cargo build --release --target ${{ matrix.target }}
run: cargo build --release --target ${{ matrix.target }} --locked
- name: Package
shell: bash
run: |
staging="yek-${{ matrix.target }}"
mkdir -p "$staging"
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
tar czf "${{ matrix.asset_name }}" "$staging"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
7z a "${{ matrix.asset_name }}" "$staging"
else
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
tar czf "${{ matrix.asset_name }}" "$staging"
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}

if-no-files-found: error

release:
name: Release
needs: [test, lint, build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
if: steps.semantic.outputs.new_release_published == 'true'
with:
path: artifacts
- name: List artifacts
run: ls -R artifacts
- name: Move artifacts
if: steps.semantic.outputs.new_release_published == 'true'
run: |
mv artifacts/*/*.tar.gz ./
- name: Create Release
mv artifacts/*/*.zip ./
- name: Update Release with Artifacts
if: steps.semantic.outputs.new_release_published == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.semantic.outputs.new_release_version }}
files: |
*.tar.gz
*.tar.gz
*.zip
- name: Copy installation script to bodo.run
if: steps.semantic.outputs.new_release_published == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone https://${{ secrets.PAT_TOKEN }}@github.com/bodo-run/bodo-run.github.io.git
cp scripts/install_yek.sh bodo-run.github.io/public/yek.sh
cp scripts/install_yek.ps1 bodo-run.github.io/public/yek.ps1
COMMIT_SHA=$(git rev-parse HEAD)
BODO_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
cd bodo-run.github.io
git add public/yek.sh public/yek.ps1
# Exit with 0 if no changes
if git diff --exit-code; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update yek installation scripts" \
-m "" \
-m "$BODO_COMMIT_MESSAGE" \
-m "" \
-m "https://github.com/bodo-run/yek/commit/$COMMIT_SHA"
git push
193 changes: 193 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
name: Installation Test

on:
release:
types: [published]
workflow_dispatch: {}

jobs:
test-unix-install:
name: Test Unix Installation
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Get install script
id: get_linux_install_script
shell: bash
run: |
script=$(awk '/<!-- LINUX_INSTALLATION_BEGIN -->/{p=1;next}/<!-- LINUX_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```')
# Ensure script is not empty
if [ -z "$script" ]; then
echo "Error: Could not extract Linux installation script from README.md"
exit 1
fi
# Escape multiline output
script="${script//'%'/'%25'}"
script="${script//$'\n'/'%0A'}"
script="${script//$'\r'/'%0D'}"
echo "script=$script" >> $GITHUB_OUTPUT
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Build yek
shell: bash
run: |
cargo build --release --target ${{ matrix.target }} --locked
# Verify binary exists
binary="target/${{ matrix.target }}/release/yek"
if [ ! -f "$binary" ]; then
echo "Error: Binary not found at: $binary"
find target -name "yek" -o -name "yek.exe"
exit 1
fi
ls -l "$binary"
- name: Setup test environment
shell: bash
run: |
# Create test directory
sudo mkdir -p /usr/local/bin
# Copy binary
sudo cp "target/${{ matrix.target }}/release/yek" /usr/local/bin/
# Make executable
sudo chmod +x /usr/local/bin/yek
# Verify binary is executable
if ! which yek; then
echo "Error: yek not found in PATH after manual installation"
echo "PATH: $PATH"
exit 1
fi
- name: Test installation script
run: ${{ steps.get_linux_install_script.outputs.script }}

- name: Verify installation
run: |
# Ensure yek is in PATH
which yek || {
echo "Error: yek not found in PATH"
echo "PATH: $PATH"
exit 1
}
# Test version output
yek --version || {
echo "Error: yek --version failed"
exit 1
}
# Create test file
echo "test content" > test.txt
# Test basic functionality
yek test.txt || {
echo "Error: yek failed to process test file"
exit 1
}
# Verify output exists
test -f repo-serialized/chunk-0.txt || {
echo "Error: Output file not found"
ls -la repo-serialized/ || true
exit 1
}
test-windows-install:
name: Test Windows Installation
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Get install script
id: get_windows_install_script
shell: bash
run: |
script=$(awk '/<!-- WINDOWS_INSTALLATION_BEGIN -->/{p=1;next}/<!-- WINDOWS_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```')
# Ensure script is not empty
if [ -z "$script" ]; then
echo "Error: Could not extract Windows installation script from README.md"
exit 1
fi
# Escape multiline output
script="${script//'%'/'%25'}"
script="${script//$'\n'/'%0A'}"
script="${script//$'\r'/'%0D'}"
echo "script=$script" >> $GITHUB_OUTPUT
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- name: Build yek
shell: powershell
run: |
cargo build --release --target x86_64-pc-windows-msvc --locked
# Verify binary exists
$binary = "target\x86_64-pc-windows-msvc\release\yek.exe"
if (-not (Test-Path $binary)) {
Write-Error "Binary not found at: $binary"
Get-ChildItem target -Recurse | Where-Object { $_.Name -like "yek.exe" }
exit 1
}
Write-Host "Binary size: $((Get-Item $binary).Length) bytes"
- name: Setup test environment
shell: powershell
run: |
# Create test directory
New-Item -ItemType Directory -Path "$env:USERPROFILE\.local\bin" -Force
# Add to PATH
$env:Path = "$env:USERPROFILE\.local\bin;" + $env:Path
# Copy binary
Copy-Item "target\x86_64-pc-windows-msvc\release\yek.exe" "$env:USERPROFILE\.local\bin\yek.exe"
# Verify binary is executable
if (-not (Get-Command yek -ErrorAction SilentlyContinue)) {
Write-Error "yek not found in PATH after manual installation"
Write-Host "PATH: $env:Path"
exit 1
}
- name: Test installation script
shell: powershell
run: ${{ steps.get_windows_install_script.outputs.script }}

- name: Verify installation
shell: powershell
run: |
# Ensure yek is in PATH
if (-not (Get-Command yek -ErrorAction SilentlyContinue)) {
Write-Error "yek not found in PATH"
Write-Host "PATH: $env:PATH"
exit 1
}
# Test version output
$version = yek --version
if (-not $?) {
Write-Error "yek --version failed"
exit 1
}
Write-Host "Version: $version"
# Create test file
"test content" | Out-File -FilePath test.txt -Encoding utf8
# Test basic functionality
yek test.txt
if (-not $?) {
Write-Error "yek failed to process test file"
exit 1
}
# Verify output exists
if (-not (Test-Path repo-serialized/chunk-0.txt)) {
Write-Error "Output file not found"
Get-ChildItem repo-serialized -ErrorAction SilentlyContinue
exit 1
}
8 changes: 8 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
Loading

0 comments on commit 13ca234

Please sign in to comment.