Skip to content

Commit

Permalink
Download latest successful bpf_performance build (#2774)
Browse files Browse the repository at this point in the history
* Download latest successful bpf_performance build

Signed-off-by: Alan Jowett <[email protected]>

* Fix path

Signed-off-by: Alan Jowett <[email protected]>

* Set GH_TOKEN environment variable

Signed-off-by: Alan Jowett <[email protected]>

* Download performance to it's own repo

Signed-off-by: Alan Jowett <[email protected]>

* PR feedback

Signed-off-by: Alan Jowett <[email protected]>

* Fix deploy script

Signed-off-by: Alan Jowett <[email protected]>

---------

Signed-off-by: Alan Jowett <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett and Alan Jowett authored Aug 29, 2023
1 parent 0c93615 commit d5f4bd9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ jobs:
working-directory: ${{env.GITHUB_WORKSPACE}}
run: Invoke-WebRequest https://github.com/microsoft/ebpf-for-windows-demo/releases/download/v0.0.1/${{env.BUILD_PLATFORM}}-Release-cilium-xdp.zip -OutFile x64-${{env.BUILD_CONFIGURATION}}-cilium-xdp.zip

- name: Download bpf_performance repository artifacts
if: steps.skip_check.outputs.should_skip != 'true' && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease')
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
GH_TOKEN: ${{ github.token }}
run: |
scripts\Fetch-LatestArtifacts.ps1 -ArtifactName "build-RelWithDebInfo-windows-2022" -OutputPath "${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\performance" -Owner alan-jowett -repo bpf_performance
- name: Extract artifacts to build path
if: steps.skip_check.outputs.should_skip != 'true' && matrix.configurations != 'FuzzerDebug'
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand Down
27 changes: 27 additions & 0 deletions scripts/Fetch-LatestArtifacts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: MIT

# Script to pull artifact from latest scheduled run from a GitHub Actions workflow.

param(
[Parameter(Mandatory=$true)] [string] $ArtifactName,
[Parameter(Mandatory=$true)] [string] $OutputPath,
[Parameter(Mandatory=$true)] [string] $Owner,
[Parameter(Mandatory=$true)] [string] $Repo,
[Parameter(Mandatory=$false)] [string] $WorkflowName = "CI/CD",
[Parameter(Mandatory=$false)] [string] $Branch = "main",
[Parameter(Mandatory=$false)] [string] $RunId = $null)

if ($null -eq (Get-Command 'gh.exe' -ErrorAction SilentlyContinue)) {
throw "Unable to locate gh.exe. This command requires GitHub CLI installed and in your path."
}

if (!$runid) {
# Get the latest run ID for the branch and workflow
$run = ((Invoke-WebRequest -Uri "https://api.github.com/repos/$Owner/$Repo/actions/runs?per_page=1&exclude_pull_requests=true&branch=$Branch&status=completed&event=schedule&conclusion=success&name=$WorkflowName").Content | ConvertFrom-Json)
$runid = $run.workflow_runs[0].id
}

Write-Output "Using run ID $runid in branch $Branch in repo $Owner/$Repo to fetch artifact $ArtifactName to $OutputPath."

gh run download $runid -R "$Owner/$Repo" -n $ArtifactName -D $OutputPath

0 comments on commit d5f4bd9

Please sign in to comment.