From 3093657b77363c0f1066cb9aaf76623c2ef32286 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 16 Feb 2024 21:34:02 +0000 Subject: [PATCH 01/68] [workflows] Port buildkite Windows config to GitHub actions This reuses most of the generate-buildkite-pipeline-premerge script which determines which projects to build and which check targets to use. This new workflow only tests clang, llvm, and lld due to resource contraints on the GitHub runners. --- .../compute-projects-to-test/action.yml | 21 ++ .../compute-projects-to-test.sh | 220 ++++++++++++++++++ .github/workflows/precommit-windows.yml | 61 +++++ 3 files changed, 302 insertions(+) create mode 100644 .github/workflows/compute-projects-to-test/action.yml create mode 100755 .github/workflows/compute-projects-to-test/compute-projects-to-test.sh create mode 100644 .github/workflows/precommit-windows.yml diff --git a/.github/workflows/compute-projects-to-test/action.yml b/.github/workflows/compute-projects-to-test/action.yml new file mode 100644 index 0000000000000..37df06c8c301c --- /dev/null +++ b/.github/workflows/compute-projects-to-test/action.yml @@ -0,0 +1,21 @@ +name: 'Compute Projects To Test' +inputs: + projects: + required: false + type: 'string' + +outputs: + check-targets: + description: "A space delimited list of check-targets to pass to ninja." + value: ${{ steps.compute-projects.outputs.check-targets }} + + projects: + description: "A semi-colon delimited list of projects to pass to -DLLVM_ENABLE_PROJECTS." + value: ${{ steps.compute-projects.outputs.projects }} + +runs: + using: "composite" + steps: + - id: compute-projects + run: .github/workflows/compute-projects-to-test/compute-projects-to-test.sh ${{ inputs.projects }} + shell: bash diff --git a/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh b/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh new file mode 100755 index 0000000000000..807142668f618 --- /dev/null +++ b/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh @@ -0,0 +1,220 @@ +#!/usr/bin/env bash +#===----------------------------------------------------------------------===## +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#===----------------------------------------------------------------------===## + +# +# This file generates a Buildkite pipeline that triggers the various CI jobs for +# the LLVM project during pre-commit CI. +# +# See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format. +# +# As this outputs a yaml file, it's possible to log messages to stderr or +# prefix with "#". + + +set -eu +set -o pipefail + +# Environment variables script works with: + +# Set by GitHub +: ${GITHUB_OUTPUT:=} +: ${RUNNER_OS:=} + +# Allow users to specify which projects to build. +all_projects="bolt clang clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl" +if [ "$#" -ne 0 ]; then + wanted_projects="${@}" +else + wanted_projects="${all_projects}" +fi + +# List of files affected by this commit +: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1...HEAD)} + +echo "Files modified:" >&2 +echo "$MODIFIED_FILES" >&2 +modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u) +echo "Directories modified:" >&2 +echo "$modified_dirs" >&2 +echo "wanted_projects: $wanted_projects" + +function remove-unwanted-projects() { + projects=${@} + for project in ${projects}; do + if echo "$wanted_projects" | tr ' ' '\n' | grep -q -E "^${project}$"; then + echo "${project}" + fi + done +} + +function compute-projects-to-test() { + projects=${@} + for project in ${projects}; do + echo "${project}" + case ${project} in + lld) + for p in bolt cross-project-tests; do + echo $p + done + ;; + llvm) + for p in bolt clang clang-tools-extra flang lld lldb mlir polly; do + echo $p + done + ;; + clang) + for p in clang-tools-extra compiler-rt flang libc lldb openmp cross-project-tests; do + echo $p + done + ;; + clang-tools-extra) + echo libc + ;; + mlir) + echo flang + ;; + *) + # Nothing to do + ;; + esac + done +} + +function add-dependencies() { + projects=${@} + for project in ${projects}; do + echo "${project}" + case ${project} in + bolt) + for p in lld llvm; do + echo $p + done + ;; + cross-project-tests) + for p in lld clang; do + echo $p + done + ;; + clang-tools-extra) + for p in llvm clang; do + echo $p + done + ;; + compiler-rt|libc|openmp) + echo clang lld + ;; + flang|lldb) + for p in llvm clang; do + echo $p + done + ;; + lld|mlir|polly) + echo llvm + ;; + *) + # Nothing to do + ;; + esac + done +} + +function exclude-linux() { + projects=${@} + for project in ${projects}; do + case ${project} in + cross-project-tests) ;; # tests failing + lldb) ;; # tests failing + openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410 + *) + echo "${project}" + ;; + esac + done +} + +function exclude-windows() { + projects=${@} + for project in ${projects}; do + case ${project} in + cross-project-tests) ;; # tests failing + compiler-rt) ;; # tests taking too long + openmp) ;; # TODO: having trouble with the Perl installation + libc) ;; # no Windows support + lldb) ;; # tests failing + bolt) ;; # tests are not supported yet + *) + echo "${project}" + ;; + esac + done +} + +# Prints only projects that are both present in $modified_dirs and the passed +# list. +function keep-modified-projects() { + projects=${@} + for project in ${projects}; do + if echo "$modified_dirs" | grep -q -E "^${project}$"; then + echo "${project}" + fi + done +} + +function check-targets() { + projects=${@} + for project in ${projects}; do + case ${project} in + clang-tools-extra) + echo "check-clang-tools" + ;; + compiler-rt) + echo "check-all" + ;; + cross-project-tests) + echo "check-cross-project" + ;; + lldb) + echo "check-all" # TODO: check-lldb may not include all the LLDB tests? + ;; + pstl) + echo "check-all" + ;; + libclc) + echo "check-all" + ;; + *) + echo "check-${project}" + ;; + esac + done +} + +# Generic pipeline for projects that have not defined custom steps. +# +# Individual projects should instead define the pre-commit CI tests that suits their +# needs while letting them run on the infrastructure provided by LLVM. + +# Figure out which projects need to be built on each platform +modified_projects="$(keep-modified-projects ${all_projects})" +echo "modified_projects: $modified_projects" + +if [ "${RUNNER_OS}" = "Linux" ]; then + projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_projects})) +elif [ "${RUNNER_OS}" = "Windows" ]; then + projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects})) +else + echo "Unknown runner OS: $RUNNER_OS" +fi +check_targets=$(check-targets $(remove-unwanted-projects ${projects_to_test}) | sort | uniq) +projects=$(remove-unwanted-projects $(add-dependencies ${projects_to_test}) | sort | uniq) + +echo "check-targets=$(echo ${check_targets} | tr ' ' ' ')" >> $GITHUB_OUTPUT +echo "projects=$(echo ${projects} | tr ' ' ';')" >> $GITHUB_OUTPUT + +cat $GITHUB_OUTPUT diff --git a/.github/workflows/precommit-windows.yml b/.github/workflows/precommit-windows.yml new file mode 100644 index 0000000000000..4864ab72241dd --- /dev/null +++ b/.github/workflows/precommit-windows.yml @@ -0,0 +1,61 @@ +name: "Windows Precommit Tests" + +permissions: + contents: read + +on: + pull_request: + branches: + - main + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + build-llvm-windows: + name: "Build and test LLVM (Windows)" + runs-on: windows-2022 + steps: + - name: Setup Windows + uses: llvm/actions/setup-windows@main + with: + arch: amd64 + - name: Fetch LLVM sources + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1 + with: + max-size: 500M + variant: sccache + key: precommit-windows + - name: Compute projects to test + id: compute-projects + uses: ./.github/workflows/compute-projects-to-test + with: + projects: clang llvm lld + + - name: Configure LLVM + shell: bash + if: ${{ steps.compute-projects.outputs.check-targets }} + run: | + cmake -B build -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="${{ steps.compute-projects.outputs.projects }}" \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_LIT_ARGS="-v --no-progress-bar" \ + -S llvm + - name: Build LLVM + if: ${{ steps.compute-projects.outputs.check-targets }} + run: | + ninja -C build test-depends + - name: Check LLVM + if: ${{ steps.compute-projects.outputs.check-targets }} + run: | + ninja -C build "${{ steps.compute-projects.outputs.check-targets }}" From 673c0788673e27ca43dcc869e0506adc1ec87a30 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 17 Feb 2024 05:04:31 +0000 Subject: [PATCH 02/68] Workflow improvements: * Split the build into 3 jobs to avoid timeouts. * Maintiain an scacche cache that is unique for each PR. --- .../workflows/pr-sccache-restore/action.yml | 44 +++++ .github/workflows/pr-sccache-save/action.yml | 38 ++++ .github/workflows/precommit-windows.yml | 171 ++++++++++++++++-- 3 files changed, 236 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/pr-sccache-restore/action.yml create mode 100644 .github/workflows/pr-sccache-save/action.yml diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml new file mode 100644 index 0000000000000..9b620c7bdcbbe --- /dev/null +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -0,0 +1,44 @@ +name: PR sccache restore + +runs: + using: "composite" + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + id: artifact-url + with: + script: | + const data = await github.rest.actions.listArtifactsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + name: 'sccache-pr' + context.issue.number + }) + + console.log(data.data.artifacts) + + for (artifact of data.data.artifacts) { + if (artifact.expired) { + continue; + } + console.log(artifact) + const url = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: "zip" + }) + console.log(url.url) + return url.url + } + console.log("Could not find previous sccache for this PR.") + return "" + + - shell: bash + if: steps.artifact-url.outputs.result != '' + run: | + curl -L -o sccache-pr${{ github.event.number }}.zip ${{ steps.artifact-url.outputs.result }} + # Is this the best way to clear the cache? + rm -Rf .sccache/ + unzip -d .sccache sccache-pr${{ github.event.number}}.zip + ls -ltr + + diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml new file mode 100644 index 0000000000000..43f0cb29115b8 --- /dev/null +++ b/.github/workflows/pr-sccache-save/action.yml @@ -0,0 +1,38 @@ +name: PR sccache save + +runs: + using: "composite" + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + with: + script: | + const data = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + name: 'sccache-pr' + context.issue.number + }) + + console.log(data.data.artifacts) + if (data.data.artifacts.length == 0) { + return ''; + } + console.log(data.data.artifacts[0]) + const artifact_id = data.data.artifacts[0].id + + // Delete the exisitng artifact so we can upload a new one with the same name. + github.rest.actions.deleteArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact_id + }) + + - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: 'sccache-pr${{ github.event.number }}' + path: .sccache + retention-days: 7 + + - shell: bash + run: | + sccache --show-stats + diff --git a/.github/workflows/precommit-windows.yml b/.github/workflows/precommit-windows.yml index 4864ab72241dd..ddcaa656215b3 100644 --- a/.github/workflows/precommit-windows.yml +++ b/.github/workflows/precommit-windows.yml @@ -15,47 +15,184 @@ concurrency: cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} jobs: - build-llvm-windows: - name: "Build and test LLVM (Windows)" + compute-projects: + name: "Compute Projects to Test" + runs-on: ubuntu-22.04 + outputs: + projects: ${{ steps.vars.outputs.projects }} + check-targets: ${{ steps.vars.outputs.check-targets }} + test-build: ${{ steps.vars.outputs.check-targets != '' }} + steps: + - name: Fetch LLVM sources + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Compute projects to test + id: vars + uses: ./.github/workflows/compute-projects-to-test + + build-windows-part1: + name: "Build LLVM/Clang" runs-on: windows-2022 + needs: + - compute-projects + if: ${{ needs.compute-projects.outputs.test-build == 'true' }} steps: - name: Setup Windows uses: llvm/actions/setup-windows@main with: arch: amd64 + - name: Fetch LLVM sources uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Setup ccache + + - name: Setup sccache uses: hendrikmuhs/ccache-action@v1 with: - max-size: 500M + max-size: 2G variant: sccache key: precommit-windows + + - name: Restore sccache from previous PR run + uses: ./.github/workflows/pr-sccache-restore + - name: Compute projects to test id: compute-projects uses: ./.github/workflows/compute-projects-to-test - with: - projects: clang llvm lld - name: Configure LLVM shell: bash - if: ${{ steps.compute-projects.outputs.check-targets }} run: | cmake -B build -GNinja \ -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_PROJECTS="${{ steps.compute-projects.outputs.projects }}" \ - -DCMAKE_C_COMPILER_LAUNCHER=sccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ + -DLLVM_ENABLE_PROJECTS="${{ needs.compute-projects.outputs.projects }}" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_LIT_ARGS="-v --no-progress-bar" \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -S llvm - - name: Build LLVM - if: ${{ steps.compute-projects.outputs.check-targets }} + + - name: Build + shell: bash + run: | + targets="llc" + if echo "${{ needs.compute-projects.outputs.check-targets }}" | grep clang; then + targets="$targets clang" + fi + ninja -C build $targets + + - name: Save sccache for next PR run + if: always() + uses: ./.github/workflows/pr-sccache-save + + - name: Package Build Directory + shell: bash run: | - ninja -C build test-depends + tar -c . | zstd -T0 -c > ../llvm-project.tar.zst + mv ../llvm-project.tar.zst . + + - name: Upload Build + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: part1 + path: llvm-project.tar.zst + retention-days: 2 + + build-windows-part2: + name: "Build All" + needs: + - build-windows-part1 + runs-on: windows-2022 + steps: + - name: Setup Windows + uses: llvm/actions/setup-windows@main + with: + arch: amd64 + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1 + with: + max-size: 2G + variant: sccache + key: precommit-windows + # The llvm-project.zip archive contains the sccache directory from + # part 1, so we don't need to restore the cache. + restore: false + + - name: Download Artifact + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + with: + pattern: part1 + + - name: Unpack Artifact + shell: bash + run: | + tar --zstd -xf llvm-project.tar.zst + rm llvm-project.tar.zst + + - name: Build + shell: bash + run: | + ls + ninja -C build + + - name: Save sccache for next PR run + if: always() + uses: ./.github/workflows/pr-sccache-save + + - name: Package Build Directory + shell: bash + run: | + tar -c . | zstd -T0 -c > ../llvm-project.tar.zst + mv ../llvm-project.tar.zst . + + - name: Upload Build + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: part2 + path: llvm-project.tar.zst + retention-days: 2 + + test-windows: + name: "Test" + needs: + - compute-projects + - build-windows-part2 + runs-on: windows-2022 + steps: + - name: Setup Windows + uses: llvm/actions/setup-windows@main + with: + arch: amd64 + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1 + with: + max-size: 2G + variant: sccache + key: precommit-windows + # The llvm-project.zip archive contains the sccache directory from + # part 1, so we don't need to restore the cache. + restore: false + + - name: Download Artifact + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + with: + pattern: part2 + merge-multiple: true + + - name: Unpack Artifact + shell: bash + run: | + tar --zstd -xf llvm-project.tar.zst + rm llvm-project.tar.zst + - name: Check LLVM - if: ${{ steps.compute-projects.outputs.check-targets }} + if: ${{ needs.compute-projects.outputs.check-targets }} run: | - ninja -C build "${{ steps.compute-projects.outputs.check-targets }}" + ninja -C build ${{ needs.compute-projects.outputs.check-targets }} + + - name: Save sccache for next PR run + if: always() + uses: ./.github/workflows/pr-sccache-save From 9e9aee138525ca8177a8c9cb9218a3256269dc04 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 29 Apr 2024 06:38:36 -0700 Subject: [PATCH 03/68] Automatically continue the CI job when it times out This simplifies the workflow a lot and will enable us to support builds that take more than 6 hours. --- .github/workflows/continue-timeout-job.yml | 69 ++++++++ .../workflows/pr-sccache-restore/action.yml | 1 - .github/workflows/pr-sccache-save/action.yml | 4 +- .github/workflows/precommit-windows.yml | 160 ++++++------------ 4 files changed, 122 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/continue-timeout-job.yml diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml new file mode 100644 index 0000000000000..65704c29cbe43 --- /dev/null +++ b/.github/workflows/continue-timeout-job.yml @@ -0,0 +1,69 @@ +name: Continue Timeout Job + +on: + workflow_run: + workflows: + - "Windows Precommit Tests" + types: + - completed + +permissions: + contents: read + +jobs: + restart: + name: "Restart Job" + permissions: + actions: write + runs-on: ubuntu-22.04 + if: github.event.workflow_run.conclusion == 'failure' + steps: + - name: "Restart Job" + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + with: + script: | + const data = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id + }) + + for (artifact of data.data.artifacts) { + if (artifact.name != 'timeout') { + continue; + } + + // Delete the timeout artifact to prepare for the next run + await github.rest.actions.deleteArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id + }) + + const job_data = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id + }); + + for (job of job_data.data.jobs) { + console.log(job) + if (job.name != "Build") { + continue; + } + if (job.conclusion == "success") { + // IS this possible? + return "success"; + } + + // Restart the job + // This function does not exist even though it is in the document + //github.rest.actions.reRunJobForWorkflow({ + await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + owner: context.repo.owner, + repo: context.repo.repo, + job_id: job.id + }) + return "timeout" + } + } diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index 9b620c7bdcbbe..abae90f7929c8 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -30,7 +30,6 @@ runs: return url.url } console.log("Could not find previous sccache for this PR.") - return "" - shell: bash if: steps.artifact-url.outputs.result != '' diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index 43f0cb29115b8..def50fbc14d53 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -9,6 +9,7 @@ runs: const data = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, + run_id: context.runId, name: 'sccache-pr' + context.issue.number }) @@ -19,13 +20,14 @@ runs: console.log(data.data.artifacts[0]) const artifact_id = data.data.artifacts[0].id - // Delete the exisitng artifact so we can upload a new one with the same name. + // Delete the exisiting artifact so we can upload a new one with the same name. github.rest.actions.deleteArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: artifact_id }) + - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: name: 'sccache-pr${{ github.event.number }}' diff --git a/.github/workflows/precommit-windows.yml b/.github/workflows/precommit-windows.yml index ddcaa656215b3..e6660e71c20f9 100644 --- a/.github/workflows/precommit-windows.yml +++ b/.github/workflows/precommit-windows.yml @@ -2,6 +2,7 @@ name: "Windows Precommit Tests" permissions: contents: read + actions: write on: pull_request: @@ -32,19 +33,43 @@ jobs: id: vars uses: ./.github/workflows/compute-projects-to-test - build-windows-part1: - name: "Build LLVM/Clang" + build-windows: + name: "Build" runs-on: windows-2022 + permissions: + actions: write #pr-sccache-save may delete artifacts. + outputs: + build-timeout: ${{ steps.build.outputs.timeout }} + build-failed: ${{ steps.build.outputs.failed }} needs: - compute-projects if: ${{ needs.compute-projects.outputs.test-build == 'true' }} steps: + - name: Download Artifact + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + with: + pattern: timeout-build + merge-multiple: true + + - name: Unpack Artifact + id: timeout-artifact + shell: bash + run: | + if [ -e llvm-project.tar.zst ]; then + tar --zstd -xf llvm-project.tar.zst + rm llvm-project.tar.zst + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + - name: Setup Windows uses: llvm/actions/setup-windows@main with: arch: amd64 - name: Fetch LLVM sources + if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} uses: actions/checkout@v4 - name: Setup sccache @@ -53,15 +78,12 @@ jobs: max-size: 2G variant: sccache key: precommit-windows - + - name: Restore sccache from previous PR run uses: ./.github/workflows/pr-sccache-restore - - name: Compute projects to test - id: compute-projects - uses: ./.github/workflows/compute-projects-to-test - - - name: Configure LLVM + - name: Configure + if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} shell: bash run: | cmake -B build -GNinja \ @@ -75,124 +97,42 @@ jobs: - name: Build shell: bash + id: build + timeout-minutes: 330 run: | - targets="llc" - if echo "${{ needs.compute-projects.outputs.check-targets }}" | grep clang; then - targets="$targets clang" - fi - ninja -C build $targets + touch timeout + ninja -C build -k 0 ${{ needs.compute-projects.outputs.check-targets }} && pass=1 + rm timeout + [ $pass ] || false - - name: Save sccache for next PR run - if: always() - uses: ./.github/workflows/pr-sccache-save - - - name: Package Build Directory - shell: bash - run: | - tar -c . | zstd -T0 -c > ../llvm-project.tar.zst - mv ../llvm-project.tar.zst . - - - name: Upload Build + - name: Upload Timeout Message uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + id: timeout + if: always() with: - name: part1 - path: llvm-project.tar.zst + name: timeout + path: timeout retention-days: 2 - build-windows-part2: - name: "Build All" - needs: - - build-windows-part1 - runs-on: windows-2022 - steps: - - name: Setup Windows - uses: llvm/actions/setup-windows@main - with: - arch: amd64 - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1 - with: - max-size: 2G - variant: sccache - key: precommit-windows - # The llvm-project.zip archive contains the sccache directory from - # part 1, so we don't need to restore the cache. - restore: false - - - name: Download Artifact - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 - with: - pattern: part1 - - - name: Unpack Artifact - shell: bash - run: | - tar --zstd -xf llvm-project.tar.zst - rm llvm-project.tar.zst - - - name: Build - shell: bash - run: | - ls - ninja -C build - - name: Save sccache for next PR run if: always() uses: ./.github/workflows/pr-sccache-save - + - name: Package Build Directory shell: bash + if: always() && steps.timeout.outputs.artifact-id != '' run: | - tar -c . | zstd -T0 -c > ../llvm-project.tar.zst + # Remove the timeout file, so the next build isn't categorized + # as a timeout. + rm -f timeout + # Dereference symlinks so that this works on Windows. + tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst mv ../llvm-project.tar.zst . - name: Upload Build uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + if: always() && steps.timeout.outputs.artifact-id != '' with: - name: part2 + name: timeout-build path: llvm-project.tar.zst retention-days: 2 - - test-windows: - name: "Test" - needs: - - compute-projects - - build-windows-part2 - runs-on: windows-2022 - steps: - - name: Setup Windows - uses: llvm/actions/setup-windows@main - with: - arch: amd64 - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1 - with: - max-size: 2G - variant: sccache - key: precommit-windows - # The llvm-project.zip archive contains the sccache directory from - # part 1, so we don't need to restore the cache. - restore: false - - - name: Download Artifact - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 - with: - pattern: part2 - merge-multiple: true - - - name: Unpack Artifact - shell: bash - run: | - tar --zstd -xf llvm-project.tar.zst - rm llvm-project.tar.zst - - - name: Check LLVM - if: ${{ needs.compute-projects.outputs.check-targets }} - run: | - ninja -C build ${{ needs.compute-projects.outputs.check-targets }} - - - name: Save sccache for next PR run - if: always() - uses: ./.github/workflows/pr-sccache-save From a7ff883345ee91779af35a4b5f5df3f208913f3b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 2 May 2024 18:12:35 -0700 Subject: [PATCH 04/68] Re-write continue-timeout-job to be more generic --- .../compute-projects-to-test.sh | 1 + .github/workflows/continue-timeout-job.yml | 71 ++++++++++--------- .github/workflows/get-job-id/action.yml | 30 ++++++++ .../workflows/pr-sccache-restore/action.yml | 39 ++-------- .github/workflows/precommit-windows.yml | 23 ++++-- .../unprivileged-download-artifact/action.yml | 67 +++++++++++++++++ .../workflows/write-timeout-file/action.yml | 17 +++++ 7 files changed, 177 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/get-job-id/action.yml create mode 100644 .github/workflows/unprivileged-download-artifact/action.yml create mode 100644 .github/workflows/write-timeout-file/action.yml diff --git a/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh b/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh index 807142668f618..4cfbda0c82034 100755 --- a/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh +++ b/.github/workflows/compute-projects-to-test/compute-projects-to-test.sh @@ -210,6 +210,7 @@ elif [ "${RUNNER_OS}" = "Windows" ]; then projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects})) else echo "Unknown runner OS: $RUNNER_OS" + exit 1 fi check_targets=$(check-targets $(remove-unwanted-projects ${projects_to_test}) | sort | uniq) projects=$(remove-unwanted-projects $(add-dependencies ${projects_to_test}) | sort | uniq) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 65704c29cbe43..7f25a0a2adebd 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -18,52 +18,53 @@ jobs: runs-on: ubuntu-22.04 if: github.event.workflow_run.conclusion == 'failure' steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/workflows/unprivileged-download-artifact + sparse-checkout-cone-mode: false + + - uses: ./.github/workflows/unprivileged-download-artifact + id: download-artifact + with: + run-id: ${{ github.event.workflow_run.id }} + artifact-name: timeout + + - shell: bash + if: steps.download-artifact.outputs.filename != '' + run: | + unzip ${{ steps.download-artifact.outputs.filename }} + - name: "Restart Job" + if: steps.download-artifact.outputs.filename != '' uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - const data = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id - }) - - for (artifact of data.data.artifacts) { - if (artifact.name != 'timeout') { - continue; + var fs = require('fs'); + const data = fs.readFileSync('./timeout'); + console.log(data); + const json = JSON.parse(data); + console.log(json); + if (!json || !json.job_id) { + console.log("Could not parse timeout artifact"); + return; } + const job_id = json.job_id // Delete the timeout artifact to prepare for the next run await github.rest.actions.deleteArtifact({ owner: context.repo.owner, repo: context.repo.repo, - artifact_id: artifact.id + artifact_id: ${{ steps.download-artifact.outputs.artifact-id }} }) - const job_data = await github.rest.actions.listJobsForWorkflowRun({ + // Restart the job + // This function does not exist even though it is in the document + //github.rest.actions.reRunJobForWorkflow({ + await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { owner: context.repo.owner, repo: context.repo.repo, - run_id: context.payload.workflow_run.id - }); - - for (job of job_data.data.jobs) { - console.log(job) - if (job.name != "Build") { - continue; - } - if (job.conclusion == "success") { - // IS this possible? - return "success"; - } - - // Restart the job - // This function does not exist even though it is in the document - //github.rest.actions.reRunJobForWorkflow({ - await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { - owner: context.repo.owner, - repo: context.repo.repo, - job_id: job.id - }) - return "timeout" - } - } + job_id: job_id + }) + console.log("Restarted job: " + job_id); + return "timeout" diff --git a/.github/workflows/get-job-id/action.yml b/.github/workflows/get-job-id/action.yml new file mode 100644 index 0000000000000..65495efd86820 --- /dev/null +++ b/.github/workflows/get-job-id/action.yml @@ -0,0 +1,30 @@ +name: Get Job ID +inputs: + job-name: + required: false + type: 'string' + +outputs: + job-id: + description: "A space delimited list of check-targets to pass to ninja." + value: ${{ steps.job-id.outputs.result }} + +runs: + using: "composite" + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + id: job-id + with: + script: | + const job_data = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }); + + for (job of job_data.data.jobs) { + console.log(job) + if (job.name == "${{ inputs.job-name }}") { + return job.id + } + } diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index abae90f7929c8..6c62d0e0de9f9 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -3,41 +3,16 @@ name: PR sccache restore runs: using: "composite" steps: - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 - id: artifact-url + - uses: ./.github/workflows/unprivileged-download-artifact + id: download-artifact with: - script: | - const data = await github.rest.actions.listArtifactsForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - name: 'sccache-pr' + context.issue.number - }) - - console.log(data.data.artifacts) - - for (artifact of data.data.artifacts) { - if (artifact.expired) { - continue; - } - console.log(artifact) - const url = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: "zip" - }) - console.log(url.url) - return url.url - } - console.log("Could not find previous sccache for this PR.") + run-id: ${{ github.run_id }} + artifact-name: sccache-pr${{ github.event.pull_request.number }} - shell: bash - if: steps.artifact-url.outputs.result != '' + if: steps.download-artifact.outputs.filename != '' run: | - curl -L -o sccache-pr${{ github.event.number }}.zip ${{ steps.artifact-url.outputs.result }} # Is this the best way to clear the cache? rm -Rf .sccache/ - unzip -d .sccache sccache-pr${{ github.event.number}}.zip - ls -ltr - - + unzip ${{ steps.download-artifact.outputs.filename }} + rm ${{ steps.download-artifact.outputs.filename }} diff --git a/.github/workflows/precommit-windows.yml b/.github/workflows/precommit-windows.yml index e6660e71c20f9..2ccf1fbee2270 100644 --- a/.github/workflows/precommit-windows.yml +++ b/.github/workflows/precommit-windows.yml @@ -6,18 +6,26 @@ permissions: on: pull_request: + types: + - opened + - synchronize + - reopened + # When a PR is closed, we still start this workflow, but then skip + # all the jobs, which makes it effectively a no-op. The reason to + # do this is that it allows us to take advantage of concurrency groups + # to cancel in progress CI jobs whenever the PR is closed. + - closed branches: - main concurrency: - # Skip intermediate builds: always. - # Cancel intermediate builds: only if it is a pull request build. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: True jobs: compute-projects: name: "Compute Projects to Test" + if: github.event.action != 'closed' runs-on: ubuntu-22.04 outputs: projects: ${{ steps.vars.outputs.projects }} @@ -34,6 +42,8 @@ jobs: uses: ./.github/workflows/compute-projects-to-test build-windows: + # If this job name is chagned, then we need to update the job-name + # paramater for the write-timeout-file step below. name: "Build" runs-on: windows-2022 permissions: @@ -95,6 +105,11 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -S llvm + - name: Write Timeout File + uses: ./.github/workflows/write-timeout-file + with: + job-name: "Build" + - name: Build shell: bash id: build diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml new file mode 100644 index 0000000000000..5e63f5ce8e3fe --- /dev/null +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -0,0 +1,67 @@ +name: Unprivileged Download Artifact +description: Download artifacts from another workflow run without using an access token. +inputs: + run-id: + description: The run-id for the workflow run that you want to download the artifact from. + required: true + artifact-name: + desciption: The name of the artifact to download. + required: true + +outputs: + filename: + description: "The filename of the downloaded artifact or the empty string if the artifact was not found." + value: ${{ steps.download-artifact.outputs.filename }} + artifact-id: + description: "The id of the artifact being downloaded." + value: ${{ steps.artifact-url.outputs.id }} + + +runs: + using: "composite" + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + id: artifact-url + with: + script: | + const response = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ inputs.run-id }}, + name: "${{ inputs.artifact-name }}" + }) + + console.log(response) + + for (artifact of response.data.artifacts) { + console.log(artifact); + } + + if (response.data.artifacts.length == 0) { + console.log("Could not find artifact ${{ inputs.artifact-name }} for workflow run ${{ inputs.run-id }}") + return; + } + + const url_response = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: response.data.artifacts[0].id, + archive_format: "zip" + }) + + core.setOutput("url", url_response.url); + core.setOutput("id", response.data.artifacts[0].id); + + - shell: bash + run: | + echo "${{ steps.artifact-url.outputs.url }}" + echo "${{ steps.artifact-url.outputs.result }}" + echo "${{ steps.artifact-url.outputs.result.url }}" + echo "${{ steps.artifact-url.outputs.result.id }}" + + - shell: bash + if: steps.artifact-url.outputs.url != '' + id: download-artifact + run: | + curl -L -o ${{ inputs.artifact-name }}.zip "${{ steps.artifact-url.outputs.url }}" + echo "filename=${{ inputs.artifact-name }}.zip" >> $GITHUB_OUTPUT diff --git a/.github/workflows/write-timeout-file/action.yml b/.github/workflows/write-timeout-file/action.yml new file mode 100644 index 0000000000000..a483185ab623f --- /dev/null +++ b/.github/workflows/write-timeout-file/action.yml @@ -0,0 +1,17 @@ +name: Write Timeout File +inputs: + job-name: + required: false + type: 'string' + +runs: + using: "composite" + steps: + - uses: ./.github/workflows/get-job-id + id: job-id + with: + job-name: ${{ inputs.job-name }} + + - shell: bash + run: | + echo '{"job_id": "${{ steps.job-id.outputs.job-id }}"}' > timeout From 3ff27a48cbba40a34bfcb74a7b7621989f6e2cb8 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 06:46:52 -0700 Subject: [PATCH 05/68] UPdate continue time-out-job --- .github/workflows/continue-timeout-job.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 7f25a0a2adebd..7efa274dae470 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -49,7 +49,6 @@ jobs: console.log("Could not parse timeout artifact"); return; } - const job_id = json.job_id // Delete the timeout artifact to prepare for the next run await github.rest.actions.deleteArtifact({ @@ -58,13 +57,14 @@ jobs: artifact_id: ${{ steps.download-artifact.outputs.artifact-id }} }) - // Restart the job - // This function does not exist even though it is in the document - //github.rest.actions.reRunJobForWorkflow({ - await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { - owner: context.repo.owner, - repo: context.repo.repo, - job_id: job_id - }) - console.log("Restarted job: " + job_id); - return "timeout" + for (job of json) { + // Restart the job + // This function does not exist even though it is in the document + //github.rest.actions.reRunJobForWorkflow({ + await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + owner: context.repo.owner, + repo: context.repo.repo, + job_id: job.job_id + }) + console.log("Restarted job: " + job_id); + } From 0406329fabe4e2fed113c460c5ee35183024a929 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 06:47:12 -0700 Subject: [PATCH 06/68] Make ci work on all platforms --- .github/workflows/pr-sccache-restore/action.yml | 7 ++++++- .github/workflows/pr-sccache-save/action.yml | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index 6c62d0e0de9f9..6a067dbd80f34 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -1,5 +1,10 @@ name: PR sccache restore +inputs: + artifact-name-suffix: + desciption: The suffix to append to the artifict name (sccache-pr${{ github.event.pull_request.number }}) + required: true + runs: using: "composite" steps: @@ -7,7 +12,7 @@ runs: id: download-artifact with: run-id: ${{ github.run_id }} - artifact-name: sccache-pr${{ github.event.pull_request.number }} + artifact-name: sccache-pr${{ github.event.pull_request.number }}-${{ inputs.artifact-name-suffix }} - shell: bash if: steps.download-artifact.outputs.filename != '' diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index def50fbc14d53..b75c27a54bcaa 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -1,4 +1,8 @@ name: PR sccache save +inputs: + artifact-name-suffix: + desciption: The suffix to append to the artifict name (sccache-pr${{ github.event.pull_request.number }}) + required: true runs: using: "composite" @@ -10,7 +14,7 @@ runs: owner: context.repo.owner, repo: context.repo.repo, run_id: context.runId, - name: 'sccache-pr' + context.issue.number + name: 'sccache-pr' + context.issue.number + "-${{ inputs.artifact-name-suffix }}" }) console.log(data.data.artifacts) From 97bde01bf102932238b8aa768cd6a6e37ef47941 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 27 Apr 2024 15:02:30 -0700 Subject: [PATCH 07/68] DEBUG Add a file so that the CI triggers --- llvm/a | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 llvm/a diff --git a/llvm/a b/llvm/a new file mode 100644 index 0000000000000..e69de29bb2d1d From dd4e153dbf5fdd06205085264aa7b192c8da3d98 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 06:47:37 -0700 Subject: [PATCH 08/68] XXX: Add cI-tsts --- .github/workflows/ci-tests.yml | 228 +++++++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 .github/workflows/ci-tests.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000000000..5f274e3f6c71d --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,228 @@ +name: "CI Tests" + +permissions: + contents: read + actions: write + +on: + pull_request: + types: + - opened + - synchronize + - reopened + # When a PR is closed, we still start this workflow, but then skip + # all the jobs, which makes it effectively a no-op. The reason to + # do this is that it allows us to take advantage of concurrency groups + # to cancel in progress CI jobs whenever the PR is closed. + - closed + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: True + +jobs: + compute-test-configs: + name: "Compute Configurations to Test" + if: github.event.action != 'closed' + runs-on: ubuntu-22.04 + outputs: + projects: ${{ steps.vars.outputs.projects }} + check-targets: ${{ steps.vars.outputs.check-targets }} + test-build: ${{ steps.vars.outputs.check-targets != '' }} + enable-windows: ${{ steps.vars.platforms.enable-windows }} + enable-linux: ${{ steps.vars.platforms.enable-linux }} + enable-macos: $${ steps.vars.platforms.enable-macos }} + steps: + - name: Fetch LLVM sources + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Compute projects to test + id: vars + uses: ./.github/workflows/compute-test-configs-to-test + + - name: Compute platforms to test + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + id: platforms + with: + script: | + var enableLinux = false; + var enableWindows = false; + var enableMacOS = false + if (context.base_ref.startsWith('release/'))) { + // This is a pull request against a release branch. + enableLinux = true; + enableWindows = true; + enableMacOS = true; + } + enableLinux = true; + enableWindows = true; + enableMacOS = true; + core.setOutput("enable-windows", enableWindows); + core.setOutput("enable-linux", enableLinux); + core.setOutput("enable-macos", enableMacOS); + + + ci-build-test: + # If this job name is chagned, then we need to update the job-name + # paramater for the write-timeout-file step below. + name: "Build" + needs: + - compute-test-configs + permissions: + actions: write #pr-sccache-save may delete artifacts. + strategy: + fail-fast: false + matrix: + include: + - name: "linux-x86_64" + runs-on: ubuntu-22.04 + enabled: ${{ needs.compute-test-configs.enable-llvm == 'true' }} + - name: "windows-x86_64" + runs-on: windows-2022 + enabled: ${{ needs.compute-test-configs.enable-windows == 'true' }} + - name: "macos-x86_64" + runs-on: macos-13 + enabled: ${{ needs.compute-test-configs.enable-macos == 'true' }} + outputs: + job-id-linux-x86_64: ${{ steps.timeout.outputs.job-id-linux-x86_64 }} + job-id-windows-x86_64: ${{ steps.timeout.outputs.job-id-windows-x86_64 }} + job-id-macos-x86_64: ${{ steps.timeout.outputs.job-id-macos-x86_64 }} + + build-timeout: ${{ steps.build.outputs.timeout }} + build-failed: ${{ steps.build.outputs.failed }} + if: | + needs.compute-test-configs.outputs.test-build == 'true' && + matrix.enabled == 'true' + steps: + - name: Download Artifact + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + with: + pattern: timeout-build-${{ matrix.name }} + merge-multiple: true + + - name: Unpack Artifact + id: timeout-artifact + shell: bash + run: | + if [ -e llvm-project.tar.zst ]; then + tar --zstd -xf llvm-project.tar.zst + rm llvm-project.tar.zst + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Setup Windows + uses: llvm/actions/setup-windows@main + if: runner.os == "Windows" + with: + arch: amd64 + + - name: Fetch LLVM sources + if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} + uses: actions/checkout@v4 + + - name: Setup sccache + uses: hendrikmuhs/ccache-action@v1 + with: + max-size: 2G + variant: sccache + key: ci-${{ matrix.name }} + + - name: Restore sccache from previous PR run + uses: ./.github/workflows/pr-sccache-restore + with: + artifact-name-suffix: ${{ matrix.name }} + + - name: Configure + if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} + shell: bash + run: | + cmake -B build -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="${{ needs.compute-test-configs.outputs.projects }}" \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_LIT_ARGS="-v --no-progress-bar" \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ + -S llvm + + - name: Build + shell: bash + id: build + timeout-minutes: 1 + run: | + echo "timeout=true" >> $GITHUB_OUTPUT + ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} && pass=1 + echo "timeout=false" >> $GITHUB_OUTPUT + [ $pass ] || false + + - name: Save sccache for next PR run + if: always() + uses: ./.github/workflows/pr-sccache-save + with: + artifact-name-suffix: ${{ matrix.name }} + + - name: Get Job ID + if: always() && steps.build.outputs.timeout == 'true' + id: job-id + uses: ./.github/workflows/get-job-id + with: + job-name: ${{ inputs.job-name }} + + - name: Handle Timeout + shell: bash + if: always() && steps.build.outputs.timeout == 'true' + id: timeout + run: | + # Dereference symlinks so that this works on Windows. + tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst + mv ../llvm-project.tar.zst . + # Save the job-id so we can restart the job + echo "job-id-${{ matrix.name }}=${{ steps.job-id.outputs.job-id }}" >> $GITHUB_OUTPUT + + - name: Upload Build + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + if: always() && steps.build.outputs.timeout == 'true' + with: + name: timeout-build-${{ matrix.name }} + path: llvm-project.tar.zst + retention-days: 2 + + handle-timeout: + # If this job name is chagned, then we need to update the job-name + # paramater for the write-timeout-file step below. + name: "Handle Timeout" + if: always() + needs: + - ci-build-test + runs-on: ubuntu-22.04 + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + with: + script: | + timeouts = [] + console.log(needs) + console.log(needs.ci-build-test.outputs) + for (var of needs.ci-build-test.outputs) { + if (!var.startsWith("job-id")) { + continue; + } + if (needs.ci-build-tests.outputs[var]) { + timeouts.append({job_id : needs.ci-build-test.outputs[var]}) + } + } + + if (timeouts.length()) { + var fs = require('fs'); + fs.writeFile('timeout', JSON.stringify(timeouts)); + } + + - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: timeout + path: timeout From a99fae888884e6bbe19f55df59e3d52f524c1e70 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 06:51:36 -0700 Subject: [PATCH 09/68] XXX: disable windows tests --- .github/workflows/ci-tests.yml | 1 + .github/workflows/precommit-windows.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 5f274e3f6c71d..f7a941628ac39 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -74,6 +74,7 @@ jobs: - compute-test-configs permissions: actions: write #pr-sccache-save may delete artifacts. + runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/precommit-windows.yml b/.github/workflows/precommit-windows.yml index 2ccf1fbee2270..df28ff45da969 100644 --- a/.github/workflows/precommit-windows.yml +++ b/.github/workflows/precommit-windows.yml @@ -25,7 +25,7 @@ concurrency: jobs: compute-projects: name: "Compute Projects to Test" - if: github.event.action != 'closed' + if: github.event.action != 'closed' && false runs-on: ubuntu-22.04 outputs: projects: ${{ steps.vars.outputs.projects }} From d51508378f8dd03edceb92bffc0b5904c3c97e44 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 06:57:33 -0700 Subject: [PATCH 10/68] Fixes --- .github/workflows/ci-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index f7a941628ac39..3020c8b79dc27 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -95,9 +95,9 @@ jobs: build-timeout: ${{ steps.build.outputs.timeout }} build-failed: ${{ steps.build.outputs.failed }} - if: | + if: | ${{ needs.compute-test-configs.outputs.test-build == 'true' && - matrix.enabled == 'true' + matrix.enabled == 'true' $}} steps: - name: Download Artifact uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 @@ -119,7 +119,7 @@ jobs: - name: Setup Windows uses: llvm/actions/setup-windows@main - if: runner.os == "Windows" + if: ${{ runner.os == "Windows" }} with: arch: amd64 From 857b97c4dc8587be37580f140eae8b9a824b8753 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 09:28:45 -0700 Subject: [PATCH 11/68] FXX --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 3020c8b79dc27..052a9e2537625 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -97,7 +97,7 @@ jobs: build-failed: ${{ steps.build.outputs.failed }} if: | ${{ needs.compute-test-configs.outputs.test-build == 'true' && - matrix.enabled == 'true' $}} + matrix.enabled == 'true' }} steps: - name: Download Artifact uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 From bad285c9606a30ff5496571603fec0a078dee07a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 09:30:23 -0700 Subject: [PATCH 12/68] Fix --- .github/workflows/ci-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 052a9e2537625..c721969f139a1 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -95,9 +95,9 @@ jobs: build-timeout: ${{ steps.build.outputs.timeout }} build-failed: ${{ steps.build.outputs.failed }} - if: | ${{ + if: >- needs.compute-test-configs.outputs.test-build == 'true' && - matrix.enabled == 'true' }} + matrix.enabled == 'true' steps: - name: Download Artifact uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 From 486a771624959aeffcd4ce3aa2e020914bf0ac1c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 09:33:06 -0700 Subject: [PATCH 13/68] Fix --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index c721969f139a1..307f87bb02887 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -119,7 +119,7 @@ jobs: - name: Setup Windows uses: llvm/actions/setup-windows@main - if: ${{ runner.os == "Windows" }} + if: ${{ runner.os == 'Windows' }} with: arch: amd64 From f0ecc4b424073535282a07dde9f6b3b413e16fe6 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 09:34:23 -0700 Subject: [PATCH 14/68] Fix --- .github/workflows/ci-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 307f87bb02887..99de0977cc3b1 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -96,8 +96,7 @@ jobs: build-timeout: ${{ steps.build.outputs.timeout }} build-failed: ${{ steps.build.outputs.failed }} if: >- - needs.compute-test-configs.outputs.test-build == 'true' && - matrix.enabled == 'true' + needs.compute-test-configs.outputs.test-build == 'true' steps: - name: Download Artifact uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 From ba5c9c32a120c2e617eaffd4b1cc9d86e3d9a05e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 09:37:33 -0700 Subject: [PATCH 15/68] XXX --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 99de0977cc3b1..1998ae87dba7f 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -42,7 +42,7 @@ jobs: - name: Compute projects to test id: vars - uses: ./.github/workflows/compute-test-configs-to-test + uses: ./.github/workflows/compute-projects-to-test - name: Compute platforms to test uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 From 7752d5835f10840747e3dd59859ea5f017ff0b24 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 11:08:44 -0700 Subject: [PATCH 16/68] XXX: fix --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 1998ae87dba7f..2a5bdd21b03f7 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -52,7 +52,7 @@ jobs: var enableLinux = false; var enableWindows = false; var enableMacOS = false - if (context.base_ref.startsWith('release/'))) { + if (context.base_ref.startsWith('release/')) { // This is a pull request against a release branch. enableLinux = true; enableWindows = true; From a913c91067aaedc7d7fc01c03e400ce178ecc18d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 11:20:21 -0700 Subject: [PATCH 17/68] XXX: fix --- .github/workflows/ci-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 2a5bdd21b03f7..901a0e0939587 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -209,6 +209,7 @@ jobs: console.log(needs) console.log(needs.ci-build-test.outputs) for (var of needs.ci-build-test.outputs) { + console.log(var); if (!var.startsWith("job-id")) { continue; } From 98971b9a37c76a1602bb596f23b56d0416f2dc02 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 11:32:56 -0700 Subject: [PATCH 18/68] XXX: fix --- .github/workflows/ci-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 901a0e0939587..e4905a8e41496 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -52,6 +52,8 @@ jobs: var enableLinux = false; var enableWindows = false; var enableMacOS = false + console.log(context) + console.log(context.base_ref) if (context.base_ref.startsWith('release/')) { // This is a pull request against a release branch. enableLinux = true; From 27c3bfc7607c77453cd30b763b878a53f3b587e5 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 11:45:33 -0700 Subject: [PATCH 19/68] XXX: --- .github/workflows/ci-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index e4905a8e41496..387ad9e41f951 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -52,9 +52,8 @@ jobs: var enableLinux = false; var enableWindows = false; var enableMacOS = false - console.log(context) - console.log(context.base_ref) - if (context.base_ref.startsWith('release/')) { + const base_ref = process.env.GITHUB_BASE_REF; + if (base_ref.startsWith('release/')) { // This is a pull request against a release branch. enableLinux = true; enableWindows = true; From a2c09a88c177612034c5c1e00b9a7597d2b92b89 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 12:06:11 -0700 Subject: [PATCH 20/68] XXX: --- .github/workflows/pr-sccache-restore/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index 6a067dbd80f34..99817b03347b5 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -2,7 +2,7 @@ name: PR sccache restore inputs: artifact-name-suffix: - desciption: The suffix to append to the artifict name (sccache-pr${{ github.event.pull_request.number }}) + desciption: The suffix to append to the artifict name (sccache-pr#) required: true runs: From ac5203da0c032a7129b4cbe2751a8e7fdc643a42 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 12:10:29 -0700 Subject: [PATCH 21/68] Install ninja --- .github/workflows/ci-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 387ad9e41f951..7da5ed350e74f 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -122,6 +122,9 @@ jobs: if: ${{ runner.os == 'Windows' }} with: arch: amd64 + + - name: Install Ninja + uses: llvm/actions/install-ninja@main - name: Fetch LLVM sources if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} From 2a5542f52fe746669417ec20b05adbf6d5da9e03 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 12:16:36 -0700 Subject: [PATCH 22/68] XXX fix --- .github/workflows/pr-sccache-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index b75c27a54bcaa..c865a9895b984 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -1,7 +1,7 @@ name: PR sccache save inputs: artifact-name-suffix: - desciption: The suffix to append to the artifict name (sccache-pr${{ github.event.pull_request.number }}) + desciption: The suffix to append to the artifict name (sccache-pr#) required: true runs: From 6356bcbdd6210abc397c0fc459aafe0a6b259ae5 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 12:27:23 -0700 Subject: [PATCH 23/68] XXX: --- .github/workflows/ci-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 7da5ed350e74f..8e03baab4a364 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -49,6 +49,7 @@ jobs: id: platforms with: script: | + console.log(context); var enableLinux = false; var enableWindows = false; var enableMacOS = false From 3551d834b88f93daa627982bf1039ccbe42e814e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 13:22:58 -0700 Subject: [PATCH 24/68] XXX: fix timeout --- .github/workflows/ci-tests.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 8e03baab4a364..9fe69fa9c966b 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -210,16 +210,16 @@ jobs: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | + const job_ids = [ + "${{ needs.ci-build-test.outputs.job-id-linux-x86_64 }}", + "${{ needs.ci-build-test.outputs.job-id-windows-x86_64 }}", + "${{ needs.ci-build-test.outputs.job-id-macos-x86_64 }}" + ]; + timeouts = [] - console.log(needs) - console.log(needs.ci-build-test.outputs) - for (var of needs.ci-build-test.outputs) { - console.log(var); - if (!var.startsWith("job-id")) { - continue; - } - if (needs.ci-build-tests.outputs[var]) { - timeouts.append({job_id : needs.ci-build-test.outputs[var]}) + for (id of job_ids) { + if (id) { + timeouts.append({job_id : id}) } } From 6cdb82bc6fafbf3fd8abd7082a0a3583be74f3a2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 13:34:40 -0700 Subject: [PATCH 25/68] XXX --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 9fe69fa9c966b..480ef2dcb27d8 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -223,7 +223,7 @@ jobs: } } - if (timeouts.length()) { + if (timeouts.length) { var fs = require('fs'); fs.writeFile('timeout', JSON.stringify(timeouts)); } From 2cb707ca79141dd4b0b2c44dbe69a82e8a869bd1 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 14:18:43 -0700 Subject: [PATCH 26/68] Fix continue timeout --- .github/workflows/continue-timeout-job.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 7efa274dae470..60a2f266f8746 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -4,6 +4,7 @@ on: workflow_run: workflows: - "Windows Precommit Tests" + - "CI Tests" types: - completed From 0aa9e5c26455ebc3d373aad8819ff2a93fdc4a33 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 14:38:01 -0700 Subject: [PATCH 27/68] Fix job name for timeouts --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 480ef2dcb27d8..3d06d5d62d2bc 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -177,7 +177,7 @@ jobs: id: job-id uses: ./.github/workflows/get-job-id with: - job-name: ${{ inputs.job-name }} + job-name: "Build (${{ matrix.name }}, ${{ matrix.runs-on }}, ${{ matrix.enabled}})" - name: Handle Timeout shell: bash From 6771a8ee6273881e4ddccf05885d77e7f45ec935 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 14:51:23 -0700 Subject: [PATCH 28/68] Fix timeout job --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 3d06d5d62d2bc..fc8d77e7efbd3 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -219,7 +219,7 @@ jobs: timeouts = [] for (id of job_ids) { if (id) { - timeouts.append({job_id : id}) + timeouts.push({job_id : id}) } } From fb45efe54a13ce87926041e6e32428ed00f7c2db Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 15:19:28 -0700 Subject: [PATCH 29/68] XXX: Fix --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index fc8d77e7efbd3..62a67efb92de4 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -225,7 +225,7 @@ jobs: if (timeouts.length) { var fs = require('fs'); - fs.writeFile('timeout', JSON.stringify(timeouts)); + fs.writeFileSync('timeout', JSON.stringify(timeouts)); } - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 From 1eef1c7514878725bb1553a29241a8146b5736ff Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 15:33:13 -0700 Subject: [PATCH 30/68] Fix continue job --- .github/workflows/continue-timeout-job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 60a2f266f8746..f1ed332cd3d5a 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -46,7 +46,7 @@ jobs: console.log(data); const json = JSON.parse(data); console.log(json); - if (!json || !json.job_id) { + if (!json) { console.log("Could not parse timeout artifact"); return; } From 2e19de839679b853dae2ccf4097a9b204e858590 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 16:25:15 -0700 Subject: [PATCH 31/68] Fix timeout --- .github/workflows/continue-timeout-job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index f1ed332cd3d5a..b652f09b3bd48 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -67,5 +67,5 @@ jobs: repo: context.repo.repo, job_id: job.job_id }) - console.log("Restarted job: " + job_id); + console.log("Restarted job: " + job.job_id); } From 5e5cea3511e43d8315930c38a1e4def1df74ade0 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 17:11:31 -0700 Subject: [PATCH 32/68] Fix restart --- .github/workflows/continue-timeout-job.yml | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index b652f09b3bd48..747441e8280f3 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -58,14 +58,25 @@ jobs: artifact_id: ${{ steps.download-artifact.outputs.artifact-id }} }) - for (job of json) { - // Restart the job - // This function does not exist even though it is in the document - //github.rest.actions.reRunJobForWorkflow({ - await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + if (json.length > 1) { + // We aren't able to re-start multiple jobs individually, so our + // only option is to restart all failed jobs. + await github.rest.actions.reRunWorkflowFailedJobs({ owner: context.repo.owner, repo: context.repo.repo, - job_id: job.job_id + run_id: context.payload.workflow_run.id }) - console.log("Restarted job: " + job.job_id); + console.log("Restarted workflow: " + context.payload.workflow_run.id); + return; } + + job = json[0]; + // Restart the job + // This function does not exist even though it is in the document + //github.rest.actions.reRunJobForWorkflow({ + await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + owner: context.repo.owner, + repo: context.repo.repo, + job_id: job.job_id + }) + console.log("Restarted job: " + job.job_id); From e1595efa7763f18e2b22b229d610bb88a3ec18a0 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 17:11:41 -0700 Subject: [PATCH 33/68] Update matrix --- .github/workflows/ci-tests.yml | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 62a67efb92de4..1540d8a31e9ff 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -31,9 +31,7 @@ jobs: projects: ${{ steps.vars.outputs.projects }} check-targets: ${{ steps.vars.outputs.check-targets }} test-build: ${{ steps.vars.outputs.check-targets != '' }} - enable-windows: ${{ steps.vars.platforms.enable-windows }} - enable-linux: ${{ steps.vars.platforms.enable-linux }} - enable-macos: $${ steps.vars.platforms.enable-macos }} + test-platforms: ${{ steps.platforms.outputs.result }} steps: - name: Fetch LLVM sources uses: actions/checkout@v4 @@ -49,24 +47,30 @@ jobs: id: platforms with: script: | - console.log(context); - var enableLinux = false; - var enableWindows = false; - var enableMacOS = false + linuxConfig = { + name: "linux-x86_64", + runs-on: "ubuntu-22.04" + } + windowsConfig = { + name: "windows-x86_64", + runs-on: "windows-2022" + } + macConfig = { + name: "macos-x86_64", + runs-on: "macos-13" + } + + configs = [ + linuxConfig, + windowsConfig, + macConfig + ] const base_ref = process.env.GITHUB_BASE_REF; if (base_ref.startsWith('release/')) { // This is a pull request against a release branch. - enableLinux = true; - enableWindows = true; - enableMacOS = true; } - enableLinux = true; - enableWindows = true; - enableMacOS = true; - core.setOutput("enable-windows", enableWindows); - core.setOutput("enable-linux", enableLinux); - core.setOutput("enable-macos", enableMacOS); + return JSON.stringify(configs); ci-build-test: # If this job name is chagned, then we need to update the job-name @@ -79,17 +83,7 @@ jobs: runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false - matrix: - include: - - name: "linux-x86_64" - runs-on: ubuntu-22.04 - enabled: ${{ needs.compute-test-configs.enable-llvm == 'true' }} - - name: "windows-x86_64" - runs-on: windows-2022 - enabled: ${{ needs.compute-test-configs.enable-windows == 'true' }} - - name: "macos-x86_64" - runs-on: macos-13 - enabled: ${{ needs.compute-test-configs.enable-macos == 'true' }} + matrix: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} outputs: job-id-linux-x86_64: ${{ steps.timeout.outputs.job-id-linux-x86_64 }} job-id-windows-x86_64: ${{ steps.timeout.outputs.job-id-windows-x86_64 }} @@ -97,8 +91,7 @@ jobs: build-timeout: ${{ steps.build.outputs.timeout }} build-failed: ${{ steps.build.outputs.failed }} - if: >- - needs.compute-test-configs.outputs.test-build == 'true' + if: needs.compute-test-configs.outputs.test-build == 'true' steps: - name: Download Artifact uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 From c50c8f925fc11e7f086236874bc769d3382f307c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 17:21:48 -0700 Subject: [PATCH 34/68] Update matrix --- .github/workflows/ci-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 1540d8a31e9ff..e4234e841f9ea 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -49,15 +49,15 @@ jobs: script: | linuxConfig = { name: "linux-x86_64", - runs-on: "ubuntu-22.04" + runs_on: "ubuntu-22.04" } windowsConfig = { name: "windows-x86_64", - runs-on: "windows-2022" + runs_on: "windows-2022" } macConfig = { name: "macos-x86_64", - runs-on: "macos-13" + runs_on: "macos-13" } configs = [ @@ -80,7 +80,7 @@ jobs: - compute-test-configs permissions: actions: write #pr-sccache-save may delete artifacts. - runs-on: ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs_on }} strategy: fail-fast: false matrix: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} From dfb9e3b5f922ff49e6b42fc116c8bb81739460aa Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 17:26:53 -0700 Subject: [PATCH 35/68] Update matrix --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index e4234e841f9ea..046bbcde64364 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -70,7 +70,7 @@ jobs: // This is a pull request against a release branch. } - return JSON.stringify(configs); + return configs; ci-build-test: # If this job name is chagned, then we need to update the job-name From 448bfe74be048762027f09fab996c3af9694f6e5 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 17:31:18 -0700 Subject: [PATCH 36/68] Fix matrix --- .github/workflows/ci-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 046bbcde64364..89d6d2cea03eb 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -83,7 +83,8 @@ jobs: runs-on: ${{ matrix.runs_on }} strategy: fail-fast: false - matrix: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} + matrix: + include: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} outputs: job-id-linux-x86_64: ${{ steps.timeout.outputs.job-id-linux-x86_64 }} job-id-windows-x86_64: ${{ steps.timeout.outputs.job-id-windows-x86_64 }} From 8a17f3a77f324e2d3d225da06b779216a257289c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 7 May 2024 20:51:57 -0700 Subject: [PATCH 37/68] Fixed --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 89d6d2cea03eb..98bf2ce1cdeb3 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -171,7 +171,7 @@ jobs: id: job-id uses: ./.github/workflows/get-job-id with: - job-name: "Build (${{ matrix.name }}, ${{ matrix.runs-on }}, ${{ matrix.enabled}})" + job-name: "Build (${{ matrix.name }}, ${{ matrix.runs-on }})" - name: Handle Timeout shell: bash From 8ef7b6e6106703aee6ff2f5fb9d4b83c058c50ad Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 05:19:30 -0700 Subject: [PATCH 38/68] Fix job_id --- .github/workflows/ci-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 98bf2ce1cdeb3..59435f8414d70 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -171,7 +171,7 @@ jobs: id: job-id uses: ./.github/workflows/get-job-id with: - job-name: "Build (${{ matrix.name }}, ${{ matrix.runs-on }})" + job-name: "Build (${{ matrix.name }}, ${{ matrix.runs_on }})" - name: Handle Timeout shell: bash From 36b082abcdacff0be909318ef5011fdafd47de74 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 05:30:26 -0700 Subject: [PATCH 39/68] Fix sccache upload --- .github/workflows/pr-sccache-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index c865a9895b984..763c70def6c52 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -34,7 +34,7 @@ runs: - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: - name: 'sccache-pr${{ github.event.number }}' + name: 'sccache-pr${{ github.event.number }}-${{ inputs.artifact-name-suffix }}' path: .sccache retention-days: 7 From c1e2cf664fb1f9da4f595008b511882f0d67b24a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 08:52:13 -0700 Subject: [PATCH 40/68] Simplify-timeout --- .github/workflows/ci-tests.yml | 107 +++---------------- .github/workflows/timeout-restore/action.yml | 33 ++++++ .github/workflows/timeout-save/action.yml | 87 +++++++++++++++ 3 files changed, 136 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/timeout-restore/action.yml create mode 100644 .github/workflows/timeout-save/action.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 59435f8414d70..2c65bd74c9e6c 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -85,32 +85,13 @@ jobs: fail-fast: false matrix: include: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} - outputs: - job-id-linux-x86_64: ${{ steps.timeout.outputs.job-id-linux-x86_64 }} - job-id-windows-x86_64: ${{ steps.timeout.outputs.job-id-windows-x86_64 }} - job-id-macos-x86_64: ${{ steps.timeout.outputs.job-id-macos-x86_64 }} - - build-timeout: ${{ steps.build.outputs.timeout }} - build-failed: ${{ steps.build.outputs.failed }} if: needs.compute-test-configs.outputs.test-build == 'true' steps: - - name: Download Artifact - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + - name: Timeout Restore + id: timeout + uses: ./.github/workflows/timeout-restore with: - pattern: timeout-build-${{ matrix.name }} - merge-multiple: true - - - name: Unpack Artifact - id: timeout-artifact - shell: bash - run: | - if [ -e llvm-project.tar.zst ]; then - tar --zstd -xf llvm-project.tar.zst - rm llvm-project.tar.zst - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi + artifact-name-suffix: ${{ matrix.name }} - name: Setup Windows uses: llvm/actions/setup-windows@main @@ -122,7 +103,7 @@ jobs: uses: llvm/actions/install-ninja@main - name: Fetch LLVM sources - if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} + if: ${{ steps.timeout.outputs.exists != 'true' }} uses: actions/checkout@v4 - name: Setup sccache @@ -138,7 +119,7 @@ jobs: artifact-name-suffix: ${{ matrix.name }} - name: Configure - if: ${{ steps.timeout-artifact.outputs.exists != 'true' }} + if: ${{ steps.timeout.outputs.exists != 'true' }} shell: bash run: | cmake -B build -GNinja \ @@ -152,77 +133,21 @@ jobs: - name: Build shell: bash - id: build timeout-minutes: 1 run: | - echo "timeout=true" >> $GITHUB_OUTPUT - ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} && pass=1 - echo "timeout=false" >> $GITHUB_OUTPUT - [ $pass ] || false + ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} - - name: Save sccache for next PR run + - name: Timeout Save if: always() - uses: ./.github/workflows/pr-sccache-save - with: - artifact-name-suffix: ${{ matrix.name }} - - - name: Get Job ID - if: always() && steps.build.outputs.timeout == 'true' - id: job-id - uses: ./.github/workflows/get-job-id + uses: ./.github/workflows/timeout-save with: job-name: "Build (${{ matrix.name }}, ${{ matrix.runs_on }})" + artifact-name-suffix: ${{ matrix.name }} + timeout-step: "Build" + timeout-minutes: 1 - - name: Handle Timeout - shell: bash - if: always() && steps.build.outputs.timeout == 'true' - id: timeout - run: | - # Dereference symlinks so that this works on Windows. - tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst - mv ../llvm-project.tar.zst . - # Save the job-id so we can restart the job - echo "job-id-${{ matrix.name }}=${{ steps.job-id.outputs.job-id }}" >> $GITHUB_OUTPUT - - - name: Upload Build - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 - if: always() && steps.build.outputs.timeout == 'true' - with: - name: timeout-build-${{ matrix.name }} - path: llvm-project.tar.zst - retention-days: 2 - - handle-timeout: - # If this job name is chagned, then we need to update the job-name - # paramater for the write-timeout-file step below. - name: "Handle Timeout" - if: always() - needs: - - ci-build-test - runs-on: ubuntu-22.04 - steps: - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 - with: - script: | - const job_ids = [ - "${{ needs.ci-build-test.outputs.job-id-linux-x86_64 }}", - "${{ needs.ci-build-test.outputs.job-id-windows-x86_64 }}", - "${{ needs.ci-build-test.outputs.job-id-macos-x86_64 }}" - ]; - - timeouts = [] - for (id of job_ids) { - if (id) { - timeouts.push({job_id : id}) - } - } - - if (timeouts.length) { - var fs = require('fs'); - fs.writeFileSync('timeout', JSON.stringify(timeouts)); - } - - - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + - name: Save sccache for next PR run + if: always() + uses: ./.github/workflows/pr-sccache-save with: - name: timeout - path: timeout + artifact-name-suffix: ${{ matrix.name }} diff --git a/.github/workflows/timeout-restore/action.yml b/.github/workflows/timeout-restore/action.yml new file mode 100644 index 0000000000000..417782ccc5ca1 --- /dev/null +++ b/.github/workflows/timeout-restore/action.yml @@ -0,0 +1,33 @@ +name: Timeout Restore +description: Save build state from a timed out job. +inputs: + artifact-name-suffix: + desciption: Suffix to add to the name of the artifact containing the build state. + required: true + +outputs: + exists: + description: "This is true if a previous timeout build was restored, false otherwise." + value: ${{ steps.timeout-artifact.exists }} + +runs: + using: "composite" + steps: + - name: Download Artifact + uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + with: + pattern: timeout-build-${{ inputs.artifact-name-suffix }} + merge-multiple: true + + - name: Unpack Artifact + id: timeout-artifact + shell: bash + run: | + if [ -e llvm-project.tar.zst ]; then + tar --zstd -xf llvm-project.tar.zst + rm llvm-project.tar.zst + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml new file mode 100644 index 0000000000000..90254f6d79759 --- /dev/null +++ b/.github/workflows/timeout-save/action.yml @@ -0,0 +1,87 @@ +name: Timeout Save +description: Save build state when a timeout occurs so that it can be reused when the job is restarted. +inputs: + job-name: + description: The name of the job. This is used to look up the job id. + required: true + artifact-name-suffix: + desciption: Suffix to add to the name of the artifact containing the build state. + required: true + timeout-step: + description: The step that we want to restart if there is a timeout. + required: true + timeout-minutes: + description: The value of timeout-minutes for this step. + required: true + +outputs: + job-id: + description: "The job id for the job that timed out. If the job did not timeout, then this is the empty string." + value: ${{ steps.job-id.outputs.job-id }} + +runs: + using: "composite" + steps: + - name: Check for timeout + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 + id: timeout + with: + script: | + const job_data = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }); + + for (job of job_data.data.jobs) { + console.log(job) + if (job.name != "${{ inputs.job-name }}") { + continue; + } + + for (step of job.steps) { + console.log(step); + if (step.name != "${{ inputs.timeout-step }}") { + continue; + } + if (step.conclusion != "failure") { + return false; + } + + // This run failed, check for timeout. + const diff = step.completed_at - step.started_at; + console.log(diff); + if (diff > timeout-minutes) + return true; + } + } + return false; + + - name: Write Timeout File + if: steps.timeout.outputs.result == 'true' + uses: ./.github/workflows/write-timeout-file + with: + job-name: ${{ inputs.job-name }} + + - name: Handle Timeout + shell: bash + if: steps.timeout.outputs.result == 'true' + id: timeout + run: | + # Dereference symlinks so that this works on Windows. + tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst + mv ../llvm-project.tar.zst . + + - name: Upload Build + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + if: steps.timeout.outputs.result == 'true' + with: + name: timeout-build-${{ inputs.artifact-name-suffix }} + path: llvm-project.tar.zst + retention-days: 2 + + - name: Upload Timeout File + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: timeout-${{ inputs.artifact-name-suffix }} + path: timeout From c39e7862dca2b6c7b9361052e10de656cc3ac215 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:10:46 -0700 Subject: [PATCH 41/68] Update continue-timeout job --- .github/workflows/continue-timeout-job.yml | 69 +++++++++++++--------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 747441e8280f3..2a12bcec8fabf 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -41,42 +41,53 @@ jobs: uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - var fs = require('fs'); - const data = fs.readFileSync('./timeout'); - console.log(data); - const json = JSON.parse(data); - console.log(json); - if (!json) { - console.log("Could not parse timeout artifact"); - return; - } + const response = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id + }) + + job_ids = []; + for (artifact of response.data.artifacts) { + + const match = artifact.name.match(/timeout-([0-9]+)/); + console.log(match); + if (!match) { + continue; + } + job_ids.push(match[1]); + // Delete the timeout artifact to prepare for the next run await github.rest.actions.deleteArtifact({ owner: context.repo.owner, repo: context.repo.repo, - artifact_id: ${{ steps.download-artifact.outputs.artifact-id }} - }) + artifact_id: artifact.id + }); + } - if (json.length > 1) { - // We aren't able to re-start multiple jobs individually, so our - // only option is to restart all failed jobs. - await github.rest.actions.reRunWorkflowFailedJobs({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id - }) - console.log("Restarted workflow: " + context.payload.workflow_run.id); - return; - } + if (job_ids.length == 0) { + return; + } - job = json[0]; - // Restart the job - // This function does not exist even though it is in the document - //github.rest.actions.reRunJobForWorkflow({ - await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + if (job_ids.length > 1) { + // We aren't able to re-start multiple jobs individually, so our + // only option is to restart all failed jobs. + await github.rest.actions.reRunWorkflowFailedJobs({ owner: context.repo.owner, repo: context.repo.repo, - job_id: job.job_id + run_id: context.payload.workflow_run.id }) - console.log("Restarted job: " + job.job_id); + console.log("Restarted workflow: " + context.payload.workflow_run.id); + return; + } + + job_id = job_ids[0]; + // This function does not exist even though it is in the document + //github.rest.actions.reRunJobForWorkflow({ + await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', { + owner: context.repo.owner, + repo: context.repo.repo, + job_id: job_id + }) + console.log("Restarted job: " + job_id); From e4310b5e7c1f6714ab74d8d2c7ca92361be58198 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:10:55 -0700 Subject: [PATCH 42/68] Updates --- .github/workflows/timeout-save/action.yml | 4 +++- .../workflows/unprivileged-download-artifact/action.yml | 3 ++- .github/workflows/write-timeout-file/action.yml | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 90254f6d79759..4aad6e1389b3a 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -62,6 +62,7 @@ runs: uses: ./.github/workflows/write-timeout-file with: job-name: ${{ inputs.job-name }} + filename: timeout-${{ inputs.artifact-name-suffix }} - name: Handle Timeout shell: bash @@ -81,7 +82,8 @@ runs: retention-days: 2 - name: Upload Timeout File + if: steps.timeout.outputs.result == 'true' uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: name: timeout-${{ inputs.artifact-name-suffix }} - path: timeout + path: timeout-${{ inputs.artifact-name-suffix }} diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index 5e63f5ce8e3fe..8f8593ce383cb 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -6,7 +6,8 @@ inputs: required: true artifact-name: desciption: The name of the artifact to download. - required: true + required: false + outputs: filename: diff --git a/.github/workflows/write-timeout-file/action.yml b/.github/workflows/write-timeout-file/action.yml index a483185ab623f..3daab39456dec 100644 --- a/.github/workflows/write-timeout-file/action.yml +++ b/.github/workflows/write-timeout-file/action.yml @@ -1,8 +1,11 @@ name: Write Timeout File inputs: job-name: - required: false + required: true type: 'string' + filename: + required: false + default: timeout runs: using: "composite" @@ -14,4 +17,4 @@ runs: - shell: bash run: | - echo '{"job_id": "${{ steps.job-id.outputs.job-id }}"}' > timeout + echo '{"job_id": "${{ steps.job-id.outputs.job-id }}"}' > ${{ inputs.filename }} From 17d2f41c18ba6d9d5caf461b82a5046aff097f7d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:15:53 -0700 Subject: [PATCH 43/68] Updates --- .github/workflows/timeout-save/action.yml | 28 +++++++++---------- .../workflows/write-timeout-file/action.yml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 4aad6e1389b3a..820c219806c83 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -14,11 +14,6 @@ inputs: description: The value of timeout-minutes for this step. required: true -outputs: - job-id: - description: "The job id for the job that timed out. If the job did not timeout, then this is the empty string." - value: ${{ steps.job-id.outputs.job-id }} - runs: using: "composite" steps: @@ -57,14 +52,8 @@ runs: } return false; - - name: Write Timeout File - if: steps.timeout.outputs.result == 'true' - uses: ./.github/workflows/write-timeout-file - with: - job-name: ${{ inputs.job-name }} - filename: timeout-${{ inputs.artifact-name-suffix }} - - name: Handle Timeout + - name: Save Working Directory shell: bash if: steps.timeout.outputs.result == 'true' id: timeout @@ -73,7 +62,7 @@ runs: tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst mv ../llvm-project.tar.zst . - - name: Upload Build + - name: Upload Working Directory uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 if: steps.timeout.outputs.result == 'true' with: @@ -81,9 +70,20 @@ runs: path: llvm-project.tar.zst retention-days: 2 + - name: Get Job ID + id: job-id + if: steps.timeout.outputs.result == 'true' + uses: ./.github/workflows/get-job-id + with: + job-name: ${{ inputs.job-name }} + + - name: Create Timeout File + shell: bash + run: touch timeout-${{ steps.job-id.outputs.job-id }} + - name: Upload Timeout File if: steps.timeout.outputs.result == 'true' uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: name: timeout-${{ inputs.artifact-name-suffix }} - path: timeout-${{ inputs.artifact-name-suffix }} + path: timeout-${{ steps.job-id.outputs.job-id }} diff --git a/.github/workflows/write-timeout-file/action.yml b/.github/workflows/write-timeout-file/action.yml index 3daab39456dec..592259c70432d 100644 --- a/.github/workflows/write-timeout-file/action.yml +++ b/.github/workflows/write-timeout-file/action.yml @@ -17,4 +17,4 @@ runs: - shell: bash run: | - echo '{"job_id": "${{ steps.job-id.outputs.job-id }}"}' > ${{ inputs.filename }} + echo '{"job_id": "${{ steps.job-id.outputs.job-id }}"}' > timeout-${{ steps.job-id From 5eb256d1f19519e079da6a0daaf7be71b12815c1 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:30:20 -0700 Subject: [PATCH 44/68] Add missing files --- .github/workflows/ci-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 2c65bd74c9e6c..5b57af71e3467 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -73,8 +73,8 @@ jobs: return configs; ci-build-test: - # If this job name is chagned, then we need to update the job-name - # paramater for the write-timeout-file step below. + # If this job name is changed, then we need to update the job-name + # paramater for the timeout-save step below. name: "Build" needs: - compute-test-configs From 372d11f6989c1889e2bd0403da1dd8704fc7aa83 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:33:09 -0700 Subject: [PATCH 45/68] XX: Fix --- .github/workflows/ci-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 5b57af71e3467..1dedec7ad25dc 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -87,6 +87,9 @@ jobs: include: ${{ fromJson(needs.compute-test-configs.outputs.test-platforms) }} if: needs.compute-test-configs.outputs.test-build == 'true' steps: + - name: Fetch LLVM sources + uses: actions/checkout@v4 + - name: Timeout Restore id: timeout uses: ./.github/workflows/timeout-restore @@ -102,10 +105,6 @@ jobs: - name: Install Ninja uses: llvm/actions/install-ninja@main - - name: Fetch LLVM sources - if: ${{ steps.timeout.outputs.exists != 'true' }} - uses: actions/checkout@v4 - - name: Setup sccache uses: hendrikmuhs/ccache-action@v1 with: From 074961a7403206fdbad8308c7ba68cfa973c4d63 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:38:59 -0700 Subject: [PATCH 46/68] Fix timeout id --- .github/workflows/timeout-save/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 820c219806c83..46a41728a6527 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -56,7 +56,6 @@ runs: - name: Save Working Directory shell: bash if: steps.timeout.outputs.result == 'true' - id: timeout run: | # Dereference symlinks so that this works on Windows. tar -h -c . | zstd -T0 -c > ../llvm-project.tar.zst From c982084ff1b0835fb02a2bae723cd032bfeb931a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:48:44 -0700 Subject: [PATCH 47/68] Fixes/debug --- .github/workflows/timeout-save/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 46a41728a6527..356f3a746fd12 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -44,9 +44,11 @@ runs: } // This run failed, check for timeout. + console.log(step.completed_at) + console.log(step.started_at) const diff = step.completed_at - step.started_at; console.log(diff); - if (diff > timeout-minutes) + if (diff > ${{ inputs.timeout-minutes }}) return true; } } From b95e9668b42e75c2379c1933da18629b60334fd2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 09:55:17 -0700 Subject: [PATCH 48/68] Fix date compare --- .github/workflows/timeout-save/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 356f3a746fd12..38be8a8106c33 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -46,7 +46,11 @@ runs: // This run failed, check for timeout. console.log(step.completed_at) console.log(step.started_at) - const diff = step.completed_at - step.started_at; + completed_at = Date.parse(step.completed_at); + started_at = Date.parse(step.started_at); + console.log(completed_at) + console.log(started_at) + const diff = completed_at - started_at; console.log(diff); if (diff > ${{ inputs.timeout-minutes }}) return true; From d879fb4b7288dc7f925903212ce70b25b9705231 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 10:18:04 -0700 Subject: [PATCH 49/68] Fix timeout detection --- .github/workflows/timeout-save/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 38be8a8106c33..494b4c97a2641 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -50,9 +50,9 @@ runs: started_at = Date.parse(step.started_at); console.log(completed_at) console.log(started_at) - const diff = completed_at - started_at; + const diff = (completed_at - started_at) / 1000; console.log(diff); - if (diff > ${{ inputs.timeout-minutes }}) + if (diff > 60 * ${{ inputs.timeout-minutes }}) return true; } } From 11885d22ea1254cad40b8d7baf426a1a9223eb7a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 10:29:17 -0700 Subject: [PATCH 50/68] Fix artifact name --- .github/workflows/timeout-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index 494b4c97a2641..c01a9d81b7369 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -90,5 +90,5 @@ runs: if: steps.timeout.outputs.result == 'true' uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: - name: timeout-${{ inputs.artifact-name-suffix }} + name: timeout-${{ steps.job-id.outupts.job-id }} path: timeout-${{ steps.job-id.outputs.job-id }} From 600bf47546b88a540fb651af07d05ddb09d90961 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 11:18:13 -0700 Subject: [PATCH 51/68] Fix typo --- .github/workflows/timeout-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/timeout-save/action.yml b/.github/workflows/timeout-save/action.yml index c01a9d81b7369..77265f972b609 100644 --- a/.github/workflows/timeout-save/action.yml +++ b/.github/workflows/timeout-save/action.yml @@ -90,5 +90,5 @@ runs: if: steps.timeout.outputs.result == 'true' uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: - name: timeout-${{ steps.job-id.outupts.job-id }} + name: timeout-${{ steps.job-id.outputs.job-id }} path: timeout-${{ steps.job-id.outputs.job-id }} From 7052a03d457ae99b733d618ad1b436231c6773bf Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 11:37:28 -0700 Subject: [PATCH 52/68] Fix continue --- .github/workflows/continue-timeout-job.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 2a12bcec8fabf..073e5de0c9c0f 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -19,25 +19,7 @@ jobs: runs-on: ubuntu-22.04 if: github.event.workflow_run.conclusion == 'failure' steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/workflows/unprivileged-download-artifact - sparse-checkout-cone-mode: false - - - uses: ./.github/workflows/unprivileged-download-artifact - id: download-artifact - with: - run-id: ${{ github.event.workflow_run.id }} - artifact-name: timeout - - - shell: bash - if: steps.download-artifact.outputs.filename != '' - run: | - unzip ${{ steps.download-artifact.outputs.filename }} - - name: "Restart Job" - if: steps.download-artifact.outputs.filename != '' uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | From 9e349ca335339dd901ebe1ed741740cd9f1a98fe Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 11:55:21 -0700 Subject: [PATCH 53/68] XXX: test fail --- .github/workflows/ci-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 1dedec7ad25dc..7a471a5f5c3df 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -134,6 +134,7 @@ jobs: shell: bash timeout-minutes: 1 run: | + false ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} - name: Timeout Save From 398beb85370df82d2ccd892d92a6d7074390e7b0 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 12:26:34 -0700 Subject: [PATCH 54/68] continue tmeout debug --- .github/workflows/continue-timeout-job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continue-timeout-job.yml b/.github/workflows/continue-timeout-job.yml index 073e5de0c9c0f..eb31acec6d0df 100644 --- a/.github/workflows/continue-timeout-job.yml +++ b/.github/workflows/continue-timeout-job.yml @@ -32,7 +32,7 @@ jobs: job_ids = []; for (artifact of response.data.artifacts) { - + console.log(artifact); const match = artifact.name.match(/timeout-([0-9]+)/); console.log(match); if (!match) { From 7a24e50e691b37acbce08ba821640ed792983321 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 12:36:33 -0700 Subject: [PATCH 55/68] Revert "XXX: test fail" This reverts commit 9e349ca335339dd901ebe1ed741740cd9f1a98fe. --- .github/workflows/ci-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 7a471a5f5c3df..1dedec7ad25dc 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -134,7 +134,6 @@ jobs: shell: bash timeout-minutes: 1 run: | - false ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} - name: Timeout Save From 3934d795f9a4bda775352f4d839fdb062de6dd6d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 13:02:08 -0700 Subject: [PATCH 56/68] timeout minutes --- .github/workflows/ci-tests.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 1dedec7ad25dc..cc376cb2ed230 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -59,11 +59,16 @@ jobs: name: "macos-x86_64", runs_on: "macos-13" } + macArmConfig = { + name: "macos-aarch64", + runs_on: "macos-14" + } configs = [ linuxConfig, windowsConfig, - macConfig + macConfig, + macArmConfig ] const base_ref = process.env.GITHUB_BASE_REF; if (base_ref.startsWith('release/')) { @@ -132,7 +137,7 @@ jobs: - name: Build shell: bash - timeout-minutes: 1 + timeout-minutes: 330 run: | ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} @@ -143,7 +148,7 @@ jobs: job-name: "Build (${{ matrix.name }}, ${{ matrix.runs_on }})" artifact-name-suffix: ${{ matrix.name }} timeout-step: "Build" - timeout-minutes: 1 + timeout-minutes: 330 - name: Save sccache for next PR run if: always() From ba9641fdc3b99bbb57b813ced6653085812827d8 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 16:22:45 -0700 Subject: [PATCH 57/68] Fix pr-sccache for mac --- .github/workflows/pr-sccache-restore/action.yml | 4 ++++ .github/workflows/pr-sccache-save/action.yml | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index 99817b03347b5..26f3f4965b65c 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -21,3 +21,7 @@ runs: rm -Rf .sccache/ unzip ${{ steps.download-artifact.outputs.filename }} rm ${{ steps.download-artifact.outputs.filename }} + tar --zstd -xf sccache.tar.zst + rm sccache.tar.zst + ls -ltr + diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index 763c70def6c52..e3a82fb42fa45 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -31,11 +31,16 @@ runs: artifact_id: artifact_id }) + - name: Package sccache Directory + shell: bash + run: | + # Dereference symlinks so that this works on Windows. + tar -h -c .sccache | zstd -T0 -c > sccache.tar.zst - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 with: name: 'sccache-pr${{ github.event.number }}-${{ inputs.artifact-name-suffix }}' - path: .sccache + path: sccache.tar.zst retention-days: 7 - shell: bash From 784fc3f1a8e1286003bbbc8d8cbbd943828fb189 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 16:23:58 -0700 Subject: [PATCH 58/68] timeout 1 --- .github/workflows/ci-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index cc376cb2ed230..41d00636a74f8 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -137,7 +137,7 @@ jobs: - name: Build shell: bash - timeout-minutes: 330 + timeout-minutes: 1 run: | ninja -C build -k 0 ${{ needs.compute-test-configs.outputs.check-targets }} @@ -148,7 +148,7 @@ jobs: job-name: "Build (${{ matrix.name }}, ${{ matrix.runs_on }})" artifact-name-suffix: ${{ matrix.name }} timeout-step: "Build" - timeout-minutes: 330 + timeout-minutes: 1 - name: Save sccache for next PR run if: always() From 024db66a996cb66341f7e1214a258eee2ec25cec Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 16:37:22 -0700 Subject: [PATCH 59/68] XXX: fix --- .github/workflows/pr-sccache-save/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index e3a82fb42fa45..ee46e1df9605e 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -45,5 +45,6 @@ runs: - shell: bash run: | + rm sccache.tar.zst sccache --show-stats From 84d7617b4cc315e451a4bc6542a5e10865967891 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 16:45:27 -0700 Subject: [PATCH 60/68] Fix pr-sccache-save --- .github/workflows/pr-sccache-save/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index ee46e1df9605e..a61f74f255acd 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -10,10 +10,9 @@ runs: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - const data = await github.rest.actions.listWorkflowRunArtifacts({ + const data = await github.rest.actions.listArtifactsForRepository({ owner: context.repo.owner, repo: context.repo.repo, - run_id: context.runId, name: 'sccache-pr' + context.issue.number + "-${{ inputs.artifact-name-suffix }}" }) From f3a441454b532236d68fe5ff5166a112eea51169 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 16:54:06 -0700 Subject: [PATCH 61/68] Fix pr-sccache-save --- .github/workflows/pr-sccache-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index a61f74f255acd..2e438d57f14f2 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -10,7 +10,7 @@ runs: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - const data = await github.rest.actions.listArtifactsForRepository({ + const data = await github.rest.actions.listArtifactsForRepo({ owner: context.repo.owner, repo: context.repo.repo, name: 'sccache-pr' + context.issue.number + "-${{ inputs.artifact-name-suffix }}" From 3779e3723df986c45073aebbbe77bcb4e7f73d2a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 17:05:37 -0700 Subject: [PATCH 62/68] Fix sccache download --- .../workflows/pr-sccache-restore/action.yml | 1 - .github/workflows/pr-sccache-save/action.yml | 3 ++- .../unprivileged-download-artifact/action.yml | 27 ++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml index 26f3f4965b65c..6ce3822aeb6a6 100644 --- a/.github/workflows/pr-sccache-restore/action.yml +++ b/.github/workflows/pr-sccache-restore/action.yml @@ -11,7 +11,6 @@ runs: - uses: ./.github/workflows/unprivileged-download-artifact id: download-artifact with: - run-id: ${{ github.run_id }} artifact-name: sccache-pr${{ github.event.pull_request.number }}-${{ inputs.artifact-name-suffix }} - shell: bash diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index 2e438d57f14f2..0cc8f97acaa2f 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -10,9 +10,10 @@ runs: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - const data = await github.rest.actions.listArtifactsForRepo({ + const data = await github.rest.actions.listArtifactsForRepository({ owner: context.repo.owner, repo: context.repo.repo, + run_id: context.runId, name: 'sccache-pr' + context.issue.number + "-${{ inputs.artifact-name-suffix }}" }) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index 8f8593ce383cb..5dce4917c6434 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -2,11 +2,11 @@ name: Unprivileged Download Artifact description: Download artifacts from another workflow run without using an access token. inputs: run-id: - description: The run-id for the workflow run that you want to download the artifact from. - required: true + description: The run-id for the workflow run that you want to download the artifact from. If ommited it will download the most recently created artifact from the repo with the artifact-name. + required: false artifact-name: desciption: The name of the artifact to download. - required: false + required: true outputs: @@ -25,12 +25,21 @@ runs: id: artifact-url with: script: | - const response = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, - name: "${{ inputs.artifact-name }}" - }) + var response; + if (!"${{ inputs.run-id}) { + response = await github.rest.actions.listArtifactsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + name: "${{ inputs.artifact-name }}" + }) + else { + const response = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ inputs.run-id }}, + name: "${{ inputs.artifact-name }}" + }) + } console.log(response) From f67668a354642eac2aececb9b74454a6c58db8b2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 17:11:18 -0700 Subject: [PATCH 63/68] Fix typo --- .github/workflows/unprivileged-download-artifact/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index 5dce4917c6434..42f270675fd1b 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -26,7 +26,7 @@ runs: with: script: | var response; - if (!"${{ inputs.run-id}) { + if (!"${{ inputs.run-id }}) { response = await github.rest.actions.listArtifactsForRepo({ owner: context.repo.owner, repo: context.repo.repo, From 79bc91112037d303db3ce8907d26fd954c07627b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 17:14:24 -0700 Subject: [PATCH 64/68] Fix typo --- .github/workflows/pr-sccache-save/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml index 0cc8f97acaa2f..ee46e1df9605e 100644 --- a/.github/workflows/pr-sccache-save/action.yml +++ b/.github/workflows/pr-sccache-save/action.yml @@ -10,7 +10,7 @@ runs: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 with: script: | - const data = await github.rest.actions.listArtifactsForRepository({ + const data = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, run_id: context.runId, From a3bbaccc8830e33abc0c825c468b84790f063942 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 17:18:15 -0700 Subject: [PATCH 65/68] Fix typo --- .github/workflows/unprivileged-download-artifact/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index 42f270675fd1b..af6cc3e275f63 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -26,7 +26,7 @@ runs: with: script: | var response; - if (!"${{ inputs.run-id }}) { + if (!"${{ inputs.run-id }}") { response = await github.rest.actions.listArtifactsForRepo({ owner: context.repo.owner, repo: context.repo.repo, From c1bb3e260f1f18a26026aa0463decde0b277afd0 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 17:21:42 -0700 Subject: [PATCH 66/68] Fix typo --- .github/workflows/unprivileged-download-artifact/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index af6cc3e275f63..a2f0446ca0f9a 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -32,7 +32,7 @@ runs: repo: context.repo.repo, name: "${{ inputs.artifact-name }}" }) - else { + } else { const response = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, From b452883d8856ef278837334796dd245c424a6f1e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 18:56:37 -0700 Subject: [PATCH 67/68] Fix typo --- .github/workflows/unprivileged-download-artifact/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index a2f0446ca0f9a..e51f733b903f9 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -32,7 +32,7 @@ runs: repo: context.repo.repo, name: "${{ inputs.artifact-name }}" }) - } else { + } else { const response = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, From b0883ecaf1459dc9ad0b5df0c4592f4a0cb5c3ba Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 8 May 2024 19:03:02 -0700 Subject: [PATCH 68/68] Fix typo --- .github/workflows/unprivileged-download-artifact/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml index e51f733b903f9..8c88736ce6875 100644 --- a/.github/workflows/unprivileged-download-artifact/action.yml +++ b/.github/workflows/unprivileged-download-artifact/action.yml @@ -36,7 +36,7 @@ runs: const response = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, + run_id: "${{ inputs.run-id }}", name: "${{ inputs.artifact-name }}" }) }