|
| 1 | +# Inspired by |
| 2 | +# https://github.com/huggingface/peft/blob/main/.github/workflows/test-docker-build.yml |
| 3 | +name: Test Docker builds (PR) |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + paths: |
| 10 | + # Run only when DockerFile files are modified |
| 11 | + - "docker/**" |
| 12 | + |
| 13 | +env: |
| 14 | + PYTHON_VERSION: "3.10" |
| 15 | + |
| 16 | +jobs: |
| 17 | + get_changed_files: |
| 18 | + name: "Get all modified Dockerfiles" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 22 | + steps: |
| 23 | + - name: Check out code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Get changed files |
| 27 | + id: changed-files |
| 28 | + uses: tj-actions/changed-files@v44 |
| 29 | + with: |
| 30 | + files: docker/** |
| 31 | + json: "true" |
| 32 | + |
| 33 | + - name: Run step if only the files listed above change |
| 34 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 35 | + id: set-matrix |
| 36 | + env: |
| 37 | + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} |
| 38 | + run: | |
| 39 | + echo "matrix=${{ steps.changed-files.outputs.all_changed_files}}" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | +
|
| 42 | + build_modified_dockerfiles: |
| 43 | + name: "Build all modified Docker images" |
| 44 | + needs: get_changed_files |
| 45 | + runs-on: ubuntu-latest |
| 46 | + if: ${{ needs.get_changed_files.outputs.matrix }} != '' |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + docker-file: ${{ fromJson(needs.get_changed_files.outputs.matrix) }} |
| 51 | + steps: |
| 52 | + - name: Cleanup disk |
| 53 | + run: | |
| 54 | + sudo df -h |
| 55 | + # sudo ls -l /usr/local/lib/ |
| 56 | + # sudo ls -l /usr/share/ |
| 57 | + sudo du -sh /usr/local/lib/ |
| 58 | + sudo du -sh /usr/share/ |
| 59 | + sudo rm -rf /usr/local/lib/android |
| 60 | + sudo rm -rf /usr/share/dotnet |
| 61 | + sudo du -sh /usr/local/lib/ |
| 62 | + sudo du -sh /usr/share/ |
| 63 | + sudo df -h |
| 64 | +
|
| 65 | + - name: Set up Docker Buildx |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Check out code |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + # HACK(aliberts): to be removed for release |
| 72 | + # ----------------------------------------- |
| 73 | + - name: Checkout gym-aloha |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + repository: huggingface/gym-aloha |
| 77 | + path: envs/gym-aloha |
| 78 | + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 79 | + |
| 80 | + - name: Checkout gym-xarm |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + repository: huggingface/gym-xarm |
| 84 | + path: envs/gym-xarm |
| 85 | + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 86 | + |
| 87 | + - name: Checkout gym-pusht |
| 88 | + uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + repository: huggingface/gym-pusht |
| 91 | + path: envs/gym-pusht |
| 92 | + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 93 | + |
| 94 | + - name: Set up Python 3.10 |
| 95 | + uses: actions/setup-python@v5 |
| 96 | + with: |
| 97 | + python-version: "3.10" |
| 98 | + |
| 99 | + - name: Change envs dependencies as local path |
| 100 | + run: python .github/scripts/dep_build.py |
| 101 | + # ----------------------------------------- |
| 102 | + |
| 103 | + - name: Build Docker image |
| 104 | + uses: docker/build-push-action@v5 |
| 105 | + with: |
| 106 | + file: ${{ matrix.docker-file }} |
| 107 | + context: . |
| 108 | + push: False |
| 109 | + build-args: PYTHON_VERSION=${{ env.PYTHON_VERSION }} |
0 commit comments