Skip to content

Commit 9be6f35

Browse files
committed
build docker image in test
1 parent 3df936b commit 9be6f35

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

.github/workflows/_torchprime_ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,77 @@ on:
1515
secrets:
1616
PERSONAL_ACCESS_TOKEN_FOR_TRIGGERING_TORCHPRIME:
1717
required: true
18+
GCLOUD_SERVICE_KEY:
19+
required: true
1820
jobs:
1921
torchprime-e2e-test:
2022
name: Run torchprime E2E tests
2123
timeout-minutes: ${{ inputs.timeout-minutes }}
2224
runs-on: ubuntu-22.04
2325
steps:
26+
- name: Use Docker in rootless mode
27+
if: inputs.has_code_changes == 'true'
28+
uses: ScribeMD/[email protected]
29+
- name: Add user to docker group
30+
if: inputs.has_code_changes == 'true'
31+
run: |
32+
sudo usermod -aG docker $USER
33+
newgrp docker
34+
shell: bash
35+
# Googlers: if this fails, follow http://shortn/_61iSj31q1b to debug.
36+
- uses: google-github-actions/auth@v2
37+
if: inputs.has_code_changes == 'true'
38+
with:
39+
credentials_json: '${{ secrets.GCLOUD_SERVICE_KEY }}'
40+
- uses: google-github-actions/setup-gcloud@v2
41+
if: inputs.has_code_changes == 'true'
42+
with:
43+
version: '>= 363.0.0'
44+
install_components: 'beta,gke-gcloud-auth-plugin'
45+
- name: Verify GCP setup
46+
if: inputs.has_code_changes == 'true'
47+
run: gcloud info
48+
shell: bash
49+
- name: Authenticate Docker
50+
if: inputs.has_code_changes == 'true'
51+
run: gcloud auth configure-docker --quiet
52+
shell: bash
53+
- name: Activate SA credentials
54+
if: inputs.has_code_changes == 'true'
55+
run: gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
56+
shell: bash
2457
- name: Checkout actions
2558
if: inputs.has_code_changes == 'true'
2659
uses: actions/checkout@v4
2760
with:
2861
sparse-checkout: |
2962
.github/workflows/setup
3063
path: .actions
64+
# Build a docker image for torchprime E2E test
65+
# First download the torch-xla-wheels
66+
- name: Fetch wheels
67+
if: inputs.has_code_changes == 'true'
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: torch-xla-wheels
71+
path: /tmp/wheels/
72+
# Then run docker to install them and push a docker
73+
- name: Build and push docker image
74+
if: inputs.has_code_changes == 'true'
75+
run: |
76+
. ./infra/ansible/build_for_torchprime.sh
77+
env:
78+
XLA_WHEELS_PATH: /tmp/wheels/
79+
DOCKER_IMAGE_NAME: torch-xla-torchprime-ci
80+
DOCKER_IMAGE_TAG: latest
81+
DOCKER_ORG: pytorch
82+
# Trigger torchprime E2E test workflow
3183
- uses: convictional/[email protected]
84+
if: inputs.has_code_changes == 'true'
3285
with:
3386
owner: AI-Hypercomputer
3487
repo: torchprime
3588
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_TRIGGERING_TORCHPRIME }}
3689
workflow_file_name: e2e_test.yml
90+
wait_interval: 60
3791
ref: yifeit/torchprime-ci

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ jobs:
128128
test-torchprime:
129129
name: "torchprime tests"
130130
uses: ./.github/workflows/_torchprime_ci.yml
131-
# needs: [build-torch-xla, check_code_changes]
132-
needs: [check_code_changes]
131+
needs: [build-torch-xla, check_code_changes]
133132
with:
134133
timeout-minutes: 100
135134
has_code_changes: ${{ needs.check_code_changes.outputs.has_code_changes }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:${python_version}-${debian_version} AS release
2+
3+
WORKDIR /tmp/wheels
4+
COPY ./*.whl ./
5+
6+
RUN echo "Installing the following wheels" && ls *.whl
7+
RUN pip install *.whl
8+
9+
# Install the dependencies including libtpu.
10+
WORKDIR /ansible
11+
RUN pip install ansible
12+
COPY . /ansible
13+
14+
ARG ansible_vars
15+
RUN ansible-playbook -vvv playbook.yaml -e "stage=release" -e "${ansible_vars}" --tags "install_deps"
16+
17+
WORKDIR /
18+
19+
RUN rm -rf /ansible /tmp/wheels

infra/ansible/build_for_torchprime.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
export IMAGE_NAME="gcr.io/tpu-pytorch/for-torchprime-ci:test"
6+
export DOCKERFILE_PATH="infra/ansible/build_for_torchprime.Dockerfile"
7+
export CONTEXT_PATH="/tmp/wheels"
8+
9+
docker build -t "${IMAGE_NAME}" "${CONTEXT_PATH}" -f "${DOCKERFILE_PATH}" --build-arg ansible_vars='{"arch":"amd64","accelerator":"tpu","pytorch_git_rev":"main","xla_git_rev":"foobar","bundle_libtpu":"0","package_version":"2.8","nightly_release":true}'
10+
docker push "${IMAGE_NAME}"

0 commit comments

Comments
 (0)