Skip to content

Patchworks

Patchworks #62671

Workflow file for this run

name: Patchworks
on:
schedule:
# Run every 15 minutes offset by 7 to try to avoid github's high-load times
# https://stackoverflow.com/questions/59560214/github-action-works-on-push-but-not-scheduled
- cron: 7,22,37,52 * * * *
workflow_call:
inputs:
timestamp:
description: 'Patch Timestamp (UTC)'
type: string
baseline_gcc_hash:
description: 'Baseline hash'
type: string
tip_of_tree_hash:
description: 'Trunk hash'
type: string
patch_id:
description: 'Patch id (patch series not supported)'
type: string
original_patch_issue_num:
description: 'Issue number to link against'
type: string
workflow_dispatch:
branches:
- main
inputs:
timestamp:
description: 'Patch Timestamp (UTC)'
required: true
baseline_gcc_hash:
description: 'Baseline hash'
required: false
tip_of_tree_hash:
description: 'Trunk hash'
required: false
patch_id:
description: 'Patch id (patch series not supported)'
required: false
original_patch_issue_num:
description: 'Issue number to link against'
required: false
jobs:
fetch_patches:
# This is a dedicated self hosted runner that will always* run this on time
runs-on: [self-hosted, ping]
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- name: Cleanup build folder
working-directory: ./
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Install dependencies
run: |
sudo apt install python3 -y
sudo apt install python-is-python3 -y
sudo apt install zip -y
- name: Get timestamps and make directories
if: ${{ inputs.timestamp == '' }}
run: |
if [ "${{ github.workflow }}" == "Staging" ] && [ "${{ github.event_name }}" == "schedule" ]; then
python scripts/create_timestamp_files.py -token ${{ secrets.GITHUB_TOKEN }} -rid ${{ github.run_id }} -repo ewlu/gcc-precommit-ci -workflow Staging
else
python scripts/create_timestamp_files.py -token ${{ secrets.GITHUB_TOKEN }} -rid ${{ github.run_id }} -repo ewlu/gcc-precommit-ci -workflow Patchworks
fi
cat runs.log
cat prior_run_time_minus_15_min_rounded.txt
cat prior_run_time_rounded.txt
cat current_time_rounded.txt
- name: Update times for workflow dispatch
if: ${{ inputs.timestamp != '' }}
run: |
# only use date to convert timestamp to isoformatted time.
python scripts/create_timestamp_files.py -timestamp $(date -d "${{ inputs.timestamp }}" '+%Y-%m-%dT%H:%M:%S')
cat prior_run_time_minus_15_min_rounded.txt
cat prior_run_time_rounded.txt
cat current_time_rounded.txt
- name: Get list of new patches
run: |
mkdir -p patch_urls
mkdir -p patchworks_metadata
if [ "${{ inputs.patch_id }}" == "" ]; then
python scripts/create_patches_files.py -backup $(cat prior_run_time_minus_15_min_rounded.txt) -start $(cat prior_run_time_rounded.txt) -end $(cat current_time_rounded.txt)
else
python scripts/create_patches_files.py -patch ${{ inputs.patch_id }}
fi
if [ "${{ github.workflow }}" == "Staging" ] && [ "${{ github.event_name }}" == "schedule" ]; then
echo "Running non riscv patches"
# save riscv patches
mv patch_urls riscv_patch_urls
mv patchworks_metadata riscv_patchworks_metadata
mv artifact_names.txt riscv_artifact_names.txt
echo "saved riscv patches"
ls riscv_patch_urls
# setup again to get all patches so we can get the difference and avoid double work
mkdir -p patch_urls
mkdir -p patchworks_metadata
python scripts/create_patches_files.py -backup $(cat prior_run_time_minus_15_min_rounded.txt) -start $(cat prior_run_time_rounded.txt) -end $(cat current_time_rounded.txt) -all-patches
echo "all found patches"
ls patch_urls
# if there are riscv patches in this batch, remove them. otherwise leave as is
if [ "$(ls riscv_patch_urls)" ]; then
# perform the difference
for file in riscv_patch_urls/*; do
base=$(basename $file)
echo "removing $base from all found patches"
rm -rf patch_urls/$base patchworks_metadata/$base
cat artifact_names.txt | sed "s/\s*'$base'\s*//g" | sed "s/,,/,/g" | sed "s/,\]/\]/g" | sed "s/\[,/\[/g"> temp.txt
mv temp.txt artifact_names.txt
done
fi
fi
- name: List patch artifacts
id: list_patches
run: |
export PATCHLIST="$(cat artifact_names.txt)"
echo "patch_list=$PATCHLIST" >> $GITHUB_OUTPUT
- name: Upload patch urls
if: ${{ steps.list_patches.outputs.patch_list != '[]' }}
uses: actions/upload-artifact@v4
with:
name: patch_urls
path: |
riscv-gnu-toolchain/patch_urls
retention-days: 90
- name: Upload patchworks metadata
if: ${{ steps.list_patches.outputs.patch_list != '[]' }}
uses: actions/upload-artifact@v4
with:
name: patchworks_metadata_files
path: |
riscv-gnu-toolchain/patchworks_metadata
retention-days: 90
outputs:
list_of_patch_names: ${{ steps.list_patches.outputs.patch_list }}
init-submodules:
needs: [fetch_patches]
if: ${{ needs.fetch_patches.outputs.list_of_patch_names != '[]' }}
uses: ./.github/workflows/init-submodules.yaml
with:
baseline_hash: ${{ inputs.baseline_gcc_hash }}
tot_hash: ${{ inputs.tip_of_tree_hash }}
patch_matrix:
needs: [fetch_patches, init-submodules]
strategy:
fail-fast: false
matrix:
patch_name: ${{ fromJSON(needs.fetch_patches.outputs.list_of_patch_names) }}
uses: ./.github/workflows/run-checks.yaml
permissions:
issues: write
with:
patch_name: ${{ matrix.patch_name }}
baseline_hash: ${{ needs.init-submodules.outputs.baseline_hash }}
tot_hash: ${{ needs.init-submodules.outputs.tot_hash }}
original_patch_issue_num: ${{ inputs.original_patch_issue_num }}
secrets: inherit