Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENV] Fix for excluding GH workflow files in hash check; skip Verilator for doc PRs #704

Merged
merged 22 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7dbaae6
Update 'find' call to properly evaluate expression precedence
calebofearth Jan 22, 2025
c572195
Manually stamp repo
calebofearth Jan 22, 2025
d65eb74
Update hash check to match 'find' operator precedence
calebofearth Jan 22, 2025
377cad2
Explanatory comment about hash check
calebofearth Jan 22, 2025
fa33613
Update Verilator workflow to be skipped for doc-only PRs
calebofearth Jan 22, 2025
3fcd9fb
Clearer comment
calebofearth Jan 22, 2025
a04dcdd
Syntax fix for 'find' usage
calebofearth Jan 22, 2025
485f4a0
Move run_vltr check to pre-run-check and share result to all Verilato…
calebofearth Jan 22, 2025
da86ffe
Fix input usage syntax
calebofearth Jan 22, 2025
b571931
Skip the test jobs, not each step
calebofearth Jan 22, 2025
618eeec
Always run the finalize job
calebofearth Jan 22, 2025
57e6e4b
Run Verilator checks when workflow files are modified
calebofearth Jan 22, 2025
76ccaef
Syntax fix in usage of github event context
calebofearth Jan 22, 2025
6a6d163
Github context webhook not available inside the step script. Use env
calebofearth Jan 23, 2025
9c89631
Use origin in git diff
calebofearth Jan 23, 2025
0062f34
Try show-ref to get the comparison commit
calebofearth Jan 23, 2025
6233e62
Fix git diff so it does not require --merge-base
calebofearth Jan 23, 2025
67d146f
Use git merge-base command to create the correct diff
calebofearth Jan 23, 2025
30d0cd1
Merge remote-tracking branch 'chips/main' into cwhitehead-msft-hash-c…
calebofearth Jan 23, 2025
9c52225
Quotes to make .. work
calebofearth Jan 23, 2025
c195e73
Revert to ... syntax
calebofearth Jan 23, 2025
1db5806
MICROSOFT AUTOMATED PIPELINE: Stamp 'cwhitehead-msft-hash-chk-exclude…
calebofearth Jan 23, 2025
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
40 changes: 20 additions & 20 deletions .github/scripts/stamp_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ if [[ -z "${CALIPTRA_ROOT:+"empty"}" ]]; then
fi

# Create file list
find "$CALIPTRA_ROOT" -type f -name "*.sv" \
-o -name "*.svh" \
-o -name "*.rdl" \
-o -name "*.json" \
-o -name "*.v" \
-o -name "*.vh" \
-o -name "*.rsp" \
-o -name "*.s" \
-o -name "*.c" \
-o -name "*.cpp" \
-o -name "*.h" \
-o -name "*.hex" \
-o -name "*.ld" \
-o -name "*.gdb" \
-o -name "*.yml" \
-o -name "*.sh" \
-o -name "*.py" \
-o -name "pr_timestamp" \
! -path "*.github/workflows/*" \
! -path "*.git/*" | LC_COLLATE=C sort -o $CALIPTRA_ROOT/.github/workflow_metadata/file_list.txt
find "$CALIPTRA_ROOT" -type f \( -name "*.sv" \
-o -name "*.svh" \
-o -name "*.rdl" \
-o -name "*.json" \
-o -name "*.v" \
-o -name "*.vh" \
-o -name "*.rsp" \
-o -name "*.s" \
-o -name "*.c" \
-o -name "*.cpp" \
-o -name "*.h" \
-o -name "*.hex" \
-o -name "*.ld" \
-o -name "*.gdb" \
-o -name "*.yml" \
-o -name "*.sh" \
-o -name "*.py" \
-o -name "pr_timestamp" \) \
! -path "*.github/workflows/*" \
! -path "*.git/*" | LC_COLLATE=C sort -o $CALIPTRA_ROOT/.github/workflow_metadata/file_list.txt
sed -i "s,^$CALIPTRA_ROOT/,," $CALIPTRA_ROOT/.github/workflow_metadata/file_list.txt
echo "Found $(wc -l $CALIPTRA_ROOT/.github/workflow_metadata/file_list.txt) source code files to hash"
echo -e "First five files:\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c1dfc17d2b57a33ff546cecb231fed8bb0094983482266972c6cc0af7094ccf524815a640497e099f9d947ef01c91fa4
4cd4ff9933e96956f51ba989e2070ef19b7aa9a8ac163288603071fda4290c71d435da83940786da9086c38eed33f4ea
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1737572855
1737599725
15 changes: 14 additions & 1 deletion .github/workflows/build-test-verilator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
push:
branches: ["main", "dev-goog", "dev-msft"]
workflow_call:
inputs:
run_vltr:
description: "Control parameter indicating if Verilator tests should be run or skipped"
required: true
type: string
default: 'true'
workflow_dispatch:

env:
Expand All @@ -23,6 +29,7 @@ jobs:
build_tools:
name: Build Tools
runs-on: ubuntu-22.04
if: ${{ inputs.run_vltr == 'true' }}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -118,6 +125,7 @@ jobs:
name: Build Smoke Test matrix
runs-on: ubuntu-22.04
needs: build_tools
if: ${{ inputs.run_vltr == 'true' }}
outputs:
test_names: ${{ steps.output-matrix.outputs.test_names }}
env:
Expand All @@ -137,6 +145,7 @@ jobs:
name: Verilator
runs-on: ubuntu-22.04
needs: build_matrix
if: ${{ inputs.run_vltr == 'true' }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -200,11 +209,15 @@ jobs:
name: Verify Verilator Test Results
runs-on: ubuntu-22.04
needs: build_and_test
# Force to run even if the build_and_test job is skipped for some reason
# Force to run even if the build_and_test job is skipped for any reason
if: ${{ !cancelled() }}
steps:
- name: Print Verilator Aggregated Result
run: |
echo "Run Verilator check has a result of [${{ inputs.run_vltr }}]"
if [[ "${{ inputs.run_vltr }}" == "false" ]]; then
exit 0
fi
echo "build_and_test has a result of [${{ needs.build_and_test.result }}]"
if [[ "${{ needs.build_and_test.result }}" != "success" ]]; then
exit 1
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/interactive-debugging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ on:
push:
branches: ["main", "dev-goog", "dev-msft", "dev-public"]
workflow_call:
inputs:
run_vltr:
description: "Control parameter indicating if Verilator tests should be run or skipped"
required: true
type: string
default: 'true'
workflow_dispatch:

jobs:
build_verilator:
name:
runs-on: ubuntu-22.04
if: ${{ inputs.run_vltr == 'true' }}

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -90,6 +97,7 @@ jobs:
build_openocd:
name:
runs-on: ubuntu-22.04
if: ${{ inputs.run_vltr == 'true' }}

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -173,6 +181,7 @@ jobs:
name: Run GDB debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
if: ${{ inputs.run_vltr == 'true' }}

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -259,6 +268,7 @@ jobs:
name: Run OpenOCD debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
if: ${{ inputs.run_vltr == 'true' }}

env:
CARGO_INCREMENTAL: 0
Expand Down
111 changes: 91 additions & 20 deletions .github/workflows/pre-run-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
type: string
default: 'main'
workflow_call:
outputs:
run_vltr:
description: "Control parameter indicating if Verilator tests should be run or skipped"
value: ${{ jobs.evaluate_if_run.outputs.run_vltr }}

env:
MSFT_ACTORS: ( "Nitsirks" "calebofearth" "mojtaba-bisheh" "anjpar" "upadhyayulakiran" "nileshbpat" "ekarabu" )
Expand Down Expand Up @@ -81,26 +85,34 @@ jobs:

- name: Gen File List
run: |
find "$GITHUB_WORKSPACE" -type f -name "*.sv" \
-o -name "*.svh" \
-o -name "*.rdl" \
-o -name "*.json" \
-o -name "*.v" \
-o -name "*.vh" \
-o -name "*.rsp" \
-o -name "*.s" \
-o -name "*.c" \
-o -name "*.cpp" \
-o -name "*.h" \
-o -name "*.hex" \
-o -name "*.ld" \
-o -name "*.gdb" \
-o -name "*.yml" \
-o -name "*.sh" \
-o -name "*.py" \
-o -name "pr_timestamp" \
! -path "*.github/workflows/*" \
! -path "*.git/*" | LC_COLLATE=C sort -o $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
# Search for all source code files, scripts, and configuration
# files used to build/validate Caliptra RTL.
# File type exclusions:
# - *.md
# - *.png
# - any files inside
# - .git
# - .github/workflows
find "$GITHUB_WORKSPACE" -type f \( -name "*.sv" \
-o -name "*.svh" \
-o -name "*.rdl" \
-o -name "*.json" \
-o -name "*.v" \
-o -name "*.vh" \
-o -name "*.rsp" \
-o -name "*.s" \
-o -name "*.c" \
-o -name "*.cpp" \
-o -name "*.h" \
-o -name "*.hex" \
-o -name "*.ld" \
-o -name "*.gdb" \
-o -name "*.yml" \
-o -name "*.sh" \
-o -name "*.py" \
-o -name "pr_timestamp" \) \
! -path "*.github/workflows/*" \
! -path "*.git/*" | LC_COLLATE=C sort -o $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
sed -i "s,^$GITHUB_WORKSPACE/,," $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
echo "Found $(wc -l $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt) source code files to hash"
echo -e "First five files:\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
Expand Down Expand Up @@ -210,3 +222,62 @@ jobs:
export CALIPTRA_ROOT=$GITHUB_WORKSPACE
export ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge
$GITHUB_WORKSPACE/.github/scripts/pr_rdl_check.sh "origin/$TARGET_BR"

# Verilator is always run outside of the Pull Request context.
# For Pull Requests, conditionally run based on evaluation of
# modified file set
evaluate_if_run:
name: Evaluate if Verilator Will Run
runs-on: ubuntu-22.04
outputs:
run_vltr: ${{ steps.do_decide.outputs.run }}
env:
DO_EVAL: ${{ github.event_name == 'pull_request' }}

steps:
- uses: actions/checkout@v4
if: ${{ env.DO_EVAL == 'true' }}
with:
submodules: 'true'

# If only documentation files have been modified as part of a
# Pull Request, skip the Verilator checks
# Otherwise, run Verilator
- name: Do Git Diff
id: do_git_diff
if: ${{ env.DO_EVAL == 'true' }}
env:
SOURCE_BR: ${{ github.event.pull_request.head.ref }}
SOURCE_FORK: ${{ github.event.pull_request.head.repo.fork }}
SOURCE_OWN: ${{ github.event.pull_request.head.repo.owner.login }}
SOURCE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
TARGET_BR: ${{ github.event.pull_request.base.ref }}
run: |
if [[ "${SOURCE_FORK}" == "true" ]]; then
echo "pull request is from a fork: ${SOURCE_FORK}"
echo "fork repository owner is ${SOURCE_OWN}"
echo "adding remote '${SOURCE_OWN}' at url '${SOURCE_URL}'"
git remote add -f ${SOURCE_OWN} ${SOURCE_URL}
fi
echo "target ref is $(git show-ref origin/${TARGET_BR} 2> /dev/null)"
echo "source ref is $(git show-ref ${SOURCE_OWN}/${SOURCE_BR} 2> /dev/null)"
mods=$(git diff --name-only $(git show-ref --hash "origin/${TARGET_BR}")...$(git show-ref --hash "${SOURCE_OWN}/${SOURCE_BR}"))
if [[ $(IFS='\n' grep -c -v '\\.md\\|\\.png' <<< "$mods") -gt 0 ]]; then
echo "Found modified source files in ${SOURCE_BR}"
echo "src_mods=true" >> "${GITHUB_OUTPUT}"
else
echo "Only modified files in ${SOURCE_BR} are for documentation"
echo "src_mods=false" >> "${GITHUB_OUTPUT}"
fi

- name: Decide
id: do_decide
run: |
if [[ "${{ env.DO_EVAL }}" == "false" ]]; then
echo "run=true" >> "${GITHUB_OUTPUT}"
elif [[ "${{ steps.do_git_diff.outputs.src_mods }}" == "true" ]]; then
echo "run=true" >> "${GITHUB_OUTPUT}"
else
echo "run=false" >> "${GITHUB_OUTPUT}"
fi

8 changes: 8 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ jobs:
uses: ./.github/workflows/pre-run-check.yml
verilator:
uses: ./.github/workflows/build-test-verilator.yml
needs: pre_run
with:
run_vltr: ${{ needs.pre_run.outputs.run_vltr }}
interactive_dbg:
uses: ./.github/workflows/interactive-debugging.yml
needs: pre_run
with:
run_vltr: ${{ needs.pre_run.outputs.run_vltr }}
doc_gen:
uses: ./.github/workflows/doc-gen.yml
permissions:
Expand All @@ -25,6 +31,8 @@ jobs:
name: Call Post Run Final
runs-on: ubuntu-22.04
needs: [pre_run, verilator, interactive_dbg, doc_gen]
# Force to run even if the prerequisites are skipped for any reason
if: ${{ !cancelled() }}
steps:
- name: Checkout RTL repo
uses: actions/checkout@v4
Expand Down