From 19060099de607e8b2bb11f412b5230327a35198f Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 26 Apr 2024 09:45:18 -0400 Subject: [PATCH] ci: update pull request workflow (#36) --- .github/workflows/build-pull-request.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index 95ab31e..b187944 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -10,23 +10,27 @@ concurrency: cancel-in-progress: true jobs: - build-container: + build: runs-on: [gpu] steps: - name: Define environment variables run: | - echo REPOSITORY=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + echo IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV echo TAG=$(echo "PR-${{ github.event.pull_request.number }}") >> $GITHUB_ENV - name: Set up docker uses: docker/setup-buildx-action@v3 - - name: Build container + - name: Pull latest image as cache + run: docker pull ${{ env.IMAGE_NAME }}:latest + + - name: Build image locally uses: docker/build-push-action@v5 with: - tags: ${{ env.REPOSITORY }}:${{ env.TAG }} + tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }} outputs: type=docker,dest=/tmp/esi-opticks-${{ env.TAG }}.tar cache-from: ${{ env.IMAGE_NAME }}:latest + cache-to: type=inline - name: Save built image for test jobs uses: actions/upload-artifact@v4 @@ -34,13 +38,13 @@ jobs: name: esi-opticks-${{ env.TAG }} path: /tmp/esi-opticks-${{ env.TAG }}.tar - test-container: + test: runs-on: ubuntu-latest - needs: build-container + needs: build steps: - name: Define environment variables run: | - echo REPOSITORY=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + echo IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV echo TAG=$(echo "PR-${{ github.event.pull_request.number }}") >> $GITHUB_ENV - name: Download artifact @@ -52,4 +56,4 @@ jobs: - name: Run tests run: | docker load --input /tmp/esi-opticks-${{ env.TAG }}.tar - docker run ${{ env.REPOSITORY }}:${{ env.TAG }} bash -l -c opticks-info + docker run ${{ env.IMAGE_NAME }}:${{ env.TAG }} bash -l -c opticks-info