|
| 1 | +name: build |
| 2 | +on: |
| 3 | + # makes workflow reusable |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + wf_category: |
| 7 | + description: "categories: NIGHTLY, RELEASE" |
| 8 | + type: string |
| 9 | + default: NIGHTLY |
| 10 | + build_label: |
| 11 | + description: "requested runner label (specifies instance)" |
| 12 | + type: string |
| 13 | + required: true |
| 14 | + timeout: |
| 15 | + description: "time limit for run in minutes " |
| 16 | + type: string |
| 17 | + default: 20 |
| 18 | + gitref: |
| 19 | + description: "git commit hash or branch name" |
| 20 | + type: string |
| 21 | + default: main |
| 22 | + outputs: |
| 23 | + whl: |
| 24 | + description: 'basename for generated whl' |
| 25 | + value: ${{ jobs.BUILD.outputs.whl }} |
| 26 | + testmo_run_id: |
| 27 | + description: 'testmo run id' |
| 28 | + value: ${{ jobs.BUILD.outputs.testmo_run_id }} |
| 29 | + |
| 30 | + # makes workflow manually callable |
| 31 | + workflow_dispatch: |
| 32 | + inputs: |
| 33 | + wf_category: |
| 34 | + description: "categories: NIGHTLY, RELEASE" |
| 35 | + type: string |
| 36 | + default: NIGHTLY |
| 37 | + build_label: |
| 38 | + description: "requested runner label (specifies instance)" |
| 39 | + type: string |
| 40 | + required: true |
| 41 | + timeout: |
| 42 | + description: "time limit for run in minutes " |
| 43 | + type: string |
| 44 | + default: 20 |
| 45 | + gitref: |
| 46 | + description: "git commit hash or branch name" |
| 47 | + type: string |
| 48 | + default: main |
| 49 | + |
| 50 | +jobs: |
| 51 | + |
| 52 | + BUILD: |
| 53 | + |
| 54 | + runs-on: ${{ inputs.build_label }} |
| 55 | + timeout-minutes: ${{ fromJson(inputs.timeout) }} |
| 56 | + permissions: |
| 57 | + contents: 'read' |
| 58 | + id-token: 'write' |
| 59 | + |
| 60 | + outputs: |
| 61 | + run_id: ${{ github.run_id }} |
| 62 | + whl: ${{ steps.build.outputs.whlname }} |
| 63 | + tarfile: ${{ steps.build.outputs.tarname }} |
| 64 | + testmo_run_id: ${{ steps.create_testmo_run.outputs.id }} |
| 65 | + |
| 66 | + steps: |
| 67 | + |
| 68 | + - name: set python |
| 69 | + uses: actions/setup-python@v4 |
| 70 | + with: |
| 71 | + python-version: '3.10' |
| 72 | + |
| 73 | + - name: checkout code |
| 74 | + id: checkout |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + ref: ${{ inputs.gitref }} |
| 78 | + |
| 79 | + - name: install testmo |
| 80 | + uses: neuralmagic/nm-actions/actions/[email protected] |
| 81 | + |
| 82 | + - name: create testmo run |
| 83 | + id: create_testmo_run |
| 84 | + uses: neuralmagic/nm-actions/actions/[email protected] |
| 85 | + if: success() |
| 86 | + with: |
| 87 | + testmo_url: https://neuralmagic.testmo.net |
| 88 | + testmo_token: ${{ secrets.TESTMO_TEST_TOKEN }} |
| 89 | + source: 'build-test' |
| 90 | + project_id: 14 |
| 91 | + run_name: compressedtensors-${{ inputs.wf_category }}-${{ inputs.gitref }}-${GITHUB_ACTOR} |
| 92 | + |
| 93 | + - name: build |
| 94 | + id: build |
| 95 | + uses: neuralmagic/nm-actions/actions/[email protected] |
| 96 | + with: |
| 97 | + dev: false |
| 98 | + release: ${{ inputs.wf_category == 'RELEASE' }} |
| 99 | + |
| 100 | + # GCP |
| 101 | + - name: 'Authenticate to Google Cloud' |
| 102 | + id: auth |
| 103 | + uses: google-github-actions/[email protected] |
| 104 | + with: |
| 105 | + project_id: ${{ secrets.GCP_PROJECT }} |
| 106 | + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} |
| 107 | + service_account: ${{ secrets.GCP_GHA_SA }} |
| 108 | + |
| 109 | + - name: 'Set up Cloud SDK' |
| 110 | + uses: 'google-github-actions/setup-gcloud@v2' |
| 111 | + with: |
| 112 | + version: '>= 473.0.0' |
| 113 | + |
| 114 | + - name: copy whl and source distribution |
| 115 | + run: | |
| 116 | + gcloud storage cp dist/${{ steps.build.outputs.whlname }} ${{ secrets.GCP_BUILD_ML_ASSETS2 }}/${{ github.run_id }}/${{ steps.build.outputs.whlname }} |
| 117 | + gcloud storage cp dist/${{ steps.build.outputs.tarname }} ${{ secrets.GCP_BUILD_ML_ASSETS2 }}/${{ github.run_id }}/${{ steps.build.outputs.tarname }} |
| 118 | +
|
| 119 | + - name: upload whl |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + if: success() || failure() |
| 122 | + with: |
| 123 | + name: ${{ steps.build.outputs.whlname }} |
| 124 | + path: dist/${{ steps.build.outputs.whlname }} |
| 125 | + retention-days: 5 |
| 126 | + |
| 127 | + - name: upload tar.gz |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + if: success() || failure() |
| 130 | + with: |
| 131 | + name: ${{ steps.build.outputs.tarname }} |
| 132 | + path: dist/${{ steps.build.outputs.tarname }} |
| 133 | + retention-days: 5 |
| 134 | + |
| 135 | + - name: summary |
| 136 | + uses: neuralmagic/nm-actions/actions/[email protected] |
| 137 | + if: success() || failure() |
| 138 | + with: |
| 139 | + label: ${{ inputs.build_label }} |
| 140 | + gitref: ${{ inputs.gitref }} |
| 141 | + whl_status: ${{ steps.build.outputs.status }} |
| 142 | + |
| 143 | + - name: report build status to testmo |
| 144 | + id: report_build |
| 145 | + uses: neuralmagic/nm-actions/actions/[email protected] |
| 146 | + if: (success() || failure()) && ${{ inputs.testmo_run_id != '' }} |
| 147 | + with: |
| 148 | + testmo_url: https://neuralmagic.testmo.net |
| 149 | + testmo_token: ${{ secrets.TESTMO_TEST_TOKEN }} |
| 150 | + testmo_run_id: ${{ steps.create_testmo_run.outputs.id }} |
| 151 | + results: build-results |
| 152 | + step_status: ${{ steps.build.outputs.status }} |
| 153 | + |
| 154 | + - name: run status |
| 155 | + id: run_status |
| 156 | + if: success() || failure() |
| 157 | + env: |
| 158 | + WHL_STATUS: ${{ steps.build.outputs.status }} |
| 159 | + run: | |
| 160 | + echo "build status: ${WHL_STATUS}" |
| 161 | + if [ -z "${WHL_STATUS}" ] || [ "${WHL_STATUS}" -ne "0" ]; then exit 1; fi |
0 commit comments