Skip to content

Commit cb5bf5f

Browse files
authored
ci: changed-crates refactor (#1691)
# What does this PR do? Remove the `github.event_name == 'pull_request'` checks # Motivation What inspired you to submit this pull request? # Additional Notes Anything else we should know when reviewing? # How to test the change? Describe here in detail how the change can be validated.
1 parent 9c957d3 commit cb5bf5f

6 files changed

Lines changed: 26 additions & 11 deletions

File tree

.github/actions/changed-crates/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ name: 'Get Changed Crates'
55
description: 'Detects which Rust crates have changed files in a PR or push'
66

77
outputs:
8+
status:
9+
description: 'Exit status of the action (e.g. success, skipped)'
10+
value: ${{ steps.detect.outputs.status }}
811
crates:
912
description: 'JSON array of changed crates with name, version, path and manifest'
1013
value: ${{ steps.detect.outputs.crates }}
@@ -25,17 +28,20 @@ runs:
2528
using: 'composite'
2629
steps:
2730
- name: Set up Rust
31+
if: ${{ github.event_name == 'pull_request' }}
2832
shell: bash
2933
run: rustup install stable && rustup default stable
3034

3135
- name: Fetch all branches
36+
if: ${{ github.event_name == 'pull_request' }}
3237
shell: bash
3338
run: |
3439
git fetch --all
3540
echo "Available branches:"
3641
git branch -a
3742
3843
- name: Build change reporter
44+
if: ${{ github.event_name == 'pull_request' }}
3945
shell: bash
4046
run: |
4147
cd ${{ github.action_path }}/..
@@ -48,4 +54,13 @@ runs:
4854
EVENT_NAME: ${{ github.event_name }}
4955
PR_BASE_REF: ${{ github.base_ref }}
5056
run: |
51-
RUST_LOG=debug ${{ github.action_path }}/../target/release/changed-crates $PR_BASE_REF
57+
if [[ "$EVENT_NAME" != "pull_request" ]]; then
58+
echo "status=skipped" >> $GITHUB_OUTPUT
59+
exit 0
60+
fi
61+
62+
if RUST_LOG=debug ${{ github.action_path }}/../target/release/changed-crates $PR_BASE_REF; then
63+
echo "status=success" >> $GITHUB_OUTPUT
64+
else
65+
echo "status=skipped" >> $GITHUB_OUTPUT
66+
fi

.github/workflows/fuzz.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
with:
1616
fetch-depth: 0
1717
- name: Get changed crates
18-
if: ${{ github.event_name == 'pull_request' }}
1918
id: changed-crates
2019
uses: ./.github/actions/changed-crates
2120
- name: Set fuzz directories
2221
id: set-dirs
2322
env:
23+
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
2424
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
2525
run: |
2626
ALL_FUZZ='["libdd-alloc", "libdd-profiling", "libdd-common-ffi", "libdd-trace-utils"]'
27-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
27+
if [[ "$CHANGED_CRATES_STATUS" == "success" ]]; then
2828
FILTERED=$(echo "$CHANGED_CRATES" | jq --argjson fuzz "$ALL_FUZZ" \
2929
'[.[] | .path | split("/") | last | . as $dir | if ($fuzz | index($dir) != null) then $dir else empty end]')
3030
COUNT=$(echo "$FILTERED" | jq 'length')

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121
- name: Get changed crates
22-
if: ${{ github.event_name == 'pull_request' }}
2322
id: changed-crates
2423
uses: ./.github/actions/changed-crates
2524
- name: Set lint packages
2625
id: set-packages
2726
env:
27+
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
2828
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
2929
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
3030
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
3131
run: |
32-
if [[ "${{ github.event_name }}" == "push" ]]; then
32+
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
3333
COUNT="1"
3434
FMT_PACKAGES=""
3535
CLIPPY_PACKAGES=""

.github/workflows/miri.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919
- name: Get changed crates
20-
if: ${{ github.event_name == 'pull_request' }}
2120
id: changed-crates
2221
uses: ./.github/actions/changed-crates
2322
- name: Set crates to run Miri on
2423
id: set-crates
2524
env:
25+
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
2626
CHANGED_CRATES: ${{ steps.changed-crates.outputs.crates }}
2727
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
2828
run: |
29-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
29+
if [[ "$CHANGED_CRATES_STATUS" == "success" ]]; then
3030
echo "This is a pull request event, running Miri on changed and affected crates"
3131
echo "Changed crates: $CHANGED_CRATES"
3232
echo "Affected crates: $AFFECTED_CRATES"

.github/workflows/test-ffi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222
- name: Get changed crates
23-
if: ${{ github.event_name == 'pull_request' }}
2423
id: changed-crates
2524
uses: ./.github/actions/changed-crates
2625
- name: Set FFI packages
2726
id: set-packages
2827
env:
28+
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
2929
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
3030
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
3131
run: |
32-
if [[ "${{ github.event_name }}" == "push" ]]; then
32+
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
3333
COUNT="1"
3434
PACKAGES=""
3535
CRATES_JSON=""

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ jobs:
2525
with:
2626
fetch-depth: 0
2727
- name: Get changed crates
28-
if: ${{ github.event_name == 'pull_request' }}
2928
id: changed-crates
3029
uses: ./.github/actions/changed-crates
3130
- name: Set unit test packages
3231
id: set-packages
3332
env:
33+
CHANGED_CRATES_STATUS: ${{ steps.changed-crates.outputs.status }}
3434
CHANGED_CRATES_COUNT: ${{ steps.changed-crates.outputs.crates_count }}
3535
AFFECTED_CRATES: ${{ steps.changed-crates.outputs.affected_crates }}
3636
run: |
37-
if [[ "${{ github.event_name }}" == "push" ]]; then
37+
if [[ "$CHANGED_CRATES_STATUS" == "skipped" ]]; then
3838
COUNT="1"
3939
PACKAGES=""
4040
CRASHTRACKER_FEATURE="--features libdd-crashtracker/generate-unit-test-files"

0 commit comments

Comments
 (0)