Skip to content

Commit

Permalink
ci: update pull request workflow (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
plexoos authored Apr 26, 2024
1 parent 3a12c6b commit 1906009
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,41 @@ 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
with:
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
Expand All @@ -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

0 comments on commit 1906009

Please sign in to comment.