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

chore(build): switch to github workflows for robot stack CI #6632

Merged
merged 21 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
40 changes: 40 additions & 0 deletions .github/actions/python/pypi-deploy/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Deploy wheel to pypi'
description: 'Deploy a python wheel to pypi or test pypi, depending on configuration. The python environment for the subproject must be set up already, and the complex environment variables must be defined.'
inputs:
project:
description: 'Which project to run make deploy in'
required: true
repository_url:
description: 'The repository url to upload to. Creds will be determined based on this'
required: true
password:
description: 'The repository password'
runs:
using: 'composite'
steps:
- shell: bash
run: |
echo "::add-mask::${{ inputs.password }}"
if [[ ${{ inputs.repository_url }} =~ "test" ]]; then
echo '::set-env name=SWALLOW_FAILURE::|| echo "Duplicate upload allowed on test"'
echo "Uploading to test pypi"
else if [[ ${{ inputs.repository_url }} =~ "upload.pypi.org" ]]; then
echo "Uploading to prod pypi"
# this needs to be cleared otherwise the makefiles append a dev tag
echo ::set-env name=OT_BUILD::""
else
echo "::error ::Invalid repository url ${{ inputs.repository_url }}"
exit 1
fi
fi


- shell: bash
run: |
status=0
QUIET=1 BUILD_NUMBER=${OT_BUILD} make -C ${{ inputs.project }} clean deploy twine_repository_url=${{ inputs.repository_url }} pypi_username=opentrons pypi_password=${{ inputs.password }} || status=$?
if [[ ${status} != 0 ]] && [[ ${{ inputs.repository_url }} =~ "test.pypi.org" ]]; then
echo "upload failures allowed to test pypi"
exit 0
fi
exit ${status}
7 changes: 4 additions & 3 deletions .github/actions/webstack/deploy-to-sandbox/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ inputs:
distPath:
description: 'The path to the compiled distribution to upload'
required: true
destPrefix:
description: 'The path prefix to deploy to (usually the current branch)'
required: true
runs:
using: 'composite'
steps:
- shell: bash
run: |
SHORTSLUG=`echo ${{ github.ref }} | sed -e "s/^\/\?refs\/\(?:tags\|heads\)\///"`
echo "Found ref slug ${SHORTSLUG} from ref ${{ github.ref }}"
aws s3 sync ${{ inputs.distPath }} s3://sandbox.${{ inputs.domain }}/${SHORTSLUG} --acl=public-read
aws s3 sync ${{ inputs.distPath }} s3://sandbox.${{ inputs.domain }}/${{ inputs.destPrefix }} --acl=public-read
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to switching PD, we will need to confirm that this is successfully uploading dotfiles in distPath to S3, which is behavior PD relies on

38 changes: 32 additions & 6 deletions .github/workflows/api-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ on:
- 'Makefile'
- 'shared-data/*/**'
- '!shared-data/js/**'
- '.github/workflows/api-push.yaml'
- '.github/actions/python/**'
branches-ignore: # ignore any release-related thing (handled elsewhere)
- 'master'
- 'chore_release-*'
tags-ignore:
- '.github/workflows/api-lint-test.yaml'
- '.github/actions/python/**/*'
- '.github/workflows/utils.js'
branches:
- '*'
tags:
- 'v*'
workflow_dispatch:


Expand Down Expand Up @@ -64,8 +64,34 @@ jobs:
- uses: 'actions/setup-python@v2'
with:
python-version: '3.7'
- name: 'set complex environment variables'
uses: actions/github-script@v2
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- uses: './.github/actions/python/setup'
with:
project: 'api'
- name: Test
run: make -C api test
- if: contains(matrix.os, 'ubuntu')
mcous marked this conversation as resolved.
Show resolved Hide resolved
uses: 'codecov/codecov-action@v1'
with:
file: ./api/coverage.xml

# creds and repository configuration for deploying python wheels
- if: contains(matrix.os, 'ubuntu') && (github.event_name == 'push') && !env.OT_TAG
mcous marked this conversation as resolved.
Show resolved Hide resolved
name: 'upload to test pypi'
uses: './.github/actions/python/pypi-deploy'
with:
project: 'api'
repository_url: 'https://test.pypi.org/legacy/'
password: '${{ secrets.OT_TEST_PYPI_PASSWORD }}'
- if: contains(matrix.os, 'ubuntu') && (github.event_name == 'push') && startsWith(env.OT_TAG, 'v')
name: 'upload to real pypi'
uses: './.github/actions/python/pypi-deploy'
with:
project: 'api'
repository_url: 'https://upload.pypi.org/legacy/'
password: '${{ secrets.OT_PYPI_PASSWORD }}'
142 changes: 142 additions & 0 deletions .github/workflows/app-test-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Run tests, build the app, and deploy it cross platform

name: 'App test, build, and deploy'

on:
push:
paths:
- 'app/**/*'
- 'app-shell/**/*'
- 'components/**/*'
- 'shared-data/**/*'
- 'webpack-config/**/*'
- 'discovery-client/**/*'
- '*.js'
- 'scripts/**/*'
- '*.json'
- 'yarn.lock'
- '.github/workflows/app-test-build.yaml'
- '.github/workflows/utils.js'
branches:
- '*'
tags:
- 'v*'
pull_request:
paths:
- 'app/**/*'
- 'app-shell/**/*'
- 'components/**/*'
- 'shared-data/**/*'
- 'webpack-config/**/*'
- 'discovery-client/**/*'
- '*.js'
- '*.json'
- 'yarn.lock'
- 'scripts/**/*'
workflow_dispatch:

#defaults:
# run:
# shell: bash

env:
CI: true
OT_APP_DEPLOY_BUCKET: opentrons-app
OT_APP_DEPLOY_FOLDER: builds-actions # Not the actual deploy target - change when we cut over

jobs:
js-unit-test:
# unit tests for js frontend projects (e.g. not app-shell or discovery-client) do not need
# to run cross-platform
runs-on: 'ubuntu-latest'
name: 'opentrons app frontend unit tests'
steps:
- uses: 'actions/checkout@v2'
- uses: 'actions/setup-node@v1'
with:
node-version: '12'
- name: 'set complex environment variables and get yarn cache'
id: 'set-vars-get-cache'
uses: actions/github-script@v2
with:
script: |
const { buildComplexEnvVars, findYarnCacheDir } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
findYarnCacheDir(core, context)
mcous marked this conversation as resolved.
Show resolved Hide resolved
- name: 'cache yarn cache'
uses: actions/cache@v2
with:
path: ${{ steps.set-vars-get-cache.outputs.yarnCacheDir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
Copy link
Member

@shlokamin shlokamin Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, instead of grabbing the global yarn cache from your util, why not just have a step that sets the cache directory like here?

Also, I don't see where behavior changes when there's a cache hit, you're still going to do a yarn from inside of setup-js even if there's a cache hit right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but that should prevent yarn from redownloading everything shouldn't it?

In terms of why put it in a file, it accomplishes essentially the same thing and the file really had to be there for the custom env vars so I built it in anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but that should prevent yarn from redownloading everything shouldn't it?

Ah yeah that makes sense. Is it working as expected now? Speaking of which, how are you validating that this works? I assume just looking through the action logs and making sure yarn doesn't redownload everything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: 'setup-js'
run: 'make setup-js'
- name: 'test frontend packages'
run: |
yarn jest --coverage=true --ci=true --testPathIgnorePatterns 'labware-.*' 'protocol-.*' 'app-shell' 'discovery-client'

build-app-test-backend:
# since js tests for "backend" projects (app-shell, discovery-client) need
# to run cross-platform just like builds, might as well do them in the same job
strategy:
matrix:
os: ['windows-latest', 'ubuntu-latest', 'macos-latest']
name: 'opentrons app backend unit tests and build'
runs-on: ${{ matrix.os }}
steps:
- uses: 'actions/checkout@v2'
- uses: 'actions/setup-node@v1'
with:
node-version: '12'
- name: 'set complex environment variables and get yarn cache'
id: 'set-vars-get-cache'
uses: actions/github-script@v2
with:
script: |
const { buildComplexEnvVars, findYarnCacheDir } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
findYarnCacheDir(core, context)
- name: 'cache yarn cache'
mcous marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/cache@v2
with:
path: ${{ steps.set-vars-get-cache.outputs.yarnCacheDir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 'setup-js'
run: 'make setup-js'
- name: 'test native(er) packages'
run: |
yarn jest --coverage=true --ci=true --testPathPattern '(app-shell|discovery-client)'
- if: contains(matrix.os, 'ubuntu')
mcous marked this conversation as resolved.
Show resolved Hide resolved
uses: 'codecov/codecov-action@v1'
with:
file: coverage.xml
mcous marked this conversation as resolved.
Show resolved Hide resolved
# build the app and deploy it
- if: github.event_name != 'pull_request'
name: 'build app for ${{ matrix.os }}'
mcous marked this conversation as resolved.
Show resolved Hide resolved
env:
OT_APP_MIXPANEL_ID: ${{ secrets.OT_APP_MIXPANEL_ID }}
OT_APP_INTERCOM_ID: ${{ secrets.OT_APP_INTERCOM_ID }}
WIN_CSC_LINK: ${{ secrets.OT_APP_CSC_WINDOWS }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_WINDOWS }}
CSC_LINK: ${{ secrets.OT_APP_CSC_MACOS }}
CSC_KEY_PASSWORD: ${{ secrets.OT_APP_CSC_KEY_MACOS }}
APPLE_ID: ${{ secrets.OT_APP_APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.OT_APP_APPLE_ID_PASSWORD }}
run: |
make -C app-shell dist-${{ matrix.os }}
- if: github.event_name != 'pull_request'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_APP_DEPLOY_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_APP_DEPLOY_SECRET }}
AWS_DEFAULT_REGION: us-east-2
name: 'deploy'
run: aws s3 sync --acl=public-read app-shell/dist/publish s3://${{ env.OT_APP_DEPLOY_BUCKET }}/${{ env.OT_APP_DEPLOY_FOLDER }}
- if: github.event_name != 'pull_request'
name: 'upload github artifact'
uses: actions/upload-artifact@v2
with:
name: 'opentrons app for ${{ matrix.os }}'
path: app-shell/dist/publish
8 changes: 8 additions & 0 deletions .github/workflows/docs-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- '.github/workflows/docs-build.yaml'
- '.github/actions/python/**'
- '.github/actions/webstack/deploy-to-sandbox/**'
- '.github/workflows/utils.js'
branches-ignore: # ignore any release-related thing (handled elsewhere)
- 'master'
- 'chore_release-**'
Expand All @@ -38,6 +39,12 @@ jobs:
- uses: './.github/actions/python/setup'
with:
project: 'api'
- name: 'set complex environment variables'
uses: actions/github-script@v2
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'Setup Docs'
run: sudo apt-get install -y --no-install-recommends texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra dvipng texlive-latex-recommended libsystemd-dev latexmk texlive-lang-greek
- name: 'Build docs'
Expand All @@ -51,3 +58,4 @@ jobs:
with:
domain: 'docs.opentrons.com'
distPath: './api/docs/dist'
destPrefix: ${{ env.OT_BRANCH }}
15 changes: 15 additions & 0 deletions .github/workflows/js-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ jobs:
- uses: 'actions/setup-node@v1'
with:
node-version: '12'
- name: 'set complex environment variables and get yarn cache'
id: 'set-vars-get-cache'
uses: actions/github-script@v2
with:
script: |
const { buildComplexEnvVars, findYarnCacheDir } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
findYarnCacheDir(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v2
with:
path: ${{ steps.set-vars-get-cache.outputs.yarnCacheDir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 'setup-js'
run: make setup-js
- name: 'lint js'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/robot-server-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ jobs:
run: make -C robot-server lint
- name: Test
run: make -C robot-server test
- uses: 'codecov/codecov-action@v1'
with:
file: ./robot-server/coverage.xml
32 changes: 26 additions & 6 deletions .github/workflows/shared-data-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
paths:
- 'Makefile'
- 'shared-data/*/**'
- '.github/workflows/shared-data-pull-request-target.yaml'
- '.github/actions/python/**'
branches-ignore: # ignore any release-related thing (handled elsewhere)
- 'master'
- 'chore_release-**'
tags-ignore:
- '.github/workflows/shared-data-lint-test.yaml'
- '.github/actions/python/**/*'
- '.github/workflows/utils.js'
branches:
- '*'
tags:
- 'v*'
pull_request:
paths:
- 'Makefile'
Expand Down Expand Up @@ -61,5 +61,25 @@ jobs:
- uses: './.github/actions/python/setup'
with:
project: 'shared-data/python'
- name: 'set complex environment variables'
uses: actions/github-script@v2
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
# creds and repository configuration for deploying python wheels
- if: contains(matrix.os, 'ubuntu') && (github.event_name == 'push') && !env.OT_TAG
mcous marked this conversation as resolved.
Show resolved Hide resolved
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.OT_TEST_PYPI_PASSWORD }}'
- if: contains(matrix.os, 'ubunut') && (github.event_name == 'push') && startsWith(env.OT_TAG, 'v')
name: 'upload to pypi'
uses: './.github/actions/python/pypi-deploy'
with:
proejct: 'shared-data/python'
repository_url: 'https://upload.pypi.org/legacy/'
3 changes: 3 additions & 0 deletions .github/workflows/update-server-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ jobs:
project: 'update-server'
- name: Test
run: make -C update-server test
- uses: 'codecov/codecov-action@v1'
with:
file: ./update-server/coverage.xml
Loading