Skip to content

Commit 13ca234

Browse files
authored
Merge pull request #1 from bodo-run/quick-install
Quick install from bodo.run
2 parents 98dfb65 + 689bc4a commit 13ca234

13 files changed

+1048
-279
lines changed

.cargo/config.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[target.x86_64-unknown-linux-gnu]
2+
rustflags = ["-C", "target-cpu=x86-64-v2"]
3+
4+
[target.x86_64-apple-darwin]
5+
rustflags = ["-C", "target-cpu=x86-64-v2"]
6+
7+
[target.aarch64-apple-darwin]
8+
rustflags = ["-C", "target-cpu=apple-m1"]
9+
10+
[target.x86_64-pc-windows-msvc]
11+
rustflags = ["-C", "target-cpu=x86-64-v2"]
12+
13+
[target.aarch64-pc-windows-msvc]
14+
rustflags = ["-C", "target-cpu=generic"]

.github/workflows/ci.yml

+91-15
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,54 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
6-
tags: [ 'v*' ]
5+
branches: [main]
6+
tags: ["v*"]
77
pull_request:
8-
branches: [ main ]
8+
branches: [main]
99

1010
env:
1111
CARGO_TERM_COLOR: always
12+
# Build optimizations
13+
CARGO_PROFILE_RELEASE_LTO: true
14+
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
15+
CARGO_PROFILE_RELEASE_PANIC: abort
16+
CARGO_PROFILE_RELEASE_OPT_LEVEL: 3
17+
CARGO_PROFILE_RELEASE_STRIP: true
18+
# Cache settings
19+
CARGO_INCREMENTAL: 0
20+
CARGO_NET_RETRY: 10
21+
RUSTUP_MAX_RETRIES: 10
22+
RUST_BACKTRACE: short
1223

1324
permissions:
1425
contents: write
1526

1627
jobs:
1728
test:
1829
name: Test
19-
runs-on: ubuntu-latest
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
os: [ubuntu-latest, windows-latest]
2034
steps:
2135
- uses: actions/checkout@v3
22-
- uses: dtolnay/rust-toolchain@stable
36+
37+
- name: Install Rust
38+
uses: dtolnay/rust-toolchain@stable
39+
2340
- uses: Swatinem/rust-cache@v2
41+
with:
42+
cache-on-failure: true
43+
44+
- name: Install Node (Windows)
45+
if: startsWith(matrix.os, 'windows-')
46+
run: choco install nodejs-lts --no-progress
47+
48+
- name: Show Node version
49+
run: node --version || echo "No Node"
50+
2451
- name: Run tests
25-
run: cargo test
52+
run: cargo test --verbose
2653

2754
lint:
2855
name: Lint
@@ -33,6 +60,8 @@ jobs:
3360
with:
3461
components: clippy
3562
- uses: Swatinem/rust-cache@v2
63+
with:
64+
cache-on-failure: true
3665
- name: Clippy
3766
run: cargo clippy -- -D warnings
3867
- name: Format check
@@ -56,43 +85,90 @@ jobs:
5685
target: aarch64-apple-darwin
5786
artifact_name: yek
5887
asset_name: yek-aarch64-apple-darwin.tar.gz
88+
- os: windows-latest
89+
target: x86_64-pc-windows-msvc
90+
artifact_name: yek.exe
91+
asset_name: yek-x86_64-pc-windows-msvc.zip
5992
steps:
6093
- uses: actions/checkout@v3
6194
- uses: dtolnay/rust-toolchain@stable
6295
with:
6396
targets: ${{ matrix.target }}
6497
- uses: Swatinem/rust-cache@v2
98+
with:
99+
cache-on-failure: true
100+
key: ${{ matrix.target }}
65101
- name: Build target
66-
run: cargo build --release --target ${{ matrix.target }}
102+
run: cargo build --release --target ${{ matrix.target }} --locked
67103
- name: Package
68104
shell: bash
69105
run: |
70106
staging="yek-${{ matrix.target }}"
71107
mkdir -p "$staging"
72-
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
73-
tar czf "${{ matrix.asset_name }}" "$staging"
108+
if [[ "${{ runner.os }}" == "Windows" ]]; then
109+
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
110+
7z a "${{ matrix.asset_name }}" "$staging"
111+
else
112+
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
113+
tar czf "${{ matrix.asset_name }}" "$staging"
114+
fi
74115
- name: Upload artifact
75116
uses: actions/upload-artifact@v3
76117
with:
77118
name: ${{ matrix.asset_name }}
78119
path: ${{ matrix.asset_name }}
79-
120+
if-no-files-found: error
121+
80122
release:
81123
name: Release
82124
needs: [test, lint, build]
83125
runs-on: ubuntu-latest
84-
if: startsWith(github.ref, 'refs/tags/')
85126
steps:
127+
- uses: actions/checkout@v3
128+
with:
129+
fetch-depth: 0
130+
- name: Semantic Release
131+
uses: cycjimmy/semantic-release-action@v4
132+
id: semantic
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86135
- uses: actions/download-artifact@v3
136+
if: steps.semantic.outputs.new_release_published == 'true'
87137
with:
88138
path: artifacts
89-
- name: List artifacts
90-
run: ls -R artifacts
91139
- name: Move artifacts
140+
if: steps.semantic.outputs.new_release_published == 'true'
92141
run: |
93142
mv artifacts/*/*.tar.gz ./
94-
- name: Create Release
143+
mv artifacts/*/*.zip ./
144+
- name: Update Release with Artifacts
145+
if: steps.semantic.outputs.new_release_published == 'true'
95146
uses: softprops/action-gh-release@v1
96147
with:
148+
tag_name: v${{ steps.semantic.outputs.new_release_version }}
97149
files: |
98-
*.tar.gz
150+
*.tar.gz
151+
*.zip
152+
- name: Copy installation script to bodo.run
153+
if: steps.semantic.outputs.new_release_published == 'true'
154+
run: |
155+
git config --global user.name 'github-actions[bot]'
156+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
157+
git clone https://${{ secrets.PAT_TOKEN }}@github.com/bodo-run/bodo-run.github.io.git
158+
cp scripts/install_yek.sh bodo-run.github.io/public/yek.sh
159+
cp scripts/install_yek.ps1 bodo-run.github.io/public/yek.ps1
160+
COMMIT_SHA=$(git rev-parse HEAD)
161+
BODO_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
162+
cd bodo-run.github.io
163+
git add public/yek.sh public/yek.ps1
164+
# Exit with 0 if no changes
165+
if git diff --exit-code; then
166+
echo "No changes to commit"
167+
exit 0
168+
fi
169+
git commit -m "Update yek installation scripts" \
170+
-m "" \
171+
-m "$BODO_COMMIT_MESSAGE" \
172+
-m "" \
173+
-m "https://github.com/bodo-run/yek/commit/$COMMIT_SHA"
174+
git push

.github/workflows/test-install.yml

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
name: Installation Test
3+
4+
on:
5+
release:
6+
types: [published]
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
test-unix-install:
11+
name: Test Unix Installation
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest]
15+
include:
16+
- os: ubuntu-latest
17+
target: x86_64-unknown-linux-gnu
18+
- os: macos-latest
19+
target: x86_64-apple-darwin
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Get install script
25+
id: get_linux_install_script
26+
shell: bash
27+
run: |
28+
script=$(awk '/<!-- LINUX_INSTALLATION_BEGIN -->/{p=1;next}/<!-- LINUX_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```')
29+
# Ensure script is not empty
30+
if [ -z "$script" ]; then
31+
echo "Error: Could not extract Linux installation script from README.md"
32+
exit 1
33+
fi
34+
# Escape multiline output
35+
script="${script//'%'/'%25'}"
36+
script="${script//$'\n'/'%0A'}"
37+
script="${script//$'\r'/'%0D'}"
38+
echo "script=$script" >> $GITHUB_OUTPUT
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
44+
45+
- name: Build yek
46+
shell: bash
47+
run: |
48+
cargo build --release --target ${{ matrix.target }} --locked
49+
# Verify binary exists
50+
binary="target/${{ matrix.target }}/release/yek"
51+
if [ ! -f "$binary" ]; then
52+
echo "Error: Binary not found at: $binary"
53+
find target -name "yek" -o -name "yek.exe"
54+
exit 1
55+
fi
56+
ls -l "$binary"
57+
58+
- name: Setup test environment
59+
shell: bash
60+
run: |
61+
# Create test directory
62+
sudo mkdir -p /usr/local/bin
63+
# Copy binary
64+
sudo cp "target/${{ matrix.target }}/release/yek" /usr/local/bin/
65+
# Make executable
66+
sudo chmod +x /usr/local/bin/yek
67+
# Verify binary is executable
68+
if ! which yek; then
69+
echo "Error: yek not found in PATH after manual installation"
70+
echo "PATH: $PATH"
71+
exit 1
72+
fi
73+
74+
- name: Test installation script
75+
run: ${{ steps.get_linux_install_script.outputs.script }}
76+
77+
- name: Verify installation
78+
run: |
79+
# Ensure yek is in PATH
80+
which yek || {
81+
echo "Error: yek not found in PATH"
82+
echo "PATH: $PATH"
83+
exit 1
84+
}
85+
# Test version output
86+
yek --version || {
87+
echo "Error: yek --version failed"
88+
exit 1
89+
}
90+
# Create test file
91+
echo "test content" > test.txt
92+
# Test basic functionality
93+
yek test.txt || {
94+
echo "Error: yek failed to process test file"
95+
exit 1
96+
}
97+
# Verify output exists
98+
test -f repo-serialized/chunk-0.txt || {
99+
echo "Error: Output file not found"
100+
ls -la repo-serialized/ || true
101+
exit 1
102+
}
103+
104+
test-windows-install:
105+
name: Test Windows Installation
106+
runs-on: windows-latest
107+
steps:
108+
- uses: actions/checkout@v3
109+
110+
- name: Get install script
111+
id: get_windows_install_script
112+
shell: bash
113+
run: |
114+
script=$(awk '/<!-- WINDOWS_INSTALLATION_BEGIN -->/{p=1;next}/<!-- WINDOWS_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```')
115+
# Ensure script is not empty
116+
if [ -z "$script" ]; then
117+
echo "Error: Could not extract Windows installation script from README.md"
118+
exit 1
119+
fi
120+
# Escape multiline output
121+
script="${script//'%'/'%25'}"
122+
script="${script//$'\n'/'%0A'}"
123+
script="${script//$'\r'/'%0D'}"
124+
echo "script=$script" >> $GITHUB_OUTPUT
125+
126+
- name: Install Rust
127+
uses: dtolnay/rust-toolchain@stable
128+
with:
129+
targets: x86_64-pc-windows-msvc
130+
131+
- name: Build yek
132+
shell: powershell
133+
run: |
134+
cargo build --release --target x86_64-pc-windows-msvc --locked
135+
# Verify binary exists
136+
$binary = "target\x86_64-pc-windows-msvc\release\yek.exe"
137+
if (-not (Test-Path $binary)) {
138+
Write-Error "Binary not found at: $binary"
139+
Get-ChildItem target -Recurse | Where-Object { $_.Name -like "yek.exe" }
140+
exit 1
141+
}
142+
Write-Host "Binary size: $((Get-Item $binary).Length) bytes"
143+
144+
- name: Setup test environment
145+
shell: powershell
146+
run: |
147+
# Create test directory
148+
New-Item -ItemType Directory -Path "$env:USERPROFILE\.local\bin" -Force
149+
# Add to PATH
150+
$env:Path = "$env:USERPROFILE\.local\bin;" + $env:Path
151+
# Copy binary
152+
Copy-Item "target\x86_64-pc-windows-msvc\release\yek.exe" "$env:USERPROFILE\.local\bin\yek.exe"
153+
# Verify binary is executable
154+
if (-not (Get-Command yek -ErrorAction SilentlyContinue)) {
155+
Write-Error "yek not found in PATH after manual installation"
156+
Write-Host "PATH: $env:Path"
157+
exit 1
158+
}
159+
160+
- name: Test installation script
161+
shell: powershell
162+
run: ${{ steps.get_windows_install_script.outputs.script }}
163+
164+
- name: Verify installation
165+
shell: powershell
166+
run: |
167+
# Ensure yek is in PATH
168+
if (-not (Get-Command yek -ErrorAction SilentlyContinue)) {
169+
Write-Error "yek not found in PATH"
170+
Write-Host "PATH: $env:PATH"
171+
exit 1
172+
}
173+
# Test version output
174+
$version = yek --version
175+
if (-not $?) {
176+
Write-Error "yek --version failed"
177+
exit 1
178+
}
179+
Write-Host "Version: $version"
180+
# Create test file
181+
"test content" | Out-File -FilePath test.txt -Encoding utf8
182+
# Test basic functionality
183+
yek test.txt
184+
if (-not $?) {
185+
Write-Error "yek failed to process test file"
186+
exit 1
187+
}
188+
# Verify output exists
189+
if (-not (Test-Path repo-serialized/chunk-0.txt)) {
190+
Write-Error "Output file not found"
191+
Get-ChildItem repo-serialized -ErrorAction SilentlyContinue
192+
exit 1
193+
}

.releaserc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/github"
7+
]
8+
}

0 commit comments

Comments
 (0)