Release responsibleai and raiwidgets to PyPI #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release responsibleai and raiwidgets to PyPI | |
env: | |
node-version: 16.x | |
widgetDirectory: raiwidgets | |
raiDirectory: responsibleai | |
typescriptBuildOutput: dist | |
typescriptBuildArtifactName: typescript | |
# trigger manually only ("collaborator" or more permissions required) | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: "Test or Prod PyPI?" | |
required: true | |
default: "Test" | |
jobs: | |
release-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: fail if Test nor Prod | |
if: ${{ ! (github.event.inputs.releaseType == 'Test' || github.event.inputs.releaseType == 'Prod') }} | |
run: | | |
echo "Only Test or Prod can be used." | |
exit 1 | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: 3.8 | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
- name: Install yarn | |
run: | | |
npm install yarn -g | |
- name: install typescript dependencies | |
run: | | |
yarn install --frozen-lock-file | |
- name: auto version | |
if: ${{ github.event.inputs.releaseType == 'Test' }} | |
run: | | |
yarn auto-version -r | |
- name: auto version | |
if: ${{ github.event.inputs.releaseType == 'Prod' }} | |
run: | | |
yarn auto-version -r -t | |
- name: build typescript | |
run: | | |
yarn buildall | |
- name: update and upgrade pip, setuptools, wheel, and twine | |
shell: bash -l {0} | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade setuptools wheel twine | |
- name: install requirements.txt for raiwidgets | |
shell: bash -l {0} | |
run: | | |
pip install -r requirements.txt | |
pip install -r requirements-dev.txt | |
working-directory: ${{ env.widgetDirectory }} | |
- name: install requirements.txt for responsibleai | |
shell: bash -l {0} | |
run: | | |
pip install -r requirements.txt | |
pip install -r requirements-dev.txt | |
working-directory: ${{ env.raiDirectory }} | |
- name: pip freeze | |
shell: bash -l {0} | |
run: pip freeze | |
- name: replace README for raiwidgets | |
run: | | |
sed -i 's/(.\/img\//(https:\/\/raw.githubusercontent.com\/microsoft\/responsible-ai-widgets\/main\/img\//g' README.md | |
cp ./README.md ./${{ env.widgetDirectory }}/ | |
- name: replace README for responsibleai | |
run: | | |
sed -i 's/(.\/img\//(https:\/\/raw.githubusercontent.com\/microsoft\/responsible-ai-widgets\/main\/img\//g' README.md | |
cp ./README.md ./${{ env.raiDirectory }}/ | |
- name: build wheel for raiwidgets | |
shell: bash -l {0} | |
run: python setup.py sdist bdist_wheel | |
working-directory: ${{ env.widgetDirectory }} | |
- name: build wheel for responsibleai | |
shell: bash -l {0} | |
run: python setup.py sdist bdist_wheel | |
working-directory: ${{ env.raiDirectory }} | |
- name: Upload a raiwidgets build result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.widgetDirectory }} | |
path: ${{ env.widgetDirectory }}/dist/ | |
- name: Upload a responsibleai build result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.raiDirectory }} | |
path: ${{ env.raiDirectory }}/dist/ | |
- name: Upload a typescript build result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.typescriptBuildArtifactName }} | |
path: ${{ env.typescriptBuildOutput }} | |
test-unittests: | |
needs: release-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: 3.8 | |
- name: install requirements.txt for raiwidgets | |
shell: bash -l {0} | |
run: pip install -r requirements-dev.txt | |
working-directory: ${{ env.widgetDirectory }} | |
- name: install requirements.txt for responsibleai | |
shell: bash -l {0} | |
run: pip install -r requirements-dev.txt | |
working-directory: ${{ env.raiDirectory }} | |
- id: download_rai_unit | |
name: Download responsibleai wheel | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ env.raiDirectory }} | |
path: ${{ env.raiDirectory }} | |
- id: download_raiwidgets_unit | |
name: Download raiwidgets wheel | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ env.widgetDirectory }} | |
path: ${{ env.widgetDirectory }} | |
- name: install responsibleai wheel locally | |
shell: bash -l {0} | |
run: find ./ -name '*.whl' -exec pip install {} \; | |
working-directory: ${{ env.raiDirectory }} | |
- name: install raiwidgets wheel locally | |
shell: bash -l {0} | |
run: find ./ -name '*.whl' -exec pip install {} \; | |
working-directory: ${{ env.widgetDirectory }} | |
- name: run raiwidgets tests | |
shell: bash -l {0} | |
run: pytest -s -v ./tests/ | |
working-directory: ${{ env.widgetDirectory }} | |
- name: run responsibleai tests | |
shell: bash -l {0} | |
run: pytest -s -v ./tests/ | |
working-directory: ${{ env.raiDirectory }} | |
test-e2e-notebooks: | |
needs: release-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
- name: Install yarn | |
run: | | |
npm install yarn -g | |
- name: install typescript dependencies | |
run: | | |
yarn install --frozen-lock-file | |
- name: build typescript | |
run: | | |
yarn build e2e | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: 3.8 | |
- id: download_rai_e2e | |
name: Download responsibleai wheel | |
uses: actions/download-artifact@v2 | |
with: | |
name: responsibleai | |
path: responsibleai | |
- id: download_raiwidgets_e2e | |
name: Download raiwidgets wheel | |
uses: actions/download-artifact@v2 | |
with: | |
name: raiwidgets | |
path: raiwidgets | |
- name: Install pytorch | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet pytorch torchvision captum cpuonly -c pytorch | |
- name: install requirements.txt for raiwidgets | |
shell: bash -l {0} | |
run: pip install -r requirements-dev.txt | |
working-directory: ${{ env.widgetDirectory }} | |
- name: install responsibleai wheel locally | |
shell: bash -l {0} | |
run: find ./ -name '*.whl' -exec pip install {} \; | |
working-directory: ${{ env.raiDirectory }} | |
- name: install raiwidgets wheel locally | |
shell: bash -l {0} | |
run: find ./ -name '*.whl' -exec pip install {} \; | |
working-directory: ${{ env.widgetDirectory }} | |
- name: Run widget tests without flights | |
shell: bash -l {0} | |
run: | | |
yarn e2e-widget -n "responsibleaidashboard-census-classification-model-debugging" -f "" | |
yarn e2e-widget -n "responsibleaidashboard-diabetes-regression-model-debugging" -f "" | |
yarn e2e-widget -n "responsibleaidashboard-housing-decision-making" -f "" | |
yarn e2e-widget -n "responsibleaidashboard-housing-classification-model-debugging" -f "" | |
yarn e2e-widget -n "responsibleaidashboard-diabetes-decision-making" -f "" | |
yarn e2e-widget -n "responsibleaidashboard-multiclass-dnn-model-debugging" -f "" | |
- name: Upload e2e test screen shot | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: raiwidgets-e2e-screen-shot | |
path: ./dist/cypress | |
release-python: | |
needs: [test-unittests, test-e2e-notebooks] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: [responsibleai, raiwidgets] | |
steps: | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: 3.8 | |
- id: download | |
name: Download a Build Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ matrix.package }} | |
path: ${{ matrix.package }} | |
- name: Publish responsibleai package to Test PyPI | |
if: ${{ github.event.inputs.releaseType == 'Test' && matrix.package == 'responsibleai' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN_RESPONSIBLEAI }} | |
repository_url: https://test.pypi.org/legacy/ | |
packages_dir: ${{steps.download.outputs.download-path}} | |
- name: Publish responsibleai package to Prod PyPI | |
if: ${{ github.event.inputs.releaseType == 'Prod' && matrix.package == 'responsibleai' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN_RESPONSIBLEAI }} | |
packages_dir: ${{steps.download.outputs.download-path}} | |
- name: Publish raiwidgets package to Test PyPI | |
if: ${{ github.event.inputs.releaseType == 'Test' && matrix.package == 'raiwidgets' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN_RAIWIDGETS }} | |
repository_url: https://test.pypi.org/legacy/ | |
packages_dir: ${{steps.download.outputs.download-path}} | |
- name: Publish raiwidgets package to Prod PyPI | |
if: ${{ github.event.inputs.releaseType == 'Prod' && matrix.package == 'raiwidgets' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN_RAIWIDGETS }} | |
packages_dir: ${{steps.download.outputs.download-path}} | |
release-typescript: | |
needs: [test-unittests, test-e2e-notebooks] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: | |
[ | |
core-ui, | |
forecasting, | |
mlchartlib, | |
dataset-explorer, | |
causality, | |
counterfactuals, | |
fairness, | |
interpret, | |
interpret-text, | |
interpret-vision, | |
localization, | |
error-analysis, | |
model-assessment, | |
e2e | |
] | |
steps: | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
- id: download | |
name: Download a Build Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ env.typescriptBuildArtifactName }} | |
path: ${{ env.typescriptBuildOutput }} | |
- id: publish | |
name: NPM Publish | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ${{steps.download.outputs.download-path}}/libs/${{ matrix.package }}/package.json | |
dry-run: ${{github.event.inputs.releaseType == 'Test'}} | |
access: public | |
# tag: next | |
- if: steps.publish.type != 'none' | |
run: | | |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" |