hamel commited on
Commit
2e61dc3
1 Parent(s): 1ffa386

Add tests to Docker (#993)

Browse files
Files changed (2) hide show
  1. .github/workflows/main.yml +17 -4
  2. docker/Dockerfile +3 -0
.github/workflows/main.yml CHANGED
@@ -38,27 +38,40 @@ jobs:
38
  uses: docker/metadata-action@v5
39
  with:
40
  images: winglian/axolotl
 
 
41
  - name: Login to Docker Hub
42
  uses: docker/login-action@v3
43
  with:
44
  username: ${{ secrets.DOCKERHUB_USERNAME }}
45
  password: ${{ secrets.DOCKERHUB_TOKEN }}
46
- - name: Set up Docker Buildx
47
- uses: docker/setup-buildx-action@v3
48
- - name: Build
49
  uses: docker/build-push-action@v5
50
  with:
51
  context: .
 
52
  build-args: |
53
  BASE_TAG=${{ github.ref_name }}-base-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}
54
  CUDA=${{ matrix.cuda }}
55
  PYTORCH_VERSION=${{ matrix.pytorch }}
56
  file: ./docker/Dockerfile
57
- push: ${{ github.event_name != 'pull_request' }}
58
  tags: |
59
  ${{ steps.metadata.outputs.tags }}-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}${{ matrix.axolotl_extras != '' && '-' || '' }}${{ matrix.axolotl_extras }}
60
  ${{ (matrix.is_latest) && format('{0}-latest', steps.metadata.outputs.tags) || '' }}
61
  labels: ${{ steps.metadata.outputs.labels }}
 
 
 
 
 
 
 
 
 
 
 
 
62
  build-axolotl-runpod:
63
  needs: build-axolotl
64
  if: github.repository_owner == 'OpenAccess-AI-Collective'
 
38
  uses: docker/metadata-action@v5
39
  with:
40
  images: winglian/axolotl
41
+ - name: Set up Docker Buildx
42
+ uses: docker/setup-buildx-action@v3
43
  - name: Login to Docker Hub
44
  uses: docker/login-action@v3
45
  with:
46
  username: ${{ secrets.DOCKERHUB_USERNAME }}
47
  password: ${{ secrets.DOCKERHUB_TOKEN }}
48
+ # guidance for testing before pushing: https://docs.docker.com/build/ci/github-actions/test-before-push/
49
+ - name: Build and export to Docker
 
50
  uses: docker/build-push-action@v5
51
  with:
52
  context: .
53
+ load: true
54
  build-args: |
55
  BASE_TAG=${{ github.ref_name }}-base-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}
56
  CUDA=${{ matrix.cuda }}
57
  PYTORCH_VERSION=${{ matrix.pytorch }}
58
  file: ./docker/Dockerfile
 
59
  tags: |
60
  ${{ steps.metadata.outputs.tags }}-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}${{ matrix.axolotl_extras != '' && '-' || '' }}${{ matrix.axolotl_extras }}
61
  ${{ (matrix.is_latest) && format('{0}-latest', steps.metadata.outputs.tags) || '' }}
62
  labels: ${{ steps.metadata.outputs.labels }}
63
+ - name: Unit Tests
64
+ run: |
65
+ docker run --rm ${{ steps.metadata.outputs.tags }}-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}${{ matrix.axolotl_extras != '' && '-' || '' }}${{ matrix.axolotl_extras }} pytest --ignore=tests/e2e/ /workspace/axolotl/tests/
66
+ - name: Push to Docker Hub
67
+ if: github.event_name != 'pull_request'
68
+ run: |
69
+ docker push ${{ steps.metadata.outputs.tags }}-py${{ matrix.python_version }}-cu${{ matrix.cuda }}-${{ matrix.pytorch }}${{ matrix.axolotl_extras != '' && '-' || '' }}${{ matrix.axolotl_extras }}
70
+ latest_tag=${{ (matrix.is_latest) && format('{0}-latest', steps.metadata.outputs.tags) || '' }}
71
+ if [ -n "$latest_tag" ]; then
72
+ docker push "$latest_tag"
73
+ fi
74
+
75
  build-axolotl-runpod:
76
  needs: build-axolotl
77
  if: github.repository_owner == 'OpenAccess-AI-Collective'
docker/Dockerfile CHANGED
@@ -25,6 +25,9 @@ RUN if [ "$AXOLOTL_EXTRAS" != "" ] ; then \
25
  pip install -e .[deepspeed,flash-attn]; \
26
  fi
27
 
 
 
 
28
  # fix so that git fetch/pull from remote works
29
  RUN git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && \
30
  git config --get remote.origin.fetch
 
25
  pip install -e .[deepspeed,flash-attn]; \
26
  fi
27
 
28
+ # So we can test the Docker image
29
+ RUN pip install pytest
30
+
31
  # fix so that git fetch/pull from remote works
32
  RUN git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && \
33
  git config --get remote.origin.fetch