-
Notifications
You must be signed in to change notification settings - Fork 148
144 lines (140 loc) · 4.67 KB
/
build-wheel-and-container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
# 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/') }}
DEV: ${{ github.base_ref == 'main' && github.event_name == 'pull_request'}}
NAME: ${{ github.event.number }}
jobs:
build-wheel-and-push:
runs-on: ubuntu-20.04
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
pull-wheel-and-test:
needs: build-wheel-and-push
runs-on: ubuntu-20.04
steps:
- 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: ${{ needs.build-wheel-and-push.outputs.wheel }}
dst: dist_s3
- name: Install Wheel
run: |
echo "FILENAME=$(echo dist_s3/*.whl)" >> $GITHUB_ENV
echo $FILENAME
- name: Checkout code
uses: actions/checkout@v3
with:
sparse-checkout: 'tests'
sparse-checkout-cone-mode: false
- name: Remove non-test files and run tests
run: |
pip install $FILENAME
pip list
pip install pytest
ls
make test
build-container-and-push:
needs: pull-wheel-and-test
runs-on: [aws-avx2-64G]
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')"
- name: Get the current version
if: ${{ env.RELEASE == 'true' }}
id: version
run: echo "::set-output name=version::$(echo ${{ github.base_ref }} | cut -c 9-15)"
- 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' }}
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 }}