Skip to content

Commit

Permalink
Merge branch 'edge' into chore_update-vite-version-53
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Jul 26, 2024
2 parents 7870a63 + 2f590fe commit a9dde42
Show file tree
Hide file tree
Showing 410 changed files with 29,043 additions and 2,196 deletions.
148 changes: 95 additions & 53 deletions .github/workflows/analyses-snapshot-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ on:
description: 'Branch or tag that provides the snapshot and test code at test runtime'
required: true
default: 'edge'
OPEN_PR_ON_FAILURE:
description: 'If the test fails, open a PR to update the snapshots'
type: boolean
required: true
default: false
schedule:
- cron: '26 7 * * *' # 7:26 AM UTC
- cron: '26 7 * * *' # 7:26 AM UTC
pull_request:
paths:
- 'api/**'
- '!api/tests/**'
- '!api/docs/**'
- '!api/release-notes-internal.md'
- '!api/release-notes.md'
- 'shared-data/**/*'
- '!shared-data/js/**'
- '.github/workflows/analyses-snapshot-test.yaml'
- 'analyses-snapshot-testing/**'

types:
- opened #default
- synchronize #default
- reopened #default
- labeled

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -32,66 +47,93 @@ jobs:
env:
ANALYSIS_REF: ${{ github.event.inputs.ANALYSIS_REF || github.head_ref || 'edge' }}
SNAPSHOT_REF: ${{ github.event.inputs.SNAPSHOT_REF || github.head_ref || 'edge' }}

# If we're running because of workflow_dispatch, use the user input to decide
# whether to open a PR on failure. Otherwise, there is no user input, so always
# open a PR on failure.
OPEN_PR_ON_FAILURE: ${{ (github.event_name == 'workflow_dispatch' && github.events.inputs.OPEN_PR_ON_FAILURE) || ((github.event_name != 'workflow_dispatch') && (contains(github.event.pull_request.labels.*.name, 'gen-analyses-snapshot-pr'))) }}
PR_TARGET_BRANCH: ${{ github.event.pull_request.base.ref || 'not a pr'}}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.SNAPSHOT_REF }}
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.SNAPSHOT_REF }}

- name: Are the analyses snapshots in my PR branch in sync with the target branch?
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ env.PR_TARGET_BRANCH }}
DIFF_OUTPUT=$(git diff HEAD origin/${{ env.PR_TARGET_BRANCH }} -- analyses-snapshot-testing/tests/__snapshots__/analyses_snapshot_test)
if [ -n "$DIFF_OUTPUT" ]; then
echo "Analyses snapshots do NOT match ${{ env.PR_TARGET_BRANCH }} snapshots."
echo "Is this becasue you have not pulled and merged ${{ env.PR_TARGET_BRANCH }}?"
echo "Or is this because you have already updated your snapshots and are all good 😊?"
else
echo "Analyses snapshots match ${{ env.PR_TARGET_BRANCH }} snapshots."
fi
- name: Docker Build
working-directory: analyses-snapshot-testing
run: make build-opentrons-analysis
- name: Docker Build
working-directory: analyses-snapshot-testing
run: make build-opentrons-analysis

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pipenv'
cache-dependency-path: analyses-snapshot-testing/Pipfile.lock
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pipenv'
cache-dependency-path: analyses-snapshot-testing/Pipfile.lock

- name: Setup Python Dependencies
working-directory: analyses-snapshot-testing
run: make setup
- name: Setup Python Dependencies
working-directory: analyses-snapshot-testing
run: make setup

- name: Run Test
id: run_test
working-directory: analyses-snapshot-testing
run: make snapshot-test
- name: Run Test
id: run_test
working-directory: analyses-snapshot-testing
run: make snapshot-test

- name: Upload Report
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: test-report
path: analyses-snapshot-testing/results/
- name: Upload Report
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: test-report
path: analyses-snapshot-testing/results/

- name: Handle Test Failure
id: handle_failure
if: always() && steps.run_test.outcome == 'failure'
working-directory: analyses-snapshot-testing
run: make snapshot-test-update
- name: Handle Test Failure
id: handle_failure
if: always() && steps.run_test.outcome == 'failure' && (env.OPEN_PR_ON_FAILURE == 'true' || github.event_name == 'schedule')
working-directory: analyses-snapshot-testing
run: make snapshot-test-update

- name: Create Snapshot update Request
id: create_pull_request
if: always() && steps.handle_failure.outcome == 'success'
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'fix(analyses-snapshot-testing): snapshot failure capture'
title: 'fix(analyses-snapshot-testing): ${{ env.ANALYSIS_REF }} snapshot failure capture'
body: 'This PR is an automated snapshot update request. Please review the changes and merge if they are acceptable or find your bug and fix it.'
- name: Create Snapshot update Request
id: create_pull_request
if: always() && steps.handle_failure.outcome == 'success' && env.OPEN_PR_ON_FAILURE == 'true' && github.event_name == 'pull_request'
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'fix(analyses-snapshot-testing): heal analyses snapshots'
title: 'fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
body: 'This PR was requested on the PR https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
branch: 'analyses-snapshot-testing/${{ env.ANALYSIS_REF }}-from-${{ env.SNAPSHOT_REF}}'
base: ${{ env.SNAPSHOT_REF}}

- name: Comment on PR
if: always() && steps.create_pull_request.outcome == 'success' && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const message = 'A PR has been opened to address analyses snapshot changes. Please review the changes here: https://github.com/${{ github.repository }}/pull/${{ steps.create-pull-request.outputs.pull-request-number }}';
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});
- name: Comment on feature PR
if: always() && steps.create_pull_request.outcome == 'success' && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const message = 'A PR has been opened to address analyses snapshot changes. Please review the changes here: https://github.com/${{ github.repository }}/pull/${{ steps.create_pull_request.outputs.pull-request-number }}';
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});
- name: Create Snapshot update Request on edge overnight failure
if: always() && steps.handle_failure.outcome == 'success' && github.event_name == 'schedule'
uses: peter-evans/create-pull-request@v6
with: # scheduled run uses the default values for ANALYSIS_REF and SNAPSHOT_REF which are edge
commit-message: 'fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
title: 'fix(analyses-snapshot-testing): heal ${{ env.ANALYSIS_REF }} snapshots'
body: 'The ${{ env.ANALYSIS_REF }} overnight analyses snapshot test is failing. This PR was opened to alert us to the failure.'
branch: 'analyses-snapshot-testing/${{ env.ANALYSIS_REF }}-from-${{ env.SNAPSHOT_REF}}'
base: ${{ env.SNAPSHOT_REF}}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ HARDWARE_DIR := hardware
USB_BRIDGE_DIR := usb-bridge
NODE_USB_BRIDGE_CLIENT_DIR := usb-bridge/node-client

PYTHON_DIRS := $(API_DIR) $(UPDATE_SERVER_DIR) $(ROBOT_SERVER_DIR) $(SERVER_UTILS_DIR) $(SHARED_DATA_DIR)/python $(SYSTEM_SERVER_DIR) $(G_CODE_TESTING_DIR) $(HARDWARE_DIR) $(USB_BRIDGE_DIR)
PYTHON_DIRS := $(API_DIR) $(UPDATE_SERVER_DIR) $(ROBOT_SERVER_DIR) $(SERVER_UTILS_DIR) $(SHARED_DATA_DIR)/python $(G_CODE_TESTING_DIR) $(HARDWARE_DIR) $(USB_BRIDGE_DIR)

# This may be set as an environment variable (and is by CI tasks that upload
# to test pypi) to add a .dev extension to the python package versions. If
Expand Down
17 changes: 14 additions & 3 deletions abr-testing/abr_testing/data_collection/abr_robot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,20 @@ def compare_lpc_to_historical_data(
current_x = round(labware_dict["X"], 2)
current_y = round(labware_dict["Y"], 2)
current_z = round(labware_dict["Z"], 2)
avg_x = round(mean(x_float), 2)
avg_y = round(mean(y_float), 2)
avg_z = round(mean(z_float), 2)
try:
avg_x = round(mean(x_float), 2)
avg_y = round(mean(y_float), 2)
avg_z = round(mean(z_float), 2)
except StatisticsError:
# If there is one value assign it as the average.
if len(x_float) == 1:
avg_x = x_float[0]
avg_y = y_float[0]
avg_z = z_float[0]
else:
avg_x = None
avg_y = None
avg_z = None

# Formats LPC message for ticket.
lpc_message = (
Expand Down
12 changes: 12 additions & 0 deletions analyses-snapshot-testing/automation/data/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@ class Protocols:
robot="Flex",
)

Flex_S_v2_19_P1000_96_GRIP_HS_MB_TC_TM_Smoke: Protocol = Protocol(
file_stem="Flex_S_v2_19_P1000_96_GRIP_HS_MB_TC_TM_Smoke",
file_extension="py",
robot="Flex",
)

OT2_X_v2_18_None_None_duplicateRTPVariableName: Protocol = Protocol(
file_stem="OT2_X_v2_18_None_None_duplicateRTPVariableName",
file_extension="py",
Expand Down Expand Up @@ -665,6 +671,12 @@ class Protocols:
robot="OT2",
)

OT2_S_v2_19_P300M_P20S_HS_TC_TM_SmokeTestV3: Protocol = Protocol(
file_stem="OT2_S_v2_19_P300M_P20S_HS_TC_TM_SmokeTestV3",
file_extension="py",
robot="OT2",
)

##########################################################################################################
# Begin Protocol Library Protocols #######################################################################
##########################################################################################################
Expand Down
Loading

0 comments on commit a9dde42

Please sign in to comment.