44 push :
55 branches :
66 - master
7+ workflow_dispatch :
8+
79jobs :
810 build :
911 if : github.repository == 'hexlet-codebattle/codebattle'
1012 runs-on : ubuntu-latest
13+ timeout-minutes : 30 # Add timeout to prevent hanging builds
1114
12- # Use test environment by default
1315 env :
1416 MIX_ENV : test
17+ DOCKER_BUILDKIT : 1 # Enable buildkit for faster docker builds
1518
1619 services :
1720 db :
1821 image : postgres:16-alpine
1922 ports : ["5432:5432"]
2023 env :
2124 POSTGRES_PASSWORD : postgres
25+ POSTGRES_HOST_AUTH_METHOD : trust # Simplify auth for CI
2226 options : >-
2327 --health-cmd pg_isready
2428 --health-interval 10s
@@ -29,29 +33,31 @@ jobs:
2933
3034 steps :
3135 - uses : actions/checkout@v4
36+ with :
37+ fetch-depth : 0 # Fetch complete history for better caching
3238
3339 - name : Setup Elixir
3440 uses : erlef/setup-beam@v1
3541 with :
3642 otp-version : " 27.2"
3743 elixir-version : " 1.18.2"
3844
39- - name : Restore Dependencies Cache
40- uses : actions/cache@v4
41- with :
42- path : ./services/app/deps
43- key : ${{ runner.os }}-deps-${{ hashFiles('**/mix.lock') }}
44- restore-keys : ${{ runner.os }}-deps-
45-
46- - name : Restore Build Cache
45+ - name : Cache Dependencies
4746 uses : actions/cache@v4
47+ id : deps-cache
4848 with :
49- path : ./services/app/_build
50- key : ${{ runner.os }}-build-${{ hashFiles('**/mix.lock') }}
51- restore-keys : ${{ runner.os }}-build-
49+ path : |
50+ ./services/app/deps
51+ ./services/app/_build
52+ key : ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
53+ restore-keys : |
54+ ${{ runner.os }}-mix-
5255
5356 - name : Get deps
54- run : mix deps.get
57+ run : |
58+ mix local.hex --force
59+ mix local.rebar --force
60+ mix deps.get
5561 working-directory : ./services/app
5662
5763 - name : Mix deps.compile
6874
6975 - name : Get yarn cache
7076 id : yarn-cache
71- run : echo "::set-output name= dir:: $(yarn cache dir)"
77+ run : echo "dir= $(yarn cache dir)" >> $GITHUB_OUTPUT
7278
7379 - uses : actions/cache@v4
7480 with :
7884 ${{ runner.os }}-yarn-
7985
8086 - name : Install yarn dependencies
81- run : yarn install --froze -lockfile
87+ run : yarn install --frozen -lockfile --network-timeout 300000
8288 working-directory : ./services/app/apps/codebattle
8389
8490 - name : Eslint
@@ -97,23 +103,30 @@ jobs:
97103 run : make test
98104
99105 - name : Upload coverage to Codecov
100- uses : codecov/codecov-action@v1
106+ uses : codecov/codecov-action@v3
101107 with :
102108 token : ${{ secrets.CODECOV_TOKEN }}
103109 file : ./services/app/assp/codebattle/cover/excoveralls.json
104110 fail_ci_if_error : false
105111
106112 - name : Login to Docker Hub
107- run : echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
108-
109- - name : Build docker image for codebattle
110- run : make GIT_HASH=${{ github.sha }} docker-build-codebattle
111- - name : Push docker image for codebattle
112- run : make docker-push-codebattle
113- - name : Build docker image for runner
114- run : make docker-build-runner
115- - name : Push docker image for runner
116- run : make docker-push-runner
113+ uses : docker/login-action@v3
114+ with :
115+ username : ${{ secrets.DOCKER_USERNAME }}
116+ password : ${{ secrets.DOCKER_PASSWORD }}
117+
118+ - name : Set up Docker Buildx
119+ uses : docker/setup-buildx-action@v3
120+
121+ - name : Build and push codebattle image
122+ run : |
123+ make GIT_HASH=${{ github.sha }} docker-build-codebattle
124+ make docker-push-codebattle
125+
126+ - name : Build and push runner image
127+ run : |
128+ make docker-build-runner
129+ make docker-push-runner
117130
118131 # stop integratoin tests on CI becaues of https://github.com/hexlet-codebattle/codebattle/runs/580337561?check_suite_focus=true
119132 # - name: Pull dockers
0 commit comments