Skip to content

Commit 9436b26

Browse files
committed
Use caller event as input
1 parent dafcf98 commit 9436b26

1 file changed

Lines changed: 64 additions & 24 deletions

File tree

.github/workflows/dunedaq-develop-cpp-ci.yml

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Single-Package CI Build
22

33
on:
44
workflow_call:
5+
inputs:
6+
caller_event_name:
7+
required: true
8+
type: string
9+
description: "Flag to distinguish between e.g. schedule and pull request"
510

611
env:
712
CALLER_BRANCH: ${{ github.head_ref || github.ref_name }}
@@ -87,7 +92,7 @@ jobs:
8792
- name: Pull build image
8893
run: docker pull ${{ needs.determine_image.outputs.image }}
8994

90-
- id: setup_dev_area
95+
- id: get_release_info
9196
run: |
9297
echo "Caller branch is " "$CALLER_BRANCH"
9398
echo "Target branch is " "$TARGET_BRANCH"
@@ -96,15 +101,12 @@ jobs:
96101
extra_dbt_args=""
97102
if [[ ${{ needs.determine_image.outputs.image }} =~ ^.*stable.* ]]; then
98103
release_name=$( ls -tr /cvmfs/dunedaq.opensciencegrid.org/spack/releases/ | grep fddaq | tail -1 )
99-
#dbt-create $release_name dev-${{ matrix.os_name }}
100104
elif [[ ${{ needs.determine_image.outputs.image }} =~ ^.*candidate.* ]]; then
101105
extra_dbt_args="-b candidate"
102106
release_name=$( ls -tr /cvmfs/dunedaq-development.opensciencegrid.org/candidates/ | grep fddaq | tail -1 )
103-
#dbt-create -b candidate $release_name dev-${{ matrix.os_name }}
104107
else
105108
extra_dbt_args="-n"
106109
release_name=$( ls -tr /cvmfs/dunedaq-development.opensciencegrid.org/nightly/ | grep fddaq | tail -1 )
107-
#dbt-create -n $release_name dev-${{ matrix.os_name }}
108110
fi
109111
110112
echo "extra_dbt_args=$extra_dbt_args" >> "$GITHUB_OUTPUT"
@@ -131,8 +133,8 @@ jobs:
131133
setup_dbt latest
132134
133135
echo "Creating in container: $(pwd)"
134-
dbt-create ${{ steps.setup_dev_area.outputs.extra_dbt_args }} \
135-
${{ steps.setup_dev_area.outputs.release_name}} \
136+
dbt-create ${{ steps.get_release_info.outputs.extra_dbt_args }} \
137+
${{ steps.get_release_info.outputs.release_name}} \
136138
dev-${{ matrix.os_name }}
137139
138140
echo "Build area?: $(ls)"
@@ -160,50 +162,88 @@ jobs:
160162
161163
chmod +x build_and_lint_package.sh
162164
163-
echo "Where am I? $(pwd)"
164-
echo "What's here? $(ls -l)"
165-
166165
docker run --rm \
167166
-v /cvmfs:/cvmfs:shared \
168167
-v "${GITHUB_WORKSPACE}:/ghw" \
169168
-w /ghw \
170169
${{ needs.determine_image.outputs.image }} \
171170
/ghw/build_and_lint_package.sh
172171
173-
echo "Post-container: where am I? $(pwd)"
174-
echo "Post-container: what's here? $(ls -l)"
175-
176-
echo "Linting results?"
177-
ls dev-${{ matrix.os_name }}/log/linting*/*_linting.log
178-
179172
- name: upload build log file
180173
uses: actions/upload-artifact@main
181174
with:
182175
name: build_log_${{ matrix.os_name }}
183176
path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/build*.log
184177

178+
- name: set linting artifact name
179+
id: set_artifact_name
180+
run: |
181+
linting_artifact_name="linting_results"
182+
if [[ ${{ inputs.caller_event_name == 'schedule' }} ]]; then
183+
linting_artifact_name="nightly_linting_results"
184+
fi
185+
echo "linting_artifact_name=$linting_artifact_name" >> "$GITHUB_OUTPUT"
186+
185187
- name: upload linting log file
186188
uses: actions/upload-artifact@main
187189
with:
188-
name: linting_results
190+
name: ${{ steps.set_artifact_name.outputs.linting_artifact_name }}
189191
path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/linting*/*_linting.log
192+
193+
compare_linting_results:
194+
if: ${{ inputs.caller_event_name == 'pull_request' }}
195+
runs-on: ubuntu-latest
196+
defaults:
197+
run:
198+
shell: bash
199+
200+
steps:
201+
- name: Get ID of latest nightly run
202+
id: latest_nightly
203+
env:
204+
GH_TOKEN: ${{ github.token }}
205+
run: |
206+
run_id=$(gh run list \
207+
--repo ${{ github.repository }}
208+
--workflow dunedaq-develop-cpp-ci.yml \
209+
--event schedule \
210+
--limit 1 \
211+
--json databaseId \
212+
--jq '.[0].databaseId')
213+
214+
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
215+
216+
- name: Download latest nightly linting results
217+
uses: actions/download-artifact@main
218+
with:
219+
name: nightly_linting_results
220+
run-id: ${{ steps.latest_nightly.outputs.run_id }}
190221

191-
- name: Download nightly linting results
192-
if: ${{ github.event_name == 'pull_request' }}
222+
- name: Download pull request linting results
193223
uses: actions/download-artifact@main
194224
with:
195-
name: linting_results
196-
path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/nightly_linting_results.log
225+
name: pull_request_linting_results
197226

198-
- name: Compare to nightly linting results
199-
if: ${{ github.event_name == 'pull_request' }}
227+
- name: Compare linting results
228+
id: compare
229+
continue-on-error: true
200230
run: |
231+
diff_file_name=linting_diff.txt
201232
pr_linting_results_file=$(dev-${{ matrix.os_name }}/log/linting*/*_linting.log)
202233
nightly_linting_results_file=$(dev-${{ matrix.os_name }}/nightly_linting_results.log)
234+
203235
[[ -f "$pr_linting_results_file" ]] || echo "ERROR: No PR results file; exit 1"
204236
[[ -f "$nightly_linting_results_file" ]] || echo "ERROR: No nightly results file; exit 2"
205-
if ! diff "$pr_linting_results_file" "$nightly_linting_results_file" > linting_diff.txt; then
237+
238+
if ! diff "$pr_linting_results_file" "$nightly_linting_results_file" > "$diff_file_name"; then
206239
echo "ERROR: This PR introduces new linting errors:"
207-
cat linting_diff.txt
240+
cat "$diff_file_name"
241+
echo "diff_file_name=$diff_file_name" >> "$GITHUB_OUTPUT"
208242
exit 1
209243
fi
244+
245+
- name: upload linting diff file
246+
uses: actions/upload-artifact@main
247+
with:
248+
name: linting_diff
249+
path: ${{ github.workspace }}/${{ steps.compare.outputs.diff_file_name }}

0 commit comments

Comments
 (0)