Skip to content
Draft
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
49 changes: 41 additions & 8 deletions .github/actions/changed-crates/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
name: 'Get Changed Crates'
description: 'Detects which Rust crates have changed files in a PR or push'

inputs:
changed-crates-version:
description: 'Version of the prebuilt changed-crates binary to download (e.g. v0.1.0). Must match a ci-crates-v* release.'
required: false
default: 'v0.1.0'

outputs:
status:
description: 'Exit status of the action (e.g. success, skipped)'
value: ${{ steps.detect.outputs.status }}
crates:
description: 'JSON array of changed crates with name, version, path and manifest'
value: ${{ steps.detect.outputs.crates }}
Expand All @@ -24,22 +33,36 @@ outputs:
runs:
using: 'composite'
steps:
- name: Set up Rust
shell: bash
run: rustup install stable && rustup default stable

- name: Fetch all branches
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
git fetch --all
echo "Available branches:"
git branch -a

- name: Build change reporter
- name: Get changed-crates binary
if: ${{ github.event_name == 'pull_request' }}
shell: bash
env:
VERSION: ${{ inputs.changed-crates-version }}
REPO: ${{ github.repository }}
run: |
cd ${{ github.action_path }}/..
cargo build --release -p ci-crates
BIN_DIR="${{ github.action_path }}/../bin"
mkdir -p "$BIN_DIR"
TAG="ci-crates-v${VERSION#v}"

## gh release create $TAG --latest=false .github/actions/target/release/changed-crates#changed-crates-x86_64-unknown-linux-gnu --title "changed-crates ${VERSION}" --notes "Prebuilt binary for changed-crates action."
URL="https://github.com/${REPO}/releases/download/${TAG}/changed-crates"
if curl -sSLfo "$BIN_DIR/changed-crates" "$URL"; then
chmod +x "$BIN_DIR/changed-crates"
else
echo "Prebuilt binary not found, building from source..."
rustup install stable && rustup default stable
cd "${{ github.action_path }}/.."
cargo build --release -p ci-crates
cp target/release/changed-crates "$BIN_DIR/changed-crates"
fi

- name: Run change reporter
id: detect
Expand All @@ -48,4 +71,14 @@ runs:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_REF: ${{ github.base_ref }}
run: |
RUST_LOG=debug ${{ github.action_path }}/../target/release/changed-crates $PR_BASE_REF
if [[ "$EVENT_NAME" != "pull_request" ]]; then
echo "status=skipped" >> $GITHUB_OUTPUT
exit 0
fi

CHANGED_CRATES_BIN="${{ github.action_path }}/../bin/changed-crates"
if RUST_LOG=debug "$CHANGED_CRATES_BIN" $PR_BASE_REF; then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=skipped" >> $GITHUB_OUTPUT
fi
4 changes: 2 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
with:
fetch-depth: 0
- name: Get changed crates
if: ${{ github.event_name == 'pull_request' }}
id: changed-crates
uses: ./.github/actions/changed-crates
- name: Set fuzz directories
id: set-dirs
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
run: |
ALL_FUZZ='["libdd-alloc", "libdd-profiling", "libdd-common-ffi", "libdd-trace-utils"]'
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "$CHANGED_CRATES_STATUS" == "success" ]]; then
FILTERED=$(echo "$CHANGED_CRATES" | jq --argjson fuzz "$ALL_FUZZ" \
'[.[] | .path | split("/") | last | . as $dir | if ($fuzz | index($dir) != null) then $dir else empty end]')
COUNT=$(echo "$FILTERED" | jq 'length')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
with:
fetch-depth: 0
- name: Get changed crates
if: ${{ github.event_name == 'pull_request' }}
id: changed-crates
uses: ./.github/actions/changed-crates
- name: Set lint packages
id: set-packages
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
COUNT="1"
FMT_PACKAGES=""
CLIPPY_PACKAGES=""
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
with:
fetch-depth: 0
- name: Get changed crates
if: ${{ github.event_name == 'pull_request' }}
id: changed-crates
uses: ./.github/actions/changed-crates
- name: Set crates to run Miri on
id: set-crates
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "$CHANGED_CRATES_STATUS" == "success" ]]; then
echo "This is a pull request event, running Miri on changed and affected crates"
echo "Changed crates: $CHANGED_CRATES"
echo "Affected crates: $AFFECTED_CRATES"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:
with:
fetch-depth: 0
- name: Get changed crates
if: ${{ github.event_name == 'pull_request' }}
id: changed-crates
uses: ./.github/actions/changed-crates
- name: Set FFI packages
id: set-packages
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
COUNT="1"
PACKAGES=""
CRATES_JSON=""
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
with:
fetch-depth: 0
- name: Get changed crates
if: ${{ github.event_name == 'pull_request' }}
id: changed-crates
uses: ./.github/actions/changed-crates
- name: Set unit test packages
id: set-packages
env:
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
COUNT="1"
PACKAGES=""
CRASHTRACKER_FEATURE="--features libdd-crashtracker/generate-unit-test-files"
Expand Down