Skip to content

better cache

better cache #25003

# Run tests, build PD, and deploy it to sandbox
name: 'PD test, build, and deploy'
on:
pull_request:
paths:
- 'protocol-designer/**'
- 'step-generation/**'
- 'shared-data/**'
- 'components/**'
- 'package.json'
- '.github/workflows/pd-test-build-deploy.yaml'
- '.github/actions/container/ci/action.yaml'
push:
paths:
- 'protocol-designer/**'
- 'step-generation/**'
- 'shared-data/**'
- 'components/**'
- 'package.json'
- '.github/workflows/pd-test-build-deploy.yaml'
- '.github/actions/container/ci/action.yaml'
branches:
- '**'
tags:
- 'protocol-designer*'
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
env:
CI: true
jobs:
setup:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Container
id: container
uses: ./.github/actions/container/ci
with:
git_ref: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
js-unit-test:
needs: setup
runs-on: 'ubuntu-22.04'
steps:
- name: 'Run tests and generate coverage'
run: |
docker run --rm --tty \
--env CI=${{ env.CI }} \
-v $PWD/coverage:/coverage \
ghcr.io/opentrons/opentrons-ci:${{ github.ref_name }} \
make -C protocol-designer test-cov
- name: 'Upload coverage report'
uses: codecov/codecov-action@v3
with:
directory: ./coverage
flags: protocol-designer
# e2e-test:
# name: 'pd e2e tests'
# needs: ['js-unit-test']
# timeout-minutes: 30
# strategy:
# matrix:
# os: ['ubuntu-22.04']
# runs-on: '${{ matrix.os }}'
# steps:
# - uses: 'actions/checkout@v4'
# 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@v4'
# with:
# node-version: '22.11.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
# - 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: 'setup-js'
# run: |
# npm config set cache ./.npm-cache
# yarn config set cache-folder ./.yarn-cache
# make setup-js
# - name: 'test-e2e'
# run: make -C protocol-designer test-e2e
# build-pd:
# name: 'build protocol designer artifact'
# needs: ['js-unit-test']
# runs-on: 'ubuntu-22.04'
# if: github.event_name != 'pull_request'
# steps:
# - uses: 'actions/checkout@v4'
# 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@v4'
# with:
# node-version: '22.11.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
# - 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') }}
# - name: 'setup-js'
# run: |
# npm config set cache ./.npm-cache
# yarn config set cache-folder ./.yarn-cache
# make setup-js
# - name: 'build PD'
# env:
# OT_PD_MIXPANEL_ID: ${{ secrets.OT_PD_MIXPANEL_ID }}
# OT_PD_MIXPANEL_DEV_ID: ${{ secrets.OT_PD_MIXPANEL_DEV_ID }}
# run: |
# make -C protocol-designer NODE_ENV=development
# - name: 'upload github artifact'
# uses: actions/upload-artifact@v4
# with:
# name: 'pd-artifact'
# path: protocol-designer/dist
# deploy-pd:
# name: 'deploy PD artifact to S3'
# runs-on: 'ubuntu-22.04'
# needs: ['js-unit-test', 'build-pd']
# if: github.event_name != 'pull_request'
# steps:
# - uses: 'actions/checkout@v4'
# # 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@v4'
# with:
# node-version: '22.11.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
# - name: 'set complex environment variables'
# id: 'set-vars'
# uses: actions/github-script@v6
# with:
# script: |
# const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
# buildComplexEnvVars(core, context)
# - name: 'download PD build'
# uses: 'actions/download-artifact@v4'
# with:
# name: pd-artifact
# path: ./dist
# - name: 'configure ot3 s3 deploy creds and deploy'
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.PD_S3_SANDBOX_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.PD_S3_SANDBOX_SECRET }}
# AWS_DEFAULT_REGION: us-east-1
# run: |
# aws configure set aws_access_key_id ${{ secrets.PD_S3_SANDBOX_KEY_ID }} --profile identity
# aws configure set aws_secret_access_key ${{ secrets.PD_S3_SANDBOX_SECRET }} --profile identity
# aws configure set region us-east-2 --profile identity
# aws configure set output json --profile identity
# aws configure set region us-east-2 --profile deploy
# aws configure set role_arn ${{ secrets.OT_PD_DEPLOY_ROLE }} --profile deploy
# aws configure set source_profile identity --profile deploy
# aws s3 sync ./dist s3://sandbox.designer.opentrons.com/${{ env.OT_BRANCH }} --acl=public-read --profile=deploy
# # invalidate both sandbox.opentrons.com and www.sandbox.opentrons.com cloudfront caches
# aws cloudfront create-invalidation --distribution-id ${{ secrets.PD_CLOUDFRONT_SANDBOX_DISTRIBUTION_ID }} --paths "/*" --profile deploy
# aws cloudfront create-invalidation --distribution-id ${{ secrets.PD_CLOUDFRONT_SANDBOX_WWW_DISTRIBUTION_ID }} --paths "/*" --profile deploy
# shell: bash