Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PH] Create workflow for manually dispatching performance harness runs #1378

Merged
merged 64 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f7f246a
Initial attempt of configurable ph run in cicd.
oschwaldp-oci Jul 7, 2023
78564fa
Fix yaml file syntax. Minor cleanup.
oschwaldp-oci Jul 7, 2023
7518f78
Fix yaml file syntax.
oschwaldp-oci Jul 7, 2023
1f2ca01
Fix yaml file syntax 'uses' already defined.
oschwaldp-oci Jul 7, 2023
975426a
Add dependency needs.
oschwaldp-oci Jul 7, 2023
947770e
Pre-calculate the report location for use in upload step.
oschwaldp-oci Jul 7, 2023
8f01104
Use normal upload-artifact action.
oschwaldp-oci Jul 7, 2023
e3ae3a3
Try finding and uploading report via wildcard.
oschwaldp-oci Jul 7, 2023
dc92ab5
Merge branch 'main' into ph-manual-workflow
oschwaldp-oci Jul 10, 2023
6b4f745
Some cleanup.
oschwaldp-oci Jul 10, 2023
8919364
Merge branch 'main' into ph-manual-workflow
oschwaldp-oci Jul 17, 2023
feffc03
Try to automatically parse platform matrix in script.
oschwaldp-oci Jul 18, 2023
be9452b
Attempt to use the json object directly.
oschwaldp-oci Jul 18, 2023
754638d
Attempt to fix github variable reference in script.
oschwaldp-oci Jul 18, 2023
cb73a84
Attempt to use constructed platform matrix in build job.
oschwaldp-oci Jul 18, 2023
b0075c0
Put matrix-out into github output for use later.
oschwaldp-oci Jul 18, 2023
a414b8c
Try quotes.
oschwaldp-oci Jul 18, 2023
3f13595
Try using fromJSON parsing.
oschwaldp-oci Jul 18, 2023
a83266b
Debugging output.
oschwaldp-oci Jul 18, 2023
158ad55
Don't needs backslashes to break lines up.
oschwaldp-oci Jul 18, 2023
ba738b8
Add input to override build platform matrix.
oschwaldp-oci Jul 18, 2023
282cfe0
Use fromJSON.
oschwaldp-oci Jul 18, 2023
1de5698
Try again.
oschwaldp-oci Jul 18, 2023
c7695c0
Try again.
oschwaldp-oci Jul 18, 2023
0385511
Remove extra training quote.
oschwaldp-oci Jul 18, 2023
f3097a2
Try fromJSON in output.
oschwaldp-oci Jul 18, 2023
4e2ebb0
Working to get array
oschwaldp-oci Jul 18, 2023
f027744
echo out GITHUB_OUTPUT
oschwaldp-oci Jul 18, 2023
2d7e8c4
Try this again.
oschwaldp-oci Jul 18, 2023
96b3d71
Try this again.
oschwaldp-oci Jul 18, 2023
fd54f6c
Try this again.
oschwaldp-oci Jul 18, 2023
d0c1e2c
Try to debug output
oschwaldp-oci Jul 18, 2023
f995e47
Try to debug output
oschwaldp-oci Jul 18, 2023
41a1824
Fix syntax.
oschwaldp-oci Jul 18, 2023
a1bcf4b
Try escaping quotes.
oschwaldp-oci Jul 18, 2023
f4b7998
Fix syntax.
oschwaldp-oci Jul 18, 2023
56e7a9d
Debugging results.
oschwaldp-oci Jul 18, 2023
7a12930
Surround with single quotes to force not escaping internal quotes.
oschwaldp-oci Jul 18, 2023
b1862f2
Remove surrounding escaped quotes.
oschwaldp-oci Jul 18, 2023
d1e099c
Update workflow for using reusable workflow.
oschwaldp-oci Jul 18, 2023
1e562e8
Make override option into an array for matrix.
oschwaldp-oci Jul 18, 2023
90f0852
Replace accidentally removed dependency on job v.
oschwaldp-oci Jul 18, 2023
a155889
Add quotes around input param for if check.
oschwaldp-oci Jul 18, 2023
6c86da5
Cleanup previous jobs now replaced by build-base reusable workflow.
oschwaldp-oci Jul 18, 2023
1b9f64a
Try to make build step optional if build for current commit has alrea…
oschwaldp-oci Jul 18, 2023
6c2758f
Pipe leap-ref selection/override through workflows.
oschwaldp-oci Jul 18, 2023
47ddeb6
Fix spacing.
oschwaldp-oci Jul 18, 2023
4f3c5ef
Revert "Fix spacing."
oschwaldp-oci Jul 18, 2023
f49f8c9
Revert "Pipe leap-ref selection/override through workflows."
oschwaldp-oci Jul 18, 2023
c597816
Remove attempt to override leap ref for this workflow.
oschwaldp-oci Jul 18, 2023
7670690
Merge branch 'main' into ph-manual-workflow
oschwaldp-oci Jul 19, 2023
e5139d6
Try using asset-artifact-download-action@v3 to pull down past build i…
oschwaldp-oci Jul 26, 2023
1a96850
Fix file name in asset-artifact-download-action
oschwaldp-oci Jul 26, 2023
775cce4
Split out platforms workflow into separate reusable workflow.
oschwaldp-oci Jul 27, 2023
13424e2
Remove workflow_dispatch from reusable workflows.
oschwaldp-oci Jul 27, 2023
78b16c5
Fix call to build-base with proper new inputs.
oschwaldp-oci Jul 27, 2023
b30be9c
Merge branch 'main' into ph-manual-workflow
oschwaldp-oci Jul 28, 2023
4cb312e
Try using something other than empty string.
oschwaldp-oci Jul 28, 2023
45b6c77
Get the output directly from the step output.
oschwaldp-oci Jul 28, 2023
bf95111
Remove override input as build will always use the full platforms.jso…
oschwaldp-oci Jul 31, 2023
8c47cce
Address peer review comments.
oschwaldp-oci Aug 2, 2023
cd872b3
Remove debugging step and unnecessary echo.
oschwaldp-oci Aug 2, 2023
d50381b
Remove unnecessary token input.
oschwaldp-oci Aug 2, 2023
b710831
Merge branch 'main' into ph-manual-workflow
oschwaldp-oci Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions .github/workflows/build_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ name: "Build leap"
on:
workflow_dispatch:
workflow_call:
inputs:
override-build-matrix:
description: 'Override build matrix'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's driving the need for adding this? You only want to build leap for a single platform when doing the performance harness test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's worth the added complexity in build_base.yaml to accommodate that. Are you doing it just to save a dollar? I'd rather take the cost and not have 30+ more lines of yaml here to maintain forever, especially because PH runs aren't regularly done anyways.

If you want to save cost I'd suggest pushing off the complexity in to the performance_harness_run.yaml by doing something like trying to fetch an existing built leap.deb & leap-dev.deb, and then only falling back to building leap if they don't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While being able to override the build matrix was in support of the performance_harness_run.yaml workflow, I also saw the generation of the platform matrix from the platforms.json input as a net gain as it removed the maintenance effort of going back and searching out everywhere that the matrix: platform: [ ubuntuXX, ubuntuYY, ...] was used any time a new platform is added or removed. Now all that is accomplished in a single step by updating platforms.json, which has become the single source of truth.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not having to copy pasta around the [ubuntuxx..] is a good improvement. I'm a little worried we're going to have to refactor much of this soon again though because while right now there is a 1:1 between build platforms and test platforms that won't always be the case. That is, right now ubuntu22 means both building and testing on ubuntu22 but that may not always be the case. For example, for our reproducible builds we may have a separate repro platform that is used for builds, but then tested on both ubuntu20 and ubuntu22. Or ARM builds may have a crossarm platform for builds that then runs the tests on ubuntu20arm or something. I can't quite wrap my head around the semantics of how that is going to work just yet (besides adding more complexity 😞) so what is in this PR is good for now on that front.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. There is definitely a complexity addition that will come when that occurs. It could be that the Platform Matrix job provides a nice location to do the platform setup though and could be expanded to help with that? Might be that it breaks out into its own workflow. I agree that it is hard to say what will work best until some of those decisions are made. I'll consider this resolved for now per your comment.

type: string
required: false
leap-ref:
description: 'Override leap ref'
default: ${{github.sha}}
type: string
outputs:
p:
description: "Discovered Build Platforms"
Expand Down Expand Up @@ -58,19 +67,51 @@ jobs:
tags: ${{fromJSON(needs.d.outputs.p)[matrix.platform].image}}
file: ${{fromJSON(needs.d.outputs.p)[matrix.platform].dockerfile}}

pm:
name: Platform Matrix
needs: [d]
if: always() && needs.d.result == 'success'
runs-on: ubuntu-latest
outputs:
platform-matrix: ${{steps.pm-results.outputs.platform-matrix}}
steps:
- uses: actions/github-script@v6
name: Parse Platform Matrix
id: parse-pm
with:
script: return Object.keys(${{needs.d.outputs.p}})
- name: Check | Override result
id: pm-results
run: |
echo 'platform-matrix=${{steps.parse-pm.outputs.result}}' >> $GITHUB_OUTPUT

if [[ "${{inputs.override-build-matrix}}" != "" ]]; then
echo "Executing override."
echo 'platform-matrix=["${{inputs.override-build-matrix}}"]' >> $GITHUB_OUTPUT
fi
- name: Check matrix
id: check-matrix
run: |
echo '${{ steps.pm-results.outputs.platform-matrix }}'
echo '${{ steps.parse-pm.outputs.result }}'

Build:
name: Build leap
needs: [d, build-platforms]
if: always() && needs.d.result == 'success' && (needs.build-platforms.result == 'success' || needs.build-platforms.result == 'skipped')
needs: [d, build-platforms, pm]
if: |
always() &&
needs.d.result == 'success' &&
(needs.build-platforms.result == 'success' || needs.build-platforms.result == 'skipped')
strategy:
fail-fast: false
matrix:
platform: [ubuntu20, ubuntu22]
platform: ${{fromJSON(needs.pm.outputs.platform-matrix)}}
runs-on: ["self-hosted", "enf-x86-beefy"]
container: ${{fromJSON(needs.d.outputs.p)[matrix.platform].image}}
steps:
- uses: actions/checkout@v3
with:
ref: '${{inputs.leap-ref}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very problematic since on first look I don't believe the workflow+platform used to build leap will match up with the version of leap checked out. You will need to do more effort in at least 2 places to get this to work correctly, I would recommend against the added complexity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I really had this working correctly, as you observed. I have removed this feature.

submodules: recursive
- name: Build
id: build
Expand Down
104 changes: 100 additions & 4 deletions .github/workflows/performance_harness_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ name: "Performance Harness Run"

on:
workflow_dispatch:
inputs:
platform-choice:
description: 'Override build platform'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this isn't really overriding the platform but rather picking which platform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Here it is a platform selection, however down in platforms.yaml it serves to override the auto-generated platform matrix (from platforms.json). I'll update the verbiage here. Addressed: 8c47cce

type: choice
options:
- ubuntu20
- ubuntu22
override-test-params:
description: 'Override perf harness params'
type: string
override-leap-ref:
description: 'Override leap ref'
type: string

permissions:
packages: read
Expand All @@ -12,10 +25,93 @@ defaults:
shell: bash

jobs:
tmp:
name: Stub

v:
name: Discover Inputs
runs-on: ubuntu-latest
outputs:
test-params: ${{steps.overrides.outputs.test-params}}
leap-ref: ${{steps.overrides.outputs.leap-ref}}
steps:
- name: Setup Input Params
id: overrides
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this used any where?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed: 8c47cce

run: |
echo test-params=testBpOpMode >> $GITHUB_OUTPUT
echo leap-ref='${{github.sha}}' >> $GITHUB_OUTPUT

if [[ "${{inputs.override-test-params}}" != "" ]]; then
echo test-params=${{inputs.override-test-params}} >> $GITHUB_OUTPUT
fi
if [[ "${{inputs.override-leap-ref}}" != "" ]]; then
echo leap-ref=${{inputs.override-leap-ref}} >> $GITHUB_OUTPUT
fi

reuse-build:
name: Reuse leap build
needs: [v]
if: |
always() &&
needs.v.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Workflow Stub
- name: Download builddir
uses: AntelopeIO/asset-artifact-download-action@v2
with:
owner: AntelopeIO
repo: leap
file: ${{github.event.inputs.platform-choice}}-build
target: '${{needs.v.outputs.leap-ref}}'
artifact-name: ${{github.event.inputs.platform-choice}}-build
token: ${{github.token}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with v3 you don't need this line, if you want to save a line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: d50381b


- name: Upload builddir
uses: AntelopeIO/upload-artifact-large-chunks-action@v1
with:
name: ${{github.event.inputs.platform-choice}}-build
path: build.tar.zst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments as #1356 (comment): we shouldn't be copy pasting all of this, we need to come up with a better approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spoonincode - I have refactored the build to be a reusable workflow in PR#1356. Hoping to have that PR go into main first, then I will pull those changes into this branch and refactor the workflow to use build-base as well.


build-base:
name: Run Build Workflow
needs: [reuse-build]
if: always() && needs.reuse-build.result != 'success'
uses: ./.github/workflows/build_base.yaml
with:
override-build-matrix: ${{github.event.inputs.platform-choice}}
leap-ref: ${{needs.v.outputs.leap-ref}}
permissions:
packages: write
contents: read

tests:
name: Tests
needs: [v, reuse-build, build-base]
if: always() && (needs.build-base.result == 'success' || needs.reuse-build.result == 'success')
runs-on: ubuntu-latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means it runs on a github owned runner, is that what you wanted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spoonincode - Correct. I was using the github owned runner for initial testing and verification of the workflow. Now that this is closer to complete, do you have a suggestion for a runner to use (enf-x86-beefy-long)? I know that most of the enf runners have time limits on them which could be problematic for performance runs depending on how a user configures the run.

container:
image: ${{fromJSON(needs.build-base.outputs.p)[github.event.inputs.platform-choice].image}}
steps:
- name: Download builddir
uses: actions/download-artifact@v3
with:
name: ${{github.event.inputs.platform-choice}}-build
- name: Run Performance Test
run: |
zstdcat build.tar.zst | tar x
cd build
./tests/performance_tests/performance_test.py ${{needs.v.outputs.test-params}}
- name: Prepare results
id: prep-results
run: |
echo "Workflow Stub"
tar -pc build/performance_test | zstd --long -T0 -9 > performance_test_logs.tar.zst
- name: Upload results
uses: AntelopeIO/upload-artifact-large-chunks-action@v1
with:
name: performance-test-results
path: performance_test_logs.tar.zst
- name: Upload report
uses: actions/upload-artifact@v3
with:
name: performance-test-report
path: ./build/performance_test/**/report.json