Skip to content
Merged
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
32 changes: 23 additions & 9 deletions .github/workflows/BuildStatusDataRecorder/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,24 @@ runs:
if: ${{ inputs.enabled }} == "true"
shell: bash
run: |
# Set +e to not immediately exit "run" step on failure.
set +e

cd ${{ inputs.project }}
DASH_DIR="$(mktemp -d)"
cp .github/workflows/scripts/record_builds.py ${DASH_DIR}/
git config user.name 'github-actions'
git config user.email 'github-actions@github.com'

# Record current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)

# Switch to dashboard branch to access build-status.db
git fetch --all
git checkout dashboard
git reset --hard origin/dashboard
ls -l

: '
Multiple workflows and parallel matrix builds write to
build-status.db file. This causes race condition, stale DB or
Expand All @@ -62,32 +70,34 @@ runs:
sleep 10
git fetch --all
git reset --hard origin/dashboard
git pull
ls -l
done
echo "Data lock removed"
}

check_lock

# After data lock is released by other workflows, a lock is acquired for current workflow.
echo "Adding ${{ inputs.workflow-name }} ${{ inputs.arch-name }} data lock."
lock_file_msg="Add data lock for ${{ inputs.workflow-name }} ${{ inputs.arch-name }} build status data to be written"
echo "$(date) -> $lock_file_msg" >> dash.log
touch data.lock
git add .
git commit -m "Add data lock for ${{ inputs.workflow-name }} ${{ inputs.arch-name }} build status data to be written"

# Keep trying until a data lock is pushed successfully.
until git push -f origin HEAD:refs/heads/dashboard; do
sleep 5
check_lock
git fetch --all
git reset --hard origin/dashboard
echo "$(date) -> $lock_file_msg" >> dash.log
touch data.lock
git add .
git commit -m "Add data lock for ${{ inputs.workflow-name }} ${{ inputs.arch-name }} build status data to be written"
git commit -m "$lock_file_msg"
done

# Record build status data for current workflow.
echo "Proceeding with data recording..."
git checkout --orphan dash
cp ${DASH_DIR}/record_builds.py .
# Set +e to not immediately exit "run" step on failure.
set +e
python3 record_builds.py --workflow ${{ inputs.workflow-name }} --${{ inputs.record-mode }} --${{ inputs.status }} --run-id ${{ inputs.run-id }} --arch ${{ inputs.arch-name }} --branch ${{ inputs.branch-name }}
EXITCODE=$?
if [ "$EXITCODE" -ne 0 ]; then
Expand Down Expand Up @@ -117,14 +127,18 @@ runs:
# Keep trying until lock/conflicts are resolved and build data is pushed successfully.
until git push -f origin HEAD:refs/heads/dashboard; do
sleep 5
git checkout dashboard
check_lock
git fetch --all
git reset --hard origin/dashboard
git checkout --orphan dash
cp -f ${DASH_DIR}/build-status.db .
rm -f data.lock
lock_file_msg="Add ${{ inputs.workflow-name }} ${{ inputs.arch-name }} build status data in DB"
echo "$(date) -> $lock_file_msg" >> dash.log
git add .
git commit -m "Add ${{ inputs.workflow-name }} ${{ matrix.arch.name }} build status data in DB"
git commit -m "$lock_file_msg"
done
rm -rf ${DASH_DIR}
git checkout -
git checkout "$current_branch"
fi
Loading