feat: dynamic probing (#71)

This commit is contained in:
LowderPlay
2026-06-06 03:03:48 +05:00
committed by GitHub
parent 7d11e14804
commit f828302ea6
60 changed files with 3761 additions and 641 deletions
+76 -75
View File
@@ -1,80 +1,81 @@
name: Build Rust Application
name: Build Rust Application
on:
push:
branches: [ master ]
tags: [ 'v*.*.*' ]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
linux-amd64:
name: Linux amd64 (.deb)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build Debian package
run: cargo deb -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-amd64-deb
path: target/debian/*.deb
compression-level: 0
linux-arm64:
name: Linux arm64 (.deb via cross)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-gnu"
args: "--release --bin cheburchecker"
strip: true
- name: Create Debian archive
run: cargo deb --target aarch64-unknown-linux-gnu --no-strip --no-build -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-arm64-deb
path: target/aarch64-unknown-linux-gnu/debian/*.deb
windows:
name: Windows amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: windows-amd64-exe
path: target/release/*.exe
env:
CARGO_TERM_COLOR: always
jobs:
linux-amd64:
name: Linux amd64 (.deb)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build Debian package
run: cargo deb -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-amd64-deb
path: target/debian/*.deb
compression-level: 0
linux-arm64:
name: Linux arm64 (.deb via cross)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-gnu"
args: "--release --bin cheburchecker"
strip: true
- name: Create Debian archive
run: cargo deb --target aarch64-unknown-linux-gnu --no-strip --no-build -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-arm64-deb
path: target/aarch64-unknown-linux-gnu/debian/*.deb
windows:
name: Windows amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: windows-amd64-exe
path: target/release/*.exe
+183
View File
@@ -0,0 +1,183 @@
name: Build Probe
on:
push:
branches: [ master ]
tags: [ 'v*.*.*' ]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-probe
jobs:
linux-amd64:
name: Linux amd64 binary and .deb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
run: cargo build --release --package probe --bin cheburprobe
- name: Build Debian package
run: cargo deb --package probe --no-build -- --bin cheburprobe
- name: Upload Linux amd64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-amd64
path: target/release/cheburprobe
compression-level: 0
- name: Upload Linux amd64 Debian package
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-amd64-deb
path: target/debian/*.deb
compression-level: 0
linux-arm64:
name: Linux arm64 binary and .deb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-gnu"
args: "--release --package probe --bin cheburprobe"
strip: true
- name: Build Debian package
run: cargo deb --package probe --target aarch64-unknown-linux-gnu --no-strip --no-build -- --bin cheburprobe
- name: Upload Linux arm64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-arm64
path: target/aarch64-unknown-linux-gnu/release/cheburprobe
compression-level: 0
- name: Upload Linux arm64 Debian package
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-arm64-deb
path: target/aarch64-unknown-linux-gnu/debian/*.deb
compression-level: 0
windows-amd64:
name: Windows amd64 binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --package probe --bin cheburprobe
- name: Upload Windows amd64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-windows-amd64
path: target/release/cheburprobe.exe
compression-level: 0
docker:
name: Docker image amd64/arm64
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
id: setup-buildx
uses: docker/setup-buildx-action@v4
- name: Cache Rust Docker build mounts
id: rust-build-cache
uses: actions/cache@v4
with:
path: rust-build-cache
key: ${{ runner.os }}-probe-docker-rust-${{ hashFiles('**/Cargo.lock', 'probe/Dockerfile') }}
restore-keys: |
${{ runner.os }}-probe-docker-rust-
- name: Restore Rust Docker build cache
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-map: |
{
"rust-build-cache/probe-target": {
"target": "/build/target",
"id": "probe-target"
},
"rust-build-cache/cargo-registry": {
"target": "/usr/local/cargo/registry",
"id": "cargo-registry"
},
"rust-build-cache/cargo-git": {
"target": "/usr/local/cargo/git",
"id": "cargo-git"
}
}
skip-extraction: ${{ steps.rust-build-cache.outputs.cache-hit }}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./probe/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+154
View File
@@ -0,0 +1,154 @@
name: Draft Release
on:
push:
tags: [ 'v*.*.*' ]
permissions:
actions: read
contents: write
concurrency:
group: draft-release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
draft-release:
name: Draft GitHub release
runs-on: ubuntu-latest
steps:
- name: Collect build artifacts
uses: actions/github-script@v8
env:
TAG_NAME: ${{ github.ref_name }}
WORKFLOWS: |
Build Rust Application
Build Probe
with:
script: |
const fs = require('fs');
const path = require('path');
const owner = context.repo.owner;
const repo = context.repo.repo;
const tagName = process.env.TAG_NAME;
const workflows = process.env.WORKFLOWS
.split(/\r?\n/)
.map((name) => name.trim())
.filter(Boolean);
const targetSha = context.sha;
const outDir = path.join(process.cwd(), 'artifact-archives');
const pollDelayMs = 30_000;
const timeoutMs = 30 * 60 * 1000;
fs.mkdirSync(outDir, { recursive: true });
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function findWorkflowRun(workflowName) {
const startedAt = Date.now();
while (Date.now() - startedAt < timeoutMs) {
const runs = await github.paginate(
github.rest.actions.listWorkflowRunsForRepo,
{
owner,
repo,
head_sha: targetSha,
event: 'push',
per_page: 100,
},
);
const run = runs.find((candidate) =>
candidate.name === workflowName &&
candidate.head_sha === targetSha &&
candidate.head_branch === tagName
);
if (run?.status === 'completed') {
if (run.conclusion === 'success') {
return run;
}
throw new Error(
`${workflowName} completed with conclusion ${run.conclusion}: ${run.html_url}`,
);
}
core.info(
run
? `${workflowName} is ${run.status}; waiting for completion.`
: `Waiting for ${workflowName} to start for ${tagName}.`,
);
await sleep(pollDelayMs);
}
throw new Error(`Timed out waiting for ${workflowName} on ${tagName}.`);
}
for (const workflowName of workflows) {
const run = await findWorkflowRun(workflowName);
core.info(`Downloading artifacts from ${workflowName}: ${run.html_url}`);
const artifacts = await github.paginate(
github.rest.actions.listWorkflowRunArtifacts,
{
owner,
repo,
run_id: run.id,
per_page: 100,
},
);
for (const artifact of artifacts.filter((item) => !item.expired)) {
const archive = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
const artifactPath = path.join(outDir, `${artifact.name}.zip`);
fs.writeFileSync(artifactPath, Buffer.from(archive.data));
core.info(`Saved ${artifactPath}`);
}
}
- name: Extract release assets
shell: bash
run: |
set -euo pipefail
mkdir -p release-artifacts
for archive in artifact-archives/*.zip; do
artifact_name="$(basename "$archive" .zip)"
extract_dir="$(mktemp -d)"
unzip -q "$archive" -d "$extract_dir"
while IFS= read -r -d '' file; do
filename="$(basename "$file")"
target="release-artifacts/$filename"
if [ -e "$target" ]; then
target="release-artifacts/${artifact_name}-${filename}"
fi
mv "$file" "$target"
done < <(find "$extract_dir" -type f -print0)
rm -rf "$extract_dir"
done
- name: Publish draft release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: true
fail_on_unmatched_files: true
files: release-artifacts/*