From 0d7229d47598a517831833fe357e8917732c38ae Mon Sep 17 00:00:00 2001 From: Huy Do Date: Mon, 17 Jul 2023 16:40:00 -0700 Subject: [PATCH 1/5] Use shareable calculate-docker-image GHA --- .github/workflows/linux_job.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux_job.yml b/.github/workflows/linux_job.yml index 7ad11a33c7..e93e214e23 100644 --- a/.github/workflows/linux_job.yml +++ b/.github/workflows/linux_job.yml @@ -47,6 +47,13 @@ on: description: Identifies the Docker image by name. default: "pytorch/conda-builder" type: string + docker-build-dir: + description: | + The directory containing the build.sh shell script to build the docker image. + The script parameters can be passed to docker build similar to how it is used + in PyTorch, i.e. build.sh "${IMAGE_NAME}" -t "${DOCKER_IMAGE}" + default: ".ci/docker" + type: string gpu-arch-type: description: "GPU arch type to use" default: "cpu" @@ -138,10 +145,17 @@ jobs: with: github-secret: ${{ github.token }} + - name: Calculate docker image + id: calculate-docker-image + uses: huydhn/test-infra/.github/actions/calculate-docker-image@calculate-docker-image + with: + docker-image-name: ${{ env.DOCKER_IMAGE }} + docker-build-dir: ${{ inputs.docker-build-dir }} + - name: Pull docker image uses: ./test-infra/.github/actions/pull-docker-image with: - docker-image: ${{ env.DOCKER_IMAGE }} + docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }} - name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }}) uses: actions/checkout@v3 From fddddfce7a0defc2e3e1d87e9c8184e9733e4f1b Mon Sep 17 00:00:00 2001 From: Huy Do Date: Mon, 17 Jul 2023 16:54:26 -0700 Subject: [PATCH 2/5] Run calculate-docker-image after checkout --- .github/workflows/linux_job.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux_job.yml b/.github/workflows/linux_job.yml index e93e214e23..4ddb01dab5 100644 --- a/.github/workflows/linux_job.yml +++ b/.github/workflows/linux_job.yml @@ -145,9 +145,20 @@ jobs: with: github-secret: ${{ github.token }} + - name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }}) + uses: actions/checkout@v3 + with: + # Support the use case where we need to checkout someone's fork + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.ref }} + path: ${{ inputs.repository || github.repository }} + fetch-depth: ${{ inputs.fetch-depth }} + - name: Calculate docker image id: calculate-docker-image uses: huydhn/test-infra/.github/actions/calculate-docker-image@calculate-docker-image + # This needs to be where the repository is checked out + working-directory: ${{ inputs.repository || github.repository }} with: docker-image-name: ${{ env.DOCKER_IMAGE }} docker-build-dir: ${{ inputs.docker-build-dir }} @@ -157,15 +168,6 @@ jobs: with: docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }} - - name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }}) - uses: actions/checkout@v3 - with: - # Support the use case where we need to checkout someone's fork - repository: ${{ inputs.repository || github.repository }} - ref: ${{ inputs.ref || github.ref }} - path: ${{ inputs.repository || github.repository }} - fetch-depth: ${{ inputs.fetch-depth }} - - name: Download artifacts (if any) uses: actions/download-artifact@v3 if: ${{ inputs.download-artifact != '' }} From 3dc8a02b3852d339eb8cfbebf0744fc0f9e5396e Mon Sep 17 00:00:00 2001 From: Huy Do Date: Mon, 17 Jul 2023 17:04:43 -0700 Subject: [PATCH 3/5] Pass the working directory --- .github/workflows/linux_job.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux_job.yml b/.github/workflows/linux_job.yml index 4ddb01dab5..e35cdd14ae 100644 --- a/.github/workflows/linux_job.yml +++ b/.github/workflows/linux_job.yml @@ -49,9 +49,8 @@ on: type: string docker-build-dir: description: | - The directory containing the build.sh shell script to build the docker image. - The script parameters can be passed to docker build similar to how it is used - in PyTorch, i.e. build.sh "${IMAGE_NAME}" -t "${DOCKER_IMAGE}" + The directory containing the build.sh shell script to build the docker image. The + path is relative to where the repo is checked out. default: ".ci/docker" type: string gpu-arch-type: @@ -157,11 +156,11 @@ jobs: - name: Calculate docker image id: calculate-docker-image uses: huydhn/test-infra/.github/actions/calculate-docker-image@calculate-docker-image - # This needs to be where the repository is checked out - working-directory: ${{ inputs.repository || github.repository }} with: docker-image-name: ${{ env.DOCKER_IMAGE }} docker-build-dir: ${{ inputs.docker-build-dir }} + # This needs to be where the repository is checked out + working-directory: ${{ inputs.repository || github.repository }} - name: Pull docker image uses: ./test-infra/.github/actions/pull-docker-image From 8dc462d0de2b73d1771a12048019a1e375f2c623 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Mon, 17 Jul 2023 18:20:02 -0700 Subject: [PATCH 4/5] Set DOCKER_IMAGE env variable --- .github/workflows/linux_job.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linux_job.yml b/.github/workflows/linux_job.yml index e35cdd14ae..0a0a5fd694 100644 --- a/.github/workflows/linux_job.yml +++ b/.github/workflows/linux_job.yml @@ -187,6 +187,7 @@ jobs: working-directory: ${{ inputs.repository }} env: ALL_SECRETS: ${{ toJSON(secrets) }} + DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }} run: | set -ex { From 800e58333ea59cf746ee8570885f007bc33e54f1 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Tue, 18 Jul 2023 17:53:00 -0700 Subject: [PATCH 5/5] Switch to the correct version --- .github/workflows/linux_job.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux_job.yml b/.github/workflows/linux_job.yml index 0a0a5fd694..bf91fb76af 100644 --- a/.github/workflows/linux_job.yml +++ b/.github/workflows/linux_job.yml @@ -49,8 +49,9 @@ on: type: string docker-build-dir: description: | - The directory containing the build.sh shell script to build the docker image. The - path is relative to where the repo is checked out. + The directory containing the build.sh shell script to build the docker image. + The script parameters can be passed to docker build similar to how it is used + in PyTorch, i.e. build.sh "${IMAGE_NAME}" -t "${DOCKER_IMAGE}". default: ".ci/docker" type: string gpu-arch-type: @@ -155,7 +156,7 @@ jobs: - name: Calculate docker image id: calculate-docker-image - uses: huydhn/test-infra/.github/actions/calculate-docker-image@calculate-docker-image + uses: ./test-infra/.github/actions/calculate-docker-image with: docker-image-name: ${{ env.DOCKER_IMAGE }} docker-build-dir: ${{ inputs.docker-build-dir }}