Skip to content

feat(ci-docker): initialize container build #35

feat(ci-docker): initialize container build

feat(ci-docker): initialize container build #35

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*
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
wait-for-build:
name: Wait for container build
runs-on: ubuntu-latest
needs: select-image
steps:
- name: Wait for Build CI Docker image workflow
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.sha }}
check-name: 'Build and push container'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
allowed-conclusions: success,skipped
lint:
name: API lint (CI Docker)
needs: [select-image, wait-for-build]
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: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore dependency checksums
run: |
if [ -f "$OT_REPO_CACHE/.ci-dependency-checksums.json" ]; then
cp "$OT_REPO_CACHE/.ci-dependency-checksums.json" .ci-dependency-checksums.json
fi
- name: Check dependency drift
id: deps
working-directory: ci-docker
run: make check-dependency-drift
- name: Refresh dependencies when manifests change
if: steps.deps.outputs.dependencies_changed == 'true'
run: |
make teardown
make setup
make -C ci-docker dependency-checksums OUTPUT=".ci-dependency-checksums.json" TITLE="Updated Dependency Checksums"
- name: Run lint
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, wait-for-build]
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: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore dependency checksums
run: |
if [ -f "$OT_REPO_CACHE/.ci-dependency-checksums.json" ]; then
cp "$OT_REPO_CACHE/.ci-dependency-checksums.json" .ci-dependency-checksums.json
fi
- name: Check dependency drift
id: deps
working-directory: ci-docker
run: make check-dependency-drift
- name: Refresh dependencies when manifests change
if: steps.deps.outputs.dependencies_changed == 'true'
run: |
make teardown
make setup
make -C ci-docker dependency-checksums OUTPUT=".ci-dependency-checksums.json" TITLE="Updated Dependency Checksums"
- name: Run API unit tests
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