Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Tests

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pull-requests: write

concurrency:
group: tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Entropia tests
runs-on: ubuntu-latest
timeout-minutes: 30

env:
CARGO_TERM_COLOR: always

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install stable Rust
run: rustup toolchain install stable --profile minimal

- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run test suites
shell: bash
run: |
set +e

summary_file="test-summary.md"
: > "$summary_file"

add_summary() {
printf "%s\n" "$1" | tee -a "$GITHUB_STEP_SUMMARY" "$summary_file" > /dev/null
}

add_summary "## Test summary"
add_summary ""
add_summary "| Suite | Command | Result |"
add_summary "| --- | --- | --- |"

failures=0

run_suite() {
local name="$1"
shift
local cmd="$*"

echo "::group::$name"
echo "$ $cmd"
"$@"
local status=$?
echo "::endgroup::"

if [ "$status" -eq 0 ]; then
printf "| %s | \`%s\` | PASS |\n" "$name" "$cmd" | tee -a "$GITHUB_STEP_SUMMARY" "$summary_file" > /dev/null
else
printf "| %s | \`%s\` | FAIL (%s) |\n" "$name" "$cmd" "$status" | tee -a "$GITHUB_STEP_SUMMARY" "$summary_file" > /dev/null
failures=$((failures + 1))
fi
}

run_suite "entropykit unit tests" cargo test -p entropykit --bin entc
run_suite "shellcode goldens" cargo test -p entropykit --test shellcode_golden
run_suite "COFF smoke tests" cargo test -p entropykit --test coff_smoke
run_suite "CLI smoke tests" cargo test -p entropykit --test cli_smoke
run_suite "negative compiler tests" cargo test -p entropykit --test typecheck_negative
run_suite "debug map golden" cargo test -p entropykit --test debug_map_golden
run_suite "BOF loader tests" cargo test -p bof-loader
run_suite "remaining workspace crates" cargo test --workspace --exclude entropykit --exclude bof-loader

add_summary ""
if [ "$failures" -eq 0 ]; then
add_summary "**Result:** all test suites passed."
else
add_summary "**Result:** $failures test suite(s) failed."
fi

echo "$failures" > .test-failures

- name: Publish PR test summary
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
continue-on-error: true
with:
script: |
const fs = require('fs');

if (!fs.existsSync('test-summary.md')) {
core.info('No test-summary.md found; skipping PR comment.');
return;
}

const marker = '<!-- entropia-test-summary -->';
const body = `${marker}\n${fs.readFileSync('test-summary.md', 'utf8')}`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;

const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number,
per_page: 100,
});

const previous = comments.data.find(comment =>
comment.user?.type === 'Bot' && comment.body?.includes(marker)
);

if (previous) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: previous.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}

- name: Fail if any suite failed
if: always()
shell: bash
run: |
failures="$(cat .test-failures 2>/dev/null || echo 1)"
if [ "$failures" -ne 0 ]; then
echo "$failures test suite(s) failed."
exit 1
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ example/*.cna
*.x64.o
*.x86.o
*.dbg
!tests/fixtures/**/*.bin
!tests/fixtures/**/*.dbg

/tmp_build/
build/
Expand Down
182 changes: 181 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading