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

[DEVOPS-234] CI/CD: Reuse existing feature branch builds for valgrind runs #670

Merged
merged 61 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d4ed587
wip
juliannguyen4 Sep 11, 2024
ce311f2
wip
juliannguyen4 Sep 11, 2024
7600ac3
wip
juliannguyen4 Sep 11, 2024
745d6a3
wip
juliannguyen4 Sep 12, 2024
f0c5952
wip
juliannguyen4 Sep 12, 2024
26e63e7
checkout
juliannguyen4 Sep 12, 2024
0f5a0fd
fix syntax
juliannguyen4 Sep 12, 2024
e9a3344
cache wheel using jfrog
juliannguyen4 Sep 12, 2024
a38524d
update comments
juliannguyen4 Sep 12, 2024
68f4f68
fix working dir
juliannguyen4 Sep 12, 2024
604e07a
fix
juliannguyen4 Sep 12, 2024
0501135
todo
juliannguyen4 Sep 12, 2024
0242e35
wip will break
juliannguyen4 Sep 16, 2024
53c5deb
Revert "wip will break"
juliannguyen4 Sep 18, 2024
a1fb1db
Merge remote-tracking branch 'origin/dev' into DEVOPS-234-reuse-ft-br…
juliannguyen4 Sep 23, 2024
4bd345d
mv
juliannguyen4 Sep 23, 2024
fb00ca3
finish
juliannguyen4 Sep 23, 2024
850495c
rev
juliannguyen4 Sep 23, 2024
b495120
rv
juliannguyen4 Sep 23, 2024
a7c3b11
rm useless env var
juliannguyen4 Sep 23, 2024
538b2d2
add abck
juliannguyen4 Sep 23, 2024
33a70d3
Fix
juliannguyen4 Sep 25, 2024
8a22851
Merge remote-tracking branch 'origin/dev' into DEVOPS-234-reuse-ft-br…
juliannguyen4 Nov 6, 2024
529e015
Fix
juliannguyen4 Nov 6, 2024
487a552
Split up
juliannguyen4 Nov 6, 2024
4e24036
not an s command
juliannguyen4 Nov 6, 2024
ebeb564
fix
juliannguyen4 Nov 6, 2024
def538a
fix
juliannguyen4 Nov 6, 2024
6cf1633
debug
juliannguyen4 Nov 6, 2024
fa1e76e
Fix
juliannguyen4 Nov 6, 2024
1bd4bbf
just do this..
juliannguyen4 Nov 6, 2024
0c71f0a
Fix
juliannguyen4 Nov 6, 2024
7f4c210
Fix
juliannguyen4 Nov 6, 2024
6f3b74e
this works
juliannguyen4 Nov 6, 2024
ccecb52
this is better
juliannguyen4 Nov 6, 2024
efcdb6c
jq doesnt edit file in place
juliannguyen4 Nov 6, 2024
a2bbbe2
install
juliannguyen4 Nov 6, 2024
257cdec
keep the array the same
juliannguyen4 Nov 6, 2024
61d5f71
coment
juliannguyen4 Nov 6, 2024
06343ec
Be more specific
juliannguyen4 Nov 7, 2024
e082960
make sure cmds aren't failing early on
juliannguyen4 Nov 7, 2024
d974995
fix
juliannguyen4 Nov 7, 2024
0e38956
Merge remote-tracking branch 'origin/dev' into DEVOPS-234-reuse-ft-br…
juliannguyen4 Nov 15, 2024
e1184a0
clear up
juliannguyen4 Nov 18, 2024
e85c717
clear up
juliannguyen4 Nov 18, 2024
106c607
just hardcode
juliannguyen4 Nov 18, 2024
11c05b3
Fix
juliannguyen4 Nov 18, 2024
81d3e8d
see if this works
juliannguyen4 Nov 18, 2024
0cd2ffe
try
juliannguyen4 Nov 18, 2024
92be52f
make logic better
juliannguyen4 Nov 18, 2024
8fa19e5
put back
juliannguyen4 Nov 18, 2024
fd8b2e6
fix
juliannguyen4 Nov 18, 2024
a881a15
Don't upload to JFrog for central branches
juliannguyen4 Nov 18, 2024
a1d2ca4
space?
juliannguyen4 Nov 18, 2024
33ef486
ref_name only works for push/prs
juliannguyen4 Nov 18, 2024
962e5b7
fully formed ref
juliannguyen4 Nov 19, 2024
f5065b6
Add explanation
juliannguyen4 Nov 19, 2024
0e645a1
better
juliannguyen4 Nov 20, 2024
dbab95a
add debug
juliannguyen4 Nov 20, 2024
fb094ae
Add note
juliannguyen4 Nov 20, 2024
c2f438c
rm debug
juliannguyen4 Nov 20, 2024
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
108 changes: 104 additions & 4 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,122 @@ on:
required: false
default: false

env:
PYTHON_TAG: cp38

jobs:
look-for-wheel-in-jfrog:
outputs:
num_artifacts_found: ${{ steps.count_num_artifacts_found.outputs.num_artifacts }}
# So we can pass the python tag to a reusable workflow
python-tag: ${{ env.PYTHON_TAG }}
runs-on: ubuntu-22.04
env:
JF_SEARCH_RESULTS_FILE_NAME: wheel_commit_matches.txt
steps:
- uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ secrets.JFROG_PLATFORM_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JFROG_ACCESS_TOKEN }}

- name: Get shortened commit hash of this workflow run
# versioningit commit sha is always 8 chars long it seems
run: echo SHORT_GITHUB_SHA=$(echo ${{ github.sha }} | cut -c1-8) >> $GITHUB_ENV

- name: Look for wheel built with default settings in JFrog
# AQL has the option to exclude patterns from search results
# but it doesn't allow regex, so we can't filter out any type of label in a wheel name
# Example: we want to filter out "unoptimized" and "dsym" but in case we add more labels, we want to use regex
# to handle those new labels without updating the regex.
run: jf rt search "${{ vars.JFROG_GENERIC_REPO_NAME }}/${{ github.ref_name }}/*${{ env.SHORT_GITHUB_SHA }}*${{ env.PYTHON_TAG }}*manylinux*x86_64*.whl" > ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}

- name: Show unfiltered results
run: cat ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}

- name: Install sponge
run: sudo apt install -y moreutils

- name: Filter out wheels with labels in results
run: jq 'map(select(.path | test("${{ env.SHORT_GITHUB_SHA }}\\.") | not))' ${{ env.JF_SEARCH_RESULTS_FILE_NAME }} | sponge ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}
shell: bash

- name: Check if artifacts with labels were filtered out
run: cat ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}

- name: Count artifacts
id: count_num_artifacts_found
run: echo num_artifacts=$(jq length ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}) >> $GITHUB_OUTPUT

- name: Multiple artifacts found, not sure which one to use. Fail out
if: ${{ steps.count_num_artifacts_found.outputs.num_artifacts > 1 }}
run: exit 1

- name: Found the exact artifact in JFrog. Get the artifact name
if: ${{ steps.count_num_artifacts_found.outputs.num_artifacts == 1 }}
run: echo ARTIFACT_PATH=$(jq -r .[0].path ${{ env.JF_SEARCH_RESULTS_FILE_NAME }}) >> $GITHUB_ENV

- name: Then download artifact from JFrog
if: ${{ steps.count_num_artifacts_found.outputs.num_artifacts == 1 }}
run: jf rt download --flat --fail-no-op ${{ env.ARTIFACT_PATH }}

- name: Pass to valgrind job
if: ${{ steps.count_num_artifacts_found.outputs.num_artifacts == 1 }}
uses: actions/upload-artifact@v4
with:
# Artifact name doesn't matter. Valgrind job downloads all artifacts to get the one wheel
if-no-files-found: error
path: './*.whl'

build-manylinux-wheel:
needs: look-for-wheel-in-jfrog
if: ${{ needs.look-for-wheel-in-jfrog.outputs.num_artifacts_found == 0 }}
uses: ./.github/workflows/build-wheels.yml
with:
python-tags: '["cp38"]'
python-tags: '["${{ needs.look-for-wheel-in-jfrog.outputs.python-tag }}"]'
platform-tag: manylinux_x86_64
sha-to-build-and-test: ${{ github.sha }}
secrets: inherit

upload-built-wheel-to-jfrog:
needs: build-manylinux-wheel
# TODO: this job should skip when this workflow is run on central branches
# We already have artifacts available for central branches in the PyPI-type JFrog repo
# The problem is we have to conditionally skip this job, but using the github context to get the branch name
# doesn't work for some reason. Just leave this alone for now.
uses: ./.github/workflows/upload-to-jfrog.yml
with:
jfrog-repo-name: ${{ vars.JFROG_GENERIC_REPO_NAME }}
secrets: inherit

valgrind:
env:
MASSIF_REPORT_FILE_NAME: massif.out
needs: build-manylinux-wheel
needs: [
look-for-wheel-in-jfrog,
build-manylinux-wheel
]
# Case 1: Found artifact in JFrog
# Case 2: Did not find artifact in JFrog, had to build it in GHA
if: ${{ !cancelled() && (needs.look-for-wheel-in-jfrog.result == 'success' && (needs.look-for-wheel-in-jfrog.outputs.num_artifacts_found == 1) || (needs.look-for-wheel-in-jfrog.outputs.num_artifacts_found == 0 && needs.build-manylinux-wheel.result == 'success')) }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Convert Python tag to Python version
run: echo PYTHON_VERSION=$(echo ${{ env.PYTHON_TAG }} | sed -e "s/cp3/cp3./" -e "s/cp//") >> $GITHUB_ENV
shell: bash

- uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '${{ env.PYTHON_VERSION }}'
architecture: 'x64'

- uses: actions/download-artifact@v4
with:
name: cp38-manylinux_x86_64.build
merge-multiple: true

- name: Install client
run: pip install ./*.whl
Expand Down Expand Up @@ -76,6 +164,18 @@ jobs:
- run: PYTHONMALLOC=malloc valgrind --error-exitcode=1 ${{ env.VALGRIND_ARGS }} python3 -m pytest -v new_tests/${{ github.event.inputs.test-file }}
working-directory: test

# TODO: upload report as artifact
- run: ms_print ./${{ env.MASSIF_REPORT_FILE_NAME }}
if: ${{ !cancelled() && inputs.massif }}
working-directory: test

# See reason for deleting artifacts in dev-workflow-p2.yml
delete-artifacts:
needs: [
# These jobs must have downloaded the artifact from Github before we can delete it
upload-built-wheel-to-jfrog,
valgrind
]
# Workflow run must clean up after itself even if cancelled
if: ${{ always() }}
uses: ./.github/workflows/delete-artifacts.yml
Loading