Skip to content

Commit 13599f4

Browse files
committed
init
0 parents  commit 13599f4

9 files changed

Lines changed: 2411 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
concurrency:
9+
group: ci-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
RUSTFLAGS: -D warnings
15+
16+
jobs:
17+
validate:
18+
name: Lint & test
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: dtolnay/rust-toolchain@stable
24+
with:
25+
components: rustfmt, clippy
26+
27+
- uses: Swatinem/rust-cache@v2
28+
29+
- name: Format
30+
run: cargo fmt --all -- --check
31+
32+
- name: Clippy
33+
run: cargo clippy --all-targets --all-features -- -D warnings
34+
35+
- name: Test
36+
run: cargo test --all-features

.github/workflows/release.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
BIN_NAME: attachmentav
14+
15+
jobs:
16+
build:
17+
name: Build ${{ matrix.target }}
18+
runs-on: ${{ matrix.runner }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- target: x86_64-unknown-linux-gnu
24+
runner: ubuntu-latest
25+
archive: tar.gz
26+
- target: aarch64-unknown-linux-gnu
27+
runner: ubuntu-24.04-arm
28+
archive: tar.gz
29+
- target: x86_64-apple-darwin
30+
runner: macos-13
31+
archive: tar.gz
32+
- target: aarch64-apple-darwin
33+
runner: macos-latest
34+
archive: tar.gz
35+
- target: x86_64-pc-windows-msvc
36+
runner: windows-latest
37+
archive: zip
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
44+
45+
- uses: Swatinem/rust-cache@v2
46+
with:
47+
key: ${{ matrix.target }}
48+
49+
- name: Build
50+
run: cargo build --release --locked --target ${{ matrix.target }}
51+
52+
- name: Package (tar.gz)
53+
if: matrix.archive == 'tar.gz'
54+
shell: bash
55+
run: |
56+
set -euo pipefail
57+
name="${BIN_NAME}-${GITHUB_REF_NAME}-${{ matrix.target }}"
58+
mkdir "$name"
59+
cp "target/${{ matrix.target }}/release/${BIN_NAME}" "$name/"
60+
tar -czf "${name}.tar.gz" "$name"
61+
shasum -a 256 "${name}.tar.gz" > "${name}.tar.gz.sha256"
62+
echo "ASSET=${name}.tar.gz" >> "$GITHUB_ENV"
63+
echo "CHECKSUM=${name}.tar.gz.sha256" >> "$GITHUB_ENV"
64+
65+
- name: Package (zip)
66+
if: matrix.archive == 'zip'
67+
shell: pwsh
68+
run: |
69+
$name = "$env:BIN_NAME-$env:GITHUB_REF_NAME-${{ matrix.target }}"
70+
New-Item -ItemType Directory -Path $name | Out-Null
71+
Copy-Item "target/${{ matrix.target }}/release/$env:BIN_NAME.exe" "$name/"
72+
Compress-Archive -Path $name -DestinationPath "$name.zip"
73+
$hash = (Get-FileHash -Algorithm SHA256 "$name.zip").Hash.ToLower()
74+
"$hash $name.zip" | Out-File -Encoding ascii "$name.zip.sha256"
75+
"ASSET=$name.zip" | Out-File -FilePath $env:GITHUB_ENV -Append
76+
"CHECKSUM=$name.zip.sha256" | Out-File -FilePath $env:GITHUB_ENV -Append
77+
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: ${{ matrix.target }}
82+
path: |
83+
${{ env.ASSET }}
84+
${{ env.CHECKSUM }}
85+
86+
release:
87+
name: Publish release
88+
needs: build
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/download-artifact@v4
92+
with:
93+
path: artifacts
94+
merge-multiple: true
95+
96+
- name: Create GitHub release
97+
uses: softprops/action-gh-release@v2
98+
with:
99+
files: artifacts/*
100+
generate_release_notes: true

.github/workflows/smoke.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Smoke
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: smoke-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
smoke:
17+
name: Smoke test against EU API
18+
runs-on: ubuntu-latest
19+
env:
20+
ATTACHMENTAV_API_KEY: ${{ secrets.ATTACHMENTAV_API_KEY }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: dtolnay/rust-toolchain@stable
25+
26+
- uses: Swatinem/rust-cache@v2
27+
28+
- name: Build release binary
29+
run: cargo build --release --locked
30+
31+
- name: Verify --help
32+
run: ./target/release/attachmentav --help
33+
34+
- name: Scan clean input via stdin
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
output=$(printf 'hello attachmentav smoke test' | ./target/release/attachmentav)
39+
echo "output: $output"
40+
[ "$output" = "clean" ]
41+
42+
- name: Scan EICAR via stdin
43+
shell: bash
44+
run: |
45+
set +e
46+
output=$(printf 'X5O!P%%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' | ./target/release/attachmentav)
47+
rc=$?
48+
set -e
49+
echo "output: $output"
50+
echo "exit: $rc"
51+
if [ "$rc" -ne 1 ]; then
52+
echo "expected exit 1 (infected), got $rc"
53+
exit 1
54+
fi
55+
case "$output" in
56+
infected:*) ;;
57+
*) echo "expected output to start with 'infected:', got: $output"; exit 1 ;;
58+
esac

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/.claude

0 commit comments

Comments
 (0)