Skip to content

Commit

Permalink
CI caching (#2103)
Browse files Browse the repository at this point in the history
* use docker cache for ci; split builds
  • Loading branch information
kjubybot authored Feb 26, 2025
1 parent fc153de commit fc0cdba
Showing 1 changed file with 69 additions and 8 deletions.
77 changes: 69 additions & 8 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,85 @@ jobs:
file: ./services/app/assp/codebattle/cover/excoveralls.json
fail_ci_if_error: false

codebattle-docker-matrix:
if: github.repository == 'hexlet-codebattle/codebattle'
runs-on: ubuntu-latest
timeout-minutes: 30 # Add timeout to prevent hanging builds
needs: build

strategy:
matrix:
target:
- assets-image
- compile-image
- nginx-assets
- runtime-image
include:
- target: runtime-image
tag: latest

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build codebattle ${{ matrix.target }}
uses: docker/build-push-action@v6
with:
context: services/app
file: services/app/Dockerfile.codebattle
build-args: |
GIT_HASH=${{ github.sha }}
push: ${{ github.ref_name == 'master' }}
target: ${{ matrix.target }}
tags: codebattle/codebattle:${{ matrix.tag != '' && matrix.tag|| matrix.target }}
cache-to: type=registry,ref=codebattle/codebattle:${{ matrix.target }}-buildcache
cache-from: type=registry,ref=codebattle/codebattle:${{ matrix.target }}-buildcache,image-manifest=true

runner-docker-matrix:
if: github.repository == 'hexlet-codebattle/codebattle'
runs-on: ubuntu-latest
timeout-minutes: 30 # Add timeout to prevent hanging builds
needs: build

strategy:
matrix:
target:
- compile-image
- runtime-image
include:
- target: runtime-image
tag: latest

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push codebattle image
run: |
make GIT_HASH=${{ github.sha }} docker-build-codebattle
make docker-push-codebattle
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push runner image
run: |
make docker-build-runner
make docker-push-runner
- name: Build runner ${{ matrix.target }}
uses: docker/build-push-action@v6
with:
context: services/app
file: services/app/Dockerfile.runner
push: ${{ github.ref_name == 'master' }}
target: ${{ matrix.target }}
tags: codebattle/runner:${{ matrix.tag != '' && matrix.tag|| matrix.target }}
cache-to: type=registry,ref=codebattle/runner:${{ matrix.target }}-buildcache
cache-from: type=registry,ref=codebattle/runner:${{ matrix.target }}-buildcache,image-manifest=true

# stop integratoin tests on CI becaues of https://github.com/hexlet-codebattle/codebattle/runs/580337561?check_suite_focus=true
# - name: Pull dockers
Expand Down

0 comments on commit fc0cdba

Please sign in to comment.