feat: configure performance-metrics to work on robot #7193
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
# This workflow runs tests and lint on branch pushes that touch the | |
# shared-data project or its CI configuration. | |
name: 'shared-data test/lint/deploy' | |
on: | |
push: | |
paths: | |
- 'Makefile' | |
- 'shared-data/*/**' | |
- 'scripts/**/*.mk' | |
- 'scripts/**/*.py' | |
- '.github/workflows/shared-data-test-lint-deploy.yaml' | |
- '.github/actions/python/**/*' | |
- '.github/workflows/utils.js' | |
branches: | |
- 'edge' | |
- 'release' | |
- '*hotfix*' | |
tags: | |
- 'v*' | |
- 'shared-data*' | |
- 'components*' | |
pull_request: | |
paths: | |
- 'Makefile' | |
- 'shared-data/*/**' | |
- 'scripts/**/*.mk' | |
- 'scripts/**/*.py' | |
- '.github/workflows/shared-data-test-lint-deploy.yaml' | |
- '.github/actions/python/**/*' | |
- '.github/workflows/utils.js' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
python-lint: | |
name: 'shared-data package python lint' | |
timeout-minutes: 10 | |
runs-on: 'ubuntu-22.04' | |
steps: | |
- uses: 'actions/checkout@v3' | |
with: | |
fetch-depth: 0 | |
- uses: 'actions/setup-node@v3' | |
with: | |
node-version: '18.19.0' | |
- uses: 'actions/setup-python@v3' | |
with: | |
python-version: '3.10' | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'shared-data/python' | |
- name: Lint | |
run: make -C shared-data/python lint | |
python-test: | |
name: 'shared-data package python ${{ matrix.python }} tests on ${{ matrix.os }}' | |
timeout-minutes: 20 | |
needs: [python-lint] | |
strategy: | |
matrix: | |
os: ['windows-2022', 'ubuntu-22.04', 'macos-latest'] | |
# TODO(mc, 2022-02-24): expand this matrix to 3.8 and 3.9, | |
# preferably in a nightly cronjob on edge or something | |
python: ['3.10'] | |
runs-on: '${{ matrix.os }}' | |
steps: | |
- uses: 'actions/checkout@v3' | |
with: | |
fetch-depth: 0 | |
- name: 'install udev for usb-detection' | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update && sudo apt-get install libudev-dev | |
- uses: 'actions/setup-node@v1' | |
with: | |
node-version: '18.19.0' | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: ${{ matrix.python }} | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'shared-data/python' | |
python-version: ${{ matrix.python }} | |
- name: 'set complex environment variables' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) | |
buildComplexEnvVars(core, context) | |
- name: Test | |
run: make -C shared-data/python test | |
- name: Ensure assets build | |
run: make -C shared-data/python sdist wheel | |
- name: 'Upload coverage report' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./shared-data/python/coverage.xml | |
flags: shared-data | |
js-test: | |
name: 'shared-data JS tests' | |
runs-on: 'ubuntu-22.04' | |
timeout-minutes: 30 | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: 'actions/setup-node@v3' | |
with: | |
node-version: '18.19.0' | |
- name: 'install udev' | |
run: | | |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update && sudo apt-get install libudev-dev | |
- name: 'cache yarn cache' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/.yarn-cache | |
${{ github.workspace }}/.npm-cache | |
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn- | |
- name: 'js deps' | |
run: | | |
npm config set cache ./.npm-cache | |
yarn config set cache-folder ./.yarn-cache | |
make setup-js | |
- name: 'run shared-data JS unit tests' | |
run: make -C shared-data test-cov | |
- name: 'Upload coverage report' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage/lcov.info | |
flags: shared-data | |
python-deploy: | |
name: 'shared-data package deploy' | |
needs: [python-test] | |
runs-on: 'ubuntu-22.04' | |
if: github.event_name == 'push' | |
steps: | |
- uses: 'actions/checkout@v3' | |
with: | |
fetch-depth: 0 | |
# https://github.com/actions/checkout/issues/290 | |
- name: 'Fix actions/checkout odd handling of tags' | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
git checkout ${{ github.ref }} | |
- uses: 'actions/setup-node@v3' | |
with: | |
node-version: '18.19.0' | |
- name: 'install udev for usb-detection' | |
run: | | |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update && sudo apt-get install libudev-dev | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: '3.10' | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'shared-data/python' | |
- name: 'set complex environment variables' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) | |
buildComplexEnvVars(core, context) | |
# creds and repository configuration for deploying python wheels | |
- if: ${{ !env.OT_TAG }} | |
name: 'upload to test pypi' | |
uses: './.github/actions/python/pypi-deploy' | |
with: | |
project: 'shared-data/python' | |
repository_url: 'https://test.pypi.org/legacy/' | |
password: '${{ secrets.TEST_PYPI_DEPLOY_TOKEN_OPENTRONS_SHARED_DATA }}' | |
- if: startsWith(env.OT_TAG, 'v') | |
name: 'upload to pypi' | |
uses: './.github/actions/python/pypi-deploy' | |
with: | |
project: 'shared-data/python' | |
repository_url: 'https://upload.pypi.org/legacy/' | |
password: '${{ secrets.PYPI_DEPLOY_TOKEN_OPENTRONS_SHARED_DATA }}' | |
publish-switch: | |
runs-on: 'ubuntu-latest' | |
name: 'Determine whether or not to publish artifacts' | |
outputs: | |
should_publish: ${{steps.publish-switch.outputs.should_publish}} | |
steps: | |
- id: publish-switch | |
run: | | |
echo "Determining whether to publish artifacts for event ${{github.event_type}} and ref ${{github.ref}}" | |
if [ "${{ format('{0}', startsWith(github.ref, 'refs/tags/shared-data')) }}" = "true" ] ; then | |
echo "Publishing builds for shared-data@ tags" | |
echo 'should_publish=true' >> $GITHUB_OUTPUT | |
elif [ "${{ format('{0}', startsWith(github.ref, 'refs/tags/components')) }}" = "true" ] ; then | |
echo "Publishing builds for components@ tags" | |
echo 'should_publish=true' >> $GITHUB_OUTPUT | |
else | |
echo "No publish for ref ${{github.ref}} and event ${{github.event_type}}" | |
echo 'should_publish=false' >> $GITHUB_OUTPUT | |
fi | |
publish-to-npm: | |
name: 'publish shared-data package to npm' | |
runs-on: 'ubuntu-latest' | |
needs: ['js-test', 'publish-switch'] | |
if: needs.publish-switch.outputs.should_publish == 'true' | |
steps: | |
- uses: 'actions/checkout@v3' | |
# https://github.com/actions/checkout/issues/290 | |
- name: 'Fix actions/checkout odd handling of tags' | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
git checkout ${{ github.ref }} | |
- uses: 'actions/setup-node@v3' | |
with: | |
node-version: '18.19.0' | |
registry-url: 'https://registry.npmjs.org' | |
- name: 'install udev for usb-detection' | |
run: | | |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update && sudo apt-get install libudev-dev | |
- name: 'cache yarn cache' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/.yarn-cache | |
${{ github.workspace }}/.npm-cache | |
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn- | |
- name: 'js deps' | |
run: | | |
npm config set cache ./.npm-cache | |
yarn config set cache-folder ./.yarn-cache | |
make setup-js | |
- name: 'build typescript' | |
run: make build-ts | |
- name: 'build library' | |
run: | | |
make -C shared-data lib-js | |
# replace package.json stub version number with version from tag | |
- name: 'set version number' | |
run: | | |
npm install -g json | |
VERSION_STRING=$(echo ${{ github.ref }} | sed -E 's/refs\/tags\/(components|shared-data)@//') | |
json -I -f ./shared-data/package.json -e "this.version=\"$VERSION_STRING\"" | |
cd ./shared-data | |
- uses: 'actions/setup-node@v3' | |
with: | |
node-version: '18.19.0' | |
registry-url: 'https://registry.npmjs.org' | |
- name: 'publish to npm registry' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
cd ./shared-data && echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ./.npmrc && npm publish --access public |