name: Pull Request
on:
pull_request:
branches:
- main
permissions:
contents: read
issues: write
jobs:
rust:
name: Rust Checks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.96.0
components: rustfmt, clippy
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Install Python task runner
run: python -m pip install invoke
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Build
run: cargo build --locked --manifest-path Cargo.toml --all-targets
- name: Check formatting
run: cargo fmt --manifest-path Cargo.toml -- --check
- name: Lint
run: cargo clippy --locked --manifest-path Cargo.toml --all-targets --all-features -- -D warnings
- name: Test
run: cargo test --locked --manifest-path Cargo.toml
- name: Documentation
run: inv docs
- name: Security audit
id: audit
continue-on-error: true
run: cargo audit --file Cargo.lock > audit-output.txt 2>&1
- name: Comment audit output
if: always() && github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b
with:
script: |
const fs = require("fs");
const marker = "<!-- cargo-audit-report -->";
const auditStatus = "${{ steps.audit.outcome }}";
const rawOutput = fs.existsSync("audit-output.txt")
? fs.readFileSync("audit-output.txt", "utf8")
: "cargo audit did not produce output.";
const output = rawOutput.length > 60000
? `${rawOutput.slice(0, 60000)}\n\n[output truncated]`
: rawOutput;
const body = `${marker}\n## cargo audit\n\nStatus: **${auditStatus}**\n\n\`\`\`text\n${output}\n\`\`\``;
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 });
const existing = comments.data.find((comment) => comment.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}
platform-link:
name: Link (${{ matrix.os }})
strategy:
matrix:
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.96.0
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Build and link all targets
run: cargo build --locked --manifest-path Cargo.toml --all-targets --all-features
- name: Test native scheduler adapter (Windows)
if: matrix.os == 'windows-latest'
run: cargo test --locked --manifest-path Cargo.toml --lib scheduled_task::platform
env:
AGENTIRON_RUN_NATIVE_SCHEDULER_TESTS: "1"
- name: Test native scheduler adapter (macOS)
if: matrix.os == 'macos-latest'
run: cargo test --locked --manifest-path Cargo.toml --lib scheduled_task::platform
package-consumer:
name: Fresh embedded-python consumer
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.96.0
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Build from a fresh consumer resolution
run: bash .github/scripts/check-package-consumer.sh