update #31
This file contains hidden or 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: API Checks (CI Docker) | |
| on: | |
| pull_request: | |
| paths: | |
| - 'api/**' | |
| - 'Makefile' | |
| - 'shared-data/**' | |
| - '!shared-data/js/**' | |
| - 'hardware/**' | |
| - 'scripts/**.mk' | |
| - 'scripts/**.py' | |
| - '.github/workflows/ci-docker-api.yaml' | |
| - '.github/workflows/utils.js' | |
| push: | |
| branches: | |
| - edge | |
| - chore_release* | |
| - ci-docker/** | |
| workflow_dispatch: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| select-image: | |
| name: Determine container tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.tag.outputs.tag }} | |
| steps: | |
| - name: Checkout utilities | |
| uses: 'actions/checkout@v4' | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| ci-docker | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Determine container tag | |
| id: tag | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| BASE_REF: ${{ github.base_ref }} | |
| REF_NAME: ${{ github.ref_name }} | |
| DEFAULT_TAG: ci-docker-init | |
| RELEASE_PREFIX: chore_release | |
| working-directory: ci-docker | |
| run: make determine-container-tag | |
| lint: | |
| name: API lint (CI Docker) | |
| needs: select-image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| OT_REPO_CACHE: /opt/opentrons | |
| HOME: /home/ci | |
| container: | |
| image: ghcr.io/opentrons/ci-bootstrap:${{ needs.select-image.outputs.tag }} | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| options: --init | |
| steps: | |
| - name: Confirm container tag | |
| run: echo "Using image ghcr.io/opentrons/ci-bootstrap:${{ needs.select-image.outputs.tag }}" | |
| - name: Prepare output file permissions | |
| run: | | |
| sudo mkdir -p "$(dirname "$GITHUB_OUTPUT")" | |
| sudo touch "$GITHUB_OUTPUT" | |
| sudo chmod 666 "$GITHUB_OUTPUT" | |
| sudo mkdir -p "$(dirname "$GITHUB_PATH")" | |
| sudo touch "$GITHUB_PATH" | |
| sudo chmod 666 "$GITHUB_PATH" | |
| - name: Ensure summary path writable | |
| run: | | |
| sudo mkdir -p "$(dirname "$GITHUB_STEP_SUMMARY")" | |
| sudo touch "$GITHUB_STEP_SUMMARY" | |
| sudo chown $(whoami):$(whoami) "$GITHUB_STEP_SUMMARY" "$(dirname "$GITHUB_STEP_SUMMARY")" | |
| - name: Configure Git access | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: | | |
| git -C "$OT_REPO_CACHE" remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/Opentrons/opentrons.git" | |
| - name: Update cached repository | |
| env: | |
| TARGET_REF: ${{ github.ref }} | |
| TARGET_SHA: ${{ github.sha }} | |
| run: | | |
| cd "$OT_REPO_CACHE" | |
| git fetch --no-tags --prune origin "$TARGET_REF" --depth=1 || git fetch --no-tags origin "$TARGET_SHA" --depth=1 | |
| git checkout --force "$TARGET_SHA" | |
| - name: Check dependency drift | |
| id: deps | |
| working-directory: ${{ env.OT_REPO_CACHE }}/ci-docker | |
| run: make check-dependency-drift | |
| - name: Refresh dependencies when manifests change | |
| if: steps.deps.outputs.dependencies_changed == 'true' | |
| working-directory: ${{ env.OT_REPO_CACHE }} | |
| run: | | |
| make teardown | |
| make setup | |
| make -C ci-docker dependency-checksums OUTPUT="$OT_REPO_CACHE/.ci-dependency-checksums.json" TITLE="Updated Dependency Checksums" | |
| - name: Run lint | |
| working-directory: ${{ env.OT_REPO_CACHE }} | |
| run: make -C api lint | |
| - name: Summarize lint | |
| if: always() | |
| env: | |
| DEPENDENCIES_CHANGED: ${{ steps.deps.outputs.dependencies_changed || 'false' }} | |
| run: | | |
| echo "## API Lint (CI Docker)" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Image tag: \`${{ needs.select-image.outputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Outcome: \`${{ job.status }}\`" >> "$GITHUB_STEP_SUMMARY" | |
| if [ "$DEPENDENCIES_CHANGED" = "true" ]; then | |
| echo "- Dependencies refreshed: ✅" >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "- Dependencies refreshed: ❌" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| api-tests: | |
| name: API tests (CI Docker) | |
| needs: select-image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| OT_REPO_CACHE: /opt/opentrons | |
| HOME: /home/ci | |
| container: | |
| image: ghcr.io/opentrons/ci-bootstrap:${{ needs.select-image.outputs.tag }} | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| options: --init | |
| steps: | |
| - name: Confirm container tag | |
| run: echo "Using image ghcr.io/opentrons/ci-bootstrap:${{ needs.select-image.outputs.tag }}" | |
| - name: Prepare output file permissions | |
| run: | | |
| sudo mkdir -p "$(dirname "$GITHUB_OUTPUT")" | |
| sudo touch "$GITHUB_OUTPUT" | |
| sudo chmod 666 "$GITHUB_OUTPUT" | |
| sudo mkdir -p "$(dirname "$GITHUB_PATH")" | |
| sudo touch "$GITHUB_PATH" | |
| sudo chmod 666 "$GITHUB_PATH" | |
| - name: Ensure summary path writable | |
| run: | | |
| sudo mkdir -p "$(dirname "$GITHUB_STEP_SUMMARY")" | |
| sudo touch "$GITHUB_STEP_SUMMARY" | |
| sudo chown $(whoami):$(whoami) "$GITHUB_STEP_SUMMARY" "$(dirname "$GITHUB_STEP_SUMMARY")" | |
| - name: Configure Git access | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: | | |
| git -C "$OT_REPO_CACHE" remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/Opentrons/opentrons.git" | |
| - name: Update cached repository | |
| env: | |
| TARGET_REF: ${{ github.ref }} | |
| TARGET_SHA: ${{ github.sha }} | |
| run: | | |
| cd "$OT_REPO_CACHE" | |
| git fetch --no-tags --prune origin "$TARGET_REF" --depth=1 || git fetch --no-tags origin "$TARGET_SHA" --depth=1 | |
| git checkout --force "$TARGET_SHA" | |
| - name: Check dependency drift | |
| id: deps | |
| working-directory: ${{ env.OT_REPO_CACHE }}/ci-docker | |
| run: make check-dependency-drift | |
| - name: Refresh dependencies when manifests change | |
| if: steps.deps.outputs.dependencies_changed == 'true' | |
| working-directory: ${{ env.OT_REPO_CACHE }} | |
| run: | | |
| make teardown | |
| make setup | |
| make -C ci-docker dependency-checksums OUTPUT="$OT_REPO_CACHE/.ci-dependency-checksums.json" TITLE="Updated Dependency Checksums" | |
| - name: Run API unit tests | |
| working-directory: ${{ env.OT_REPO_CACHE }} | |
| run: make -C api test-cov | |
| - name: Summarize results | |
| if: always() | |
| env: | |
| DEPENDENCIES_CHANGED: ${{ steps.deps.outputs.dependencies_changed || 'false' }} | |
| run: | | |
| echo "## API Tests (CI Docker)" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Image tag: \`${{ needs.select-image.outputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Outcome: \`${{ job.status }}\`" >> "$GITHUB_STEP_SUMMARY" | |
| if [ "$DEPENDENCIES_CHANGED" = "true" ]; then | |
| echo "- Dependencies refreshed: ✅" >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "- Dependencies refreshed: ❌" >> "$GITHUB_STEP_SUMMARY" | |
| fi |