1818 workflow_call :
1919
2020env :
21- MSFT_ACTORS : ( "Nitsirks" "calebofearth" "mojtaba-bisheh" "anjpar" "upadhyayulakiran" "nileshbpat " "ekarabu" )
21+ MSFT_ACTORS : ( "Nitsirks" "calebofearth" "mojtaba-bisheh" "anjpar" "upadhyayulakiran" "ekarabu " "clayton8" )
2222
2323jobs :
2424 # Fail if any compile.yml has been modified
@@ -42,23 +42,36 @@ jobs:
4242 SOURCE_URL : ${{ github.event.pull_request.head.repo.clone_url }}
4343 TARGET_BR : ${{ github.event.pull_request.base.ref }}
4444 run : |
45- echo "Comparing $SOURCE_OWN/$SOURCE_BR against merge target origin/$TARGET_BR to look for compile.yml"
4645 local_msft_actors=${{ env.MSFT_ACTORS }}
4746 for msft_actor in "${local_msft_actors[@]}"; do
4847 if [[ "${PR_OPENER}" == "${msft_actor}" ]]; then
4948 echo "Skipping check on compile.yml modifications for detected Microsoft contributor: ${msft_actor}"
5049 exit 0
5150 fi
5251 done
52+ echo "git fetch origin $TARGET_BR"
53+ if ! git fetch origin $TARGET_BR; then
54+ echo "git fetch failed\!"
55+ exit 1
56+ fi
5357 if [[ "${SOURCE_FORK}" == "true" ]]; then
5458 echo "pull request is from a fork: ${SOURCE_FORK}"
5559 echo "fork repository owner is ${SOURCE_OWN}"
5660 echo "adding remote '${SOURCE_OWN}' at url '${SOURCE_URL}'"
5761 git remote add -f ${SOURCE_OWN} ${SOURCE_URL}
62+ SOURCE_REMOTE=${SOURCE_OWN}
63+ else
64+ SOURCE_REMOTE=origin
5865 fi
59- echo "target ref is $(git show-ref origin/${TARGET_BR} 2> /dev/null)"
60- echo "source ref is $(git show-ref ${SOURCE_OWN}/${SOURCE_BR} 2> /dev/null)"
61- compiles=$(git diff --name-only $(git show-ref --hash "origin/$TARGET_BR")...$(git show-ref --hash "${SOURCE_OWN}/${SOURCE_BR}"))
66+ echo "git fetch ${SOURCE_REMOTE} $SOURCE_BR"
67+ if ! git fetch ${SOURCE_REMOTE} $SOURCE_BR; then
68+ echo "git fetch failed\!"
69+ exit 1
70+ fi
71+ echo "target ref for [origin/${TARGET_BR}] is $(git log -n1 --pretty=tformat:'%H' origin/${TARGET_BR} 2> /dev/null)"
72+ echo "source ref for [${SOURCE_REMOTE}/${SOURCE_BR}] is $(git log -n1 --pretty=tformat:'%H' ${SOURCE_REMOTE}/${SOURCE_BR} 2> /dev/null)"
73+ echo "Comparing $SOURCE_REMOTE/$SOURCE_BR against merge target origin/$TARGET_BR to look for compile.yml"
74+ compiles=$(git diff --name-only $(git log -n1 --pretty=tformat:'%H' "origin/$TARGET_BR")...$(git log -n1 --pretty=tformat:'%H' "${SOURCE_REMOTE}/${SOURCE_BR}"))
6275 if [[ $(grep -c compile.yml <<< "$compiles") -gt 0 ]]; then
6376 echo "compile.yml should not be modified for pull requests! Found:"
6477 echo "$compiles"
@@ -71,55 +84,73 @@ jobs:
7184 hash_check :
7285 name : Hash Check
7386 runs-on : ubuntu-22.04
87+ if : ${{ (github.event_name == 'pull_request' && github.base_ref == 'main') || (github.event_name == 'workflow_dispatch') }}
7488 steps :
89+ - name : Echo Reason
90+ run : echo "$GITHUB_EVENT_NAME"
7591 - name : Checkout RTL repo
7692 uses : actions/checkout@v4
7793 with :
7894 fetch-depth : 0
7995
8096 - name : Gen File List
8197 run : |
82- find "$GITHUB_WORKSPACE" -type f -name "*.sv" \
83- -o -name "*.svh" \
84- -o -name "*.rdl" \
85- -o -name "*.json" \
86- -o -name "*.v" \
87- -o -name "*.vh" \
88- -o -name "*.rsp" \
89- -o -name "*.s" \
90- -o -name "*.c" \
91- -o -name "*.cpp" \
92- -o -name "*.h" \
93- -o -name "*.hex" \
94- -o -name "*.ld" \
95- -o -name "*.gdb" \
96- -o -name "*.yml" \
97- -o -name "*.sh" \
98- -o -name "*.py" \
99- -o -name "pr_timestamp" \
100- ! -path "*.git/*" | LC_COLLATE=C sort -o $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
98+ # Search for all source code files, scripts, and configuration
99+ # files used to build/validate Caliptra RTL.
100+ # File type exclusions:
101+ # - *.md
102+ # - *.png
103+ # - *.jpg
104+ # - *.xlsx/*.xls
105+ # - any files inside
106+ # - .git
107+ # - .github/workflows
108+ find "$GITHUB_WORKSPACE" -type f \( -name "*.sv" \
109+ -o -name "*.svh" \
110+ -o -name "*.rdl" \
111+ -o -name "*.json" \
112+ -o -name "*.v" \
113+ -o -name "*.vh" \
114+ -o -name "*.rsp" \
115+ -o -name "*.s" \
116+ -o -name "*.c" \
117+ -o -name "*.cpp" \
118+ -o -name "*.h" \
119+ -o -name "*.hex" \
120+ -o -name "*.ld" \
121+ -o -name "*.gdb" \
122+ -o -name "*.yml" \
123+ -o -name "*.sh" \
124+ -o -name "*.py" \
125+ -o -name "pr_timestamp" \) \
126+ ! -path "*.github/workflows/*" \
127+ ! -path "*.git/*" | LC_COLLATE=C sort -o $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
101128 sed -i "s,^$GITHUB_WORKSPACE/,," $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
102129 echo "Found $(wc -l $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt) source code files to hash"
103130 echo -e "First five files:\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
104131 head -5 $GITHUB_WORKSPACE/.github/workflow_metadata/file_list.txt
105132 echo -e ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
106133
107134 - name : Check Timestamp
135+ env :
136+ TARGET_BR : ${{ (github.event_name == 'pull_request' && github.base_ref) || (github.event_name == 'workflow_dispatch' && inputs.base_ref) }}
108137 run : |
109138 # Find the last commit that modified any design file (not documentation)
110139 # Start the search with the second parent of the PR merge commit
111140 # in order to only traverse the feature branch commits
141+ # Use an explicit list of files instead of an exclusion list
112142 last_commit=$(git rev-parse HEAD^2)
113- until git diff --name-only "${last_commit}^..${last_commit}" | grep -v '\.md \|\.png ' > /dev/null; do
143+ until git diff --name-only "${last_commit}^..${last_commit}" | grep -v '.github/workflows' | grep -e '\.sv \|\.svh\|\.rdl\|\.json\|\.v\|\.vh\|\.rsp\|\.s\|\.c\|\.cpp\|\.h\|\.hex\|\.ld\|\.gdb\|\.yml\|\.sh\|\.py\|pr_timestamp ' > /dev/null; do
114144 last_commit="$(git rev-parse ${last_commit}^)"
115145 done
116146 echo "Latest non-doc hash is ${last_commit}"
117- # If the last non-doc commit is already contained in branch 'main', then skip the
147+ echo "Checking if ${last_commit} is contained in branch 'origin/$TARGET_BR'"
148+ # If the last non-doc commit is already contained in branch 'TARGET_BR', then skip the
118149 # timestamp check -- as that commit would already be signed off through another PR.
119- # Otherwise, that commit would fail because it's part of a commit that was squashed into main
150+ # Otherwise, that commit would fail because it's part of a commit that was squashed into TARGET_BR
120151 # much later than the original stamp commit.
121- if [[ $(git branch --remotes --list ' origin/main' --contains ${last_commit}) =~ ' origin/main' ]]; then
122- echo "Commit ${last_commit} is contained in branch 'main ', skipping timestamp check"
152+ if [[ $(git branch --remotes --list " origin/$TARGET_BR" --contains ${last_commit}) =~ " origin/$TARGET_BR" ]]; then
153+ echo "Commit ${last_commit} is contained in branch '$TARGET_BR ', skipping timestamp check"
123154 else
124155 # Compare the timestamp from the latest commit with the pr_timestamp file
125156 timestamp_exp=$(bc <<< "$(git log -n1 --pretty=tformat:'%ct' ${last_commit})-3600")
@@ -177,7 +208,7 @@ jobs:
177208 rdl_check :
178209 name : RDL File Check
179210 runs-on : ubuntu-22.04
180- if : ${{ (github.event_name == 'pull_request' && github.base_ref == 'main' ) || (github.event_name == 'workflow_dispatch') }}
211+ if : ${{ (github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch') }}
181212 steps :
182213 - name : Checkout RTL repo
183214 uses : actions/checkout@v4
0 commit comments