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

[GHA] Add container build dependency to wait on wheels to be built #2205

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
2c23b53
add container build dependency to wait on wheels to be built
dsikka Mar 29, 2024
8abc46d
update
dsikka Mar 29, 2024
bb7b02d
update permissions
dsikka Mar 29, 2024
2d3de11
try nightly flow
dsikka Mar 29, 2024
0421a11
teset
dsikka Mar 29, 2024
f402157
Merge branch 'main' into add_dependency
dsikka Mar 29, 2024
bb13f99
remove extra line
dsikka Apr 2, 2024
713f251
try self-hosted runner
dsikka Apr 2, 2024
646d383
remove self-hosted tag
dsikka Apr 2, 2024
837dd15
add pull wheel and test
dsikka Apr 2, 2024
0c7aed9
typo
dsikka Apr 2, 2024
116de30
typo
dsikka Apr 2, 2024
37d6885
update
dsikka Apr 2, 2024
aefac3f
update install
dsikka Apr 2, 2024
ece28cb
update path
dsikka Apr 2, 2024
1437adc
try again
dsikka Apr 2, 2024
9f7454b
update wheel install
dsikka Apr 2, 2024
68539a8
typo
dsikka Apr 2, 2024
acb63ab
typo
dsikka Apr 2, 2024
d396464
try again
dsikka Apr 2, 2024
1a21154
try again
dsikka Apr 2, 2024
872c10a
try again
dsikka Apr 2, 2024
155d7cc
try again
dsikka Apr 2, 2024
89d2ef8
try again
dsikka Apr 2, 2024
f610bf6
try again
dsikka Apr 2, 2024
bfaaee3
small refactor
dsikka Apr 3, 2024
5608143
update path
dsikka Apr 3, 2024
2ca29a0
update path
dsikka Apr 3, 2024
acf8c67
cleanup
dsikka Apr 3, 2024
9fe897f
cleanup
dsikka Apr 3, 2024
8224698
cleanup
dsikka Apr 3, 2024
457d905
change bool
dsikka Apr 3, 2024
5245824
update
dsikka Apr 3, 2024
3138e5a
add back type
dsikka Apr 3, 2024
af246b9
update
dsikka Apr 3, 2024
4b23616
try again
dsikka Apr 3, 2024
3a6d141
try again
dsikka Apr 3, 2024
0605649
try again
dsikka Apr 3, 2024
a973d64
inherit
dsikka Apr 3, 2024
d0719e8
try again
dsikka Apr 3, 2024
4b891a1
try again
dsikka Apr 3, 2024
95a5327
try again
dsikka Apr 3, 2024
0882b05
try
dsikka Apr 3, 2024
2bf4e01
try again
dsikka Apr 3, 2024
808d8a7
try again
dsikka Apr 3, 2024
384506c
update
dsikka Apr 3, 2024
2a92a70
update
dsikka Apr 3, 2024
7c3002e
update
dsikka Apr 3, 2024
81c9efa
update
dsikka Apr 3, 2024
eae6993
debug
dsikka Apr 3, 2024
bc3fe3a
try updating name
dsikka Apr 3, 2024
fc7412c
add output
dsikka Apr 3, 2024
071cbdb
add subfolder; try internal pypi step
dsikka Apr 3, 2024
340be9f
remove subfolder
dsikka Apr 3, 2024
3dcc204
update job
dsikka Apr 3, 2024
bc1023a
update condition
dsikka Apr 3, 2024
e01ca4e
move if condition
dsikka Apr 3, 2024
d94a4d3
move to other job
dsikka Apr 3, 2024
6e14a67
move
dsikka Apr 3, 2024
3634021
always push to internal
dsikka Apr 3, 2024
aabd094
one more time
dsikka Apr 3, 2024
91b4685
remove internal requirements
dsikka Apr 3, 2024
f71c979
try new bucket name
dsikka Apr 3, 2024
723955d
provide bucket name
dsikka Apr 3, 2024
ce671e0
update internal pypi action
dsikka Apr 3, 2024
1a33f25
move
dsikka Apr 3, 2024
a7cd36d
try another runner
dsikka Apr 3, 2024
0e11f06
update
dsikka Apr 3, 2024
1a3078e
try again
dsikka Apr 3, 2024
903b09c
update
dsikka Apr 3, 2024
a89123b
hardcode
dsikka Apr 3, 2024
de19d04
revert
dsikka Apr 3, 2024
9b374cb
add upload step
dsikka Apr 3, 2024
caf2d8e
try upload
dsikka Apr 3, 2024
59578c4
hardcode'
dsikka Apr 3, 2024
4a6f81a
try relative path
dsikka Apr 3, 2024
807fd73
try again
dsikka Apr 3, 2024
78b52fd
try again
dsikka Apr 3, 2024
1035da2
try again
dsikka Apr 3, 2024
58b7e75
move
dsikka Apr 3, 2024
441fead
update
dsikka Apr 3, 2024
ed3df7d
fix
dsikka Apr 3, 2024
f1ab797
try again
dsikka Apr 3, 2024
0bea05e
try again
dsikka Apr 3, 2024
3b8096d
update
dsikka Apr 3, 2024
e2d1fb8
try one more time
dsikka Apr 3, 2024
9b478a0
try again
dsikka Apr 3, 2024
662deba
typo
dsikka Apr 3, 2024
79d7205
one more time
dsikka Apr 3, 2024
8c980c5
again
dsikka Apr 3, 2024
d7fc98c
reepat
dsikka Apr 3, 2024
cabe4e1
add python version and env creation
dsikka Apr 3, 2024
a221a9d
cleanup
dsikka Apr 4, 2024
d192e01
fix typo
dsikka Apr 4, 2024
8fc32b3
update docker steps
dsikka Apr 4, 2024
0672ba4
add remaining steps
dsikka Apr 4, 2024
3377748
try again
dsikka Apr 4, 2024
77b2070
try again
dsikka Apr 4, 2024
50e674f
try again
dsikka Apr 4, 2024
33fd885
try again
dsikka Apr 4, 2024
46ca3b8
try again
dsikka Apr 4, 2024
731b1ad
update needs
dsikka Apr 4, 2024
8c68e32
clean-up
dsikka Apr 4, 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
74 changes: 25 additions & 49 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,56 @@
name: Build Docker Container
name: Build Container with wheel and push to GCR
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'release/[0-9]+.[0-9]+'
push:
branches:
- 'main'
release:
types: [created, published]
schedule:
- cron: '0 2 * * *'

# TODO: docker containers created through a release cut vs PR to the release branch
# will be pushed to different locations (i.e one will be sparseml the other will be test-sparseml).
# These containers rely on the new internal pypi server being enabled. Once enabled,
# this workflow can be expanded to make this distinction.
env:
RELEASE: ${{ github.event_name =='release' || (startsWith(github.base_ref, 'release/') && github.event_name == 'pull_request')}}
DEV: ${{ github.base_ref == 'main' && github.event_name == 'pull_request'}}
NAME: ${{ github.event.number }}

permissions:
contents: read
packages: write
workflow_call:
inputs:
build-label:
description: "requested runner label"
type: string
dev:
type: string
required: true
release:
type: string
required: true
name:
type: string

jobs:
build-container:
name: Build sparseml container
runs-on: ubuntu-20.04
runs-on: ${{ inputs.build-label }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT

- name: Get the current version
if: ${{ env.RELEASE == 'true' }}
if: ${{ inputs.release == 'true' }}
id: version
run: echo "::set-output name=version::$(echo ${{ github.base_ref }} | cut -c 9-15)"
run: echo "version=$(echo ${{ github.base_ref }} | cut -c 9-15)" >> $GITHUB_OUTPUT

- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Dev Docker Container
if: ${{ env.DEV == 'true' }}
if: ${{ inputs.dev == 'true' }}
uses: docker/build-push-action@v4
with:
context: ./docker/containers/docker_dev
build-args: |
BRANCH=${{github.head_ref}}
push: true
tags: ghcr.io/neuralmagic/sparseml-dev:${{ env.NAME }}
- name: Build Release Docker Container
if: ${{ env.RELEASE == 'true' }}
uses: docker/build-push-action@v4
with:
context: ./docker/containers/docker_release
build-args: |
VERSION=${{ steps.version.outputs.version }}
push: true
tags: ghcr.io/neuralmagic/test-sparseml:latest, ghcr.io/neuralmagic/test-sparseml:${{ steps.version.outputs.version }}
- name: Build Nightly Docker Container
if: ${{ env.DEV == 'false' && env.RELEASE == 'false'}}
uses: docker/build-push-action@v4
with:
context: ./docker/containers/docker_nightly
push: true
tags: ghcr.io/neuralmagic/test-sparseml-nightly:latest, ghcr.io/neuralmagic/test-sparseml-nightly:${{ steps.date.outputs.date }}
tags: ghcr.io/neuralmagic/sparseml-dev:${{ inputs.name }}
77 changes: 77 additions & 0 deletions .github/workflows/build-wheel-and-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build PyPi Wheel and Docker Container
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'release/[0-9]+.[0-9]+'
push:
branches:
- 'release/[0-9]+.[0-9]+'
- main
release:
types: [created, published]
schedule:
- cron: '0 0 * * *'

permissions:
id-token: write
contents: read
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

# if not dev or release, will create a nightly build
env:
PRODUCTION: ${{ github.event_name == 'schedule' || github.event_name == 'release'}}
RELEASE: ${{ github.event_name =='release' || startsWith(github.base_ref, 'release/') }}
DEV: ${{ github.base_ref == 'main' && github.event_name == 'pull_request'}}

jobs:
set-outputs:
runs-on: ubuntu-latest
outputs:
dev: ${{ steps.set-outputs.outputs.dev }}
release: ${{ steps.set-outputs.outputs.release }}
steps:
- name: Set variables for workflows
id: set-outputs
run: |
echo "dev=$DEV" >> $GITHUB_OUTPUT
echo "release=$RELEASE" >> $GITHUB_OUTPUT

build-wheel-and-push:
needs: set-outputs
uses: ./.github/workflows/build-wheel.yml
with:
build-label: ubuntu-20.04
dev: ${{ needs.set-outputs.outputs.dev }}
release: ${{ needs.set-outputs.outputs.release }}
name: ${{ github.event.number }}
filename: dist/*.whl
bucket_name: nm-actions-test
python: '3.10'
secrets: inherit

test-wheel-and-push-internal:
needs: build-wheel-and-push
uses: ./.github/workflows/test-wheel-push-to-internal.yml
with:
build-label: aws-avx2-64G
whl: ${{ needs.build-wheel-and-push.outputs.wheel }}
python: '3.10'
secrets: inherit

# TODO: add nightly and release container build steps once wheel build push
# to production is automated. Removed until then.
build-container-and-push:
needs: [set-outputs, test-wheel-and-push-internal]
uses: ./.github/workflows/build-container.yml
with:
build-label: aws-avx2-64G
dev: ${{ needs.set-outputs.outputs.dev }}
release: ${{ needs.set-outputs.outputs.release }}
name: ${{ github.event.number }}
secrets: inherit
114 changes: 62 additions & 52 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
name: Build PyPi Wheel
name: Build Wheel and Push to s3
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'release/[0-9]+.[0-9]+'
push:
branches:
- main
release:
types: [created, published]
schedule:
- cron: '0 0 * * *'

permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

# if not dev or release, will create a nightly build
# everything is pushed to internal unless created through a nightly scheduled cron job which creates the build or
# missing release tag workflow/needs to be added in
env:
INTERNAL: ${{ github.event_name != 'schedule' && github.event_name != 'release'}}
RELEASE: ${{ github.event_name =='release' || (startsWith(github.base_ref, 'release/') && github.event_name == 'pull_request')}}
DEV: ${{ github.base_ref == 'main' && github.event_name == 'pull_request'}}
NAME: ${{ github.event.number }}
workflow_call:
inputs:
build-label:
description: "requested runner label"
type: string
required: true
dev:
type: string
required: true
release:
type: string
required: true
name:
type: string
filename:
type: string
required: true
bucket_name:
type: string
required: true
python:
type: string
outputs:
wheel:
value: ${{ jobs.build-wheel-and-push.outputs.wheel }}

jobs:
build_and_push:
runs-on: ubuntu-latest
build-wheel-and-push:
runs-on: ${{ inputs.build-label }}
outputs:
wheel: ${{ steps.push-wheel.outputs.wheel }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to s3
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_WEBIDENTITY_FOR_GITHUB_ACTIONS }}
aws-region: us-east-1
- name: Build PyPi Wheel
id: build-wheel
uses: neuralmagic/nm-actions/actions/pypi_build@main
with:
dev: $DEV
release: $RELEASE
name: $NAME
- name: Push to s3 bucket
id: push-wheel
uses: neuralmagic/nm-actions/actions/s3_push@main
with:
filename: dist/*.whl
internal: $INTERNAL
- uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python }}

- name: Checkout code
uses: actions/checkout@v3

- name: Login to s3
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_WEBIDENTITY_FOR_GITHUB_ACTIONS }}
aws-region: us-east-1

- name: Set Env
run: |
pip3 install virtualenv
virtualenv venv
source venv/bin/activate

- name: Build PyPi Wheel
id: build-wheel
uses: neuralmagic/nm-actions/actions/pypi_build@update_bucket
with:
dev: ${{ inputs.dev }}
release: ${{ inputs.release }}
name: ${{ inputs.name }}

- name: Push to s3 bucket
id: push-wheel
uses: neuralmagic/nm-actions/actions/s3_push@update_bucket
with:
filename: ${{ inputs.filename }}
bucket_name: ${{ inputs.bucket_name }}

73 changes: 73 additions & 0 deletions .github/workflows/test-wheel-push-to-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test Wheel and Push to Internal PyPi
on:
workflow_call:
inputs:
build-label:
description: "requested runner label"
type: string
required: true
whl:
type: string
required: true
python:
type: string

jobs:
test-wheel-and-push-internal:
runs-on: ${{ inputs.build-label }}
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python }}

- name: Login to s3
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_WEBIDENTITY_FOR_GITHUB_ACTIONS }}
aws-region: us-east-1

- name: Make directory for wheel
run: |
mkdir dist_s3

- name: Pull from s3
uses: neuralmagic/nm-actions/actions/s3_pull@main
with:
filename: ${{ inputs.whl }}
dst: dist_s3

- name: Set Env
run: |
pip3 install virtualenv
virtualenv venv
source venv/bin/activate

- name: Fetch name of whl
run: |
echo "FILENAME=$(echo dist_s3/*.whl)" >> $GITHUB_ENV

- name: Push to internal pypi
uses: neuralmagic/nm-actions/actions/nm-upload-whl@upload-pypi
with:
server: ${{ secrets.NM_PRIVATE_PYPI_LOCATION }}
username: ${{ secrets.NM_PRIVATE_PYPI_USER }}
password: ${{ secrets.NM_PRIVATE_PYPI_AUTH }}
whl: ./$FILENAME
port: 8080

- name: Install whl
run: |
pip3 install $FILENAME[dev]

- name: Checkout code
uses: actions/checkout@v3

- name: Remove src files and run tests
run: |
rm -rf src
make test





Loading
Loading