Skip to content

Commit 48798a9

Browse files
committed
chore(ci): use docker
1 parent c67ca46 commit 48798a9

File tree

8 files changed

+53
-177
lines changed

8 files changed

+53
-177
lines changed

.github/actions/setup/action.yml

Lines changed: 6 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ name: Setup
33
description: Setup CI environment.
44

55
inputs:
6-
type:
7-
description: Type of setup, `minimal` will only setup the JavaScript monorepo, empty will also install Java.
8-
required: false
9-
language:
10-
description: the language for which to install deps
6+
javascript-utils:
7+
description: If true, it will also restore the cache of the javascript util packages.
118
required: false
129

1310
runs:
@@ -18,31 +15,7 @@ runs:
1815
run: |
1916
echo "CACHE_VERSION=$(< .github/.cache_version)" >> $GITHUB_ENV
2017
21-
# Java for code generation
22-
- name: Install Java
23-
if: inputs.type != 'minimal'
24-
uses: actions/setup-java@v4
25-
with:
26-
distribution: zulu
27-
java-version-file: config/.java-version
28-
cache: gradle
29-
30-
- name: Validate gradle wrapper
31-
if: inputs.type != 'minimal'
32-
uses: gradle/wrapper-validation-action@v1
33-
34-
- name: Download Java formatter
35-
if: inputs.type != 'minimal'
36-
shell: bash
37-
run: curl --retry 3 -L "https://github.com/google/google-java-format/releases/download/v1.19.2/google-java-format-1.19.2-all-deps.jar" > /tmp/java-formatter.jar
38-
3918
# JavaScript for monorepo and tooling
40-
- name: Install Node
41-
uses: actions/setup-node@v4
42-
with:
43-
node-version-file: .nvmrc
44-
cache: yarn
45-
4619
- name: Get yarn cache directory path
4720
shell: bash
4821
id: yarn-cache-dir
@@ -69,143 +42,29 @@ runs:
6942
shell: bash
7043
run: yarn workspace scripts build:cli
7144

72-
- name: Get all languages versions
73-
id: versions
74-
shell: bash
75-
run: |
76-
# remove patch from php version
77-
echo "CSHARP_VERSION=$(cat config/.csharp-version)" >> $GITHUB_OUTPUT
78-
echo "DART_VERSION=$(cat config/.dart-version)" >> $GITHUB_OUTPUT
79-
echo "GO_VERSION=$(cat config/.go-version)" >> $GITHUB_OUTPUT
80-
echo "PHP_VERSION=$(cat config/.php-version | cut -d '.' -f 1,2)" >> $GITHUB_OUTPUT
81-
echo "PYTHON_VERSION=$(cat config/.python-version)" >> $GITHUB_OUTPUT
82-
echo "RUBY_VERSION=$(cat config/.ruby-version)" >> $GITHUB_OUTPUT
83-
echo "SWIFT_VERSION=$(cat config/.swift-version)" >> $GITHUB_OUTPUT
84-
8545
# JavaScript client deps
8646
- name: Get yarn js-client cache directory path
87-
if: ${{ inputs.language == 'javascript' }}
47+
if: ${{ inputs.javascript-utils == 'true' }}
8848
shell: bash
8949
id: yarn-cache-dir-client
9050
run: echo "dir=$(cd clients/algoliasearch-client-javascript && yarn config get cacheFolder)" >> $GITHUB_OUTPUT
9151

9252
- name: Restore Yarn js-client
93-
if: ${{ inputs.language == 'javascript' }}
53+
if: ${{ inputs.javascript-utils == 'true' }}
9454
uses: actions/cache@v3
9555
with:
9656
path: ${{ steps.yarn-cache-dir-client.outputs.dir || 'clients/algoliasearch-client-javascript/.yarn/cache' }}
9757
# let yarn handle the cache hash
9858
key: yarn-cache-client-${{ env.CACHE_VERSION }}
9959

10060
- name: Cache js-client node modules
101-
if: ${{ inputs.language == 'javascript' }}
61+
if: ${{ inputs.javascript-utils == 'true' }}
10262
uses: actions/cache@v3
10363
with:
10464
path: clients/algoliasearch-client-javascript/node_modules
10565
key: node-modules-client-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}
10666

10767
- name: Install JavaScript client dependencies
108-
if: ${{ inputs.language == 'javascript' }}
68+
if: ${{ inputs.javascript-utils == 'true' }}
10969
shell: bash
11070
run: cd clients/algoliasearch-client-javascript && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
111-
112-
# PHP
113-
- name: Install PHP
114-
if: ${{ inputs.language == 'php' }}
115-
uses: shivammathur/setup-php@v2
116-
with:
117-
php-version: ${{ steps.versions.outputs.PHP_VERSION }}
118-
tools: composer
119-
120-
- name: Run composer install
121-
if: ${{ inputs.language == 'php' }}
122-
shell: bash
123-
run: |
124-
composer install --working-dir=clients/algoliasearch-client-php
125-
composer dump-autoload --working-dir=clients/algoliasearch-client-php
126-
127-
# Golang
128-
- name: Install golang
129-
if: ${{ inputs.language == 'go' }}
130-
uses: actions/setup-go@v5
131-
with:
132-
cache-dependency-path: clients/algoliasearch-client-go/go.sum
133-
go-version: ${{ steps.versions.outputs.GO_VERSION }}
134-
135-
- name: Install golangci-lint
136-
if: ${{ inputs.language == 'go' }}
137-
shell: bash
138-
run: |
139-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
140-
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
141-
go install golang.org/x/tools/cmd/goimports@latest
142-
143-
# Dart
144-
- name: Install dart
145-
if: ${{ inputs.language == 'dart' }}
146-
uses: dart-lang/setup-dart@v1
147-
with:
148-
sdk: ${{ steps.versions.outputs.DART_VERSION }}
149-
150-
- name: Setup dart tools
151-
if: ${{ inputs.language == 'dart' }}
152-
shell: bash
153-
run: dart pub global activate melos
154-
155-
# Python
156-
- name: Install poetry
157-
if: ${{ inputs.language == 'python' }}
158-
shell: bash
159-
run: pipx install poetry
160-
161-
- uses: actions/setup-python@v5
162-
if: ${{ inputs.language == 'python' }}
163-
with:
164-
python-version: ${{ steps.versions.outputs.PYTHON_VERSION }}
165-
cache: 'poetry'
166-
167-
- run: poetry install
168-
if: ${{ inputs.language == 'python' }}
169-
working-directory: clients/algoliasearch-client-python
170-
shell: bash
171-
172-
# Ruby
173-
- name: Install Ruby
174-
if: ${{ inputs.language == 'ruby' }}
175-
uses: ruby/setup-ruby@v1
176-
with:
177-
ruby-version: ${{ steps.versions.outputs.RUBY_VERSION }}
178-
bundler-cache: true
179-
180-
# Csharp
181-
- name: Install dotnet
182-
if: ${{ inputs.language == 'csharp' }}
183-
uses: actions/setup-dotnet@v4
184-
with:
185-
dotnet-version: ${{ steps.versions.outputs.CSHARP_VERSION }}
186-
187-
# Swift deps
188-
- name: Install swift
189-
if: ${{ inputs.language == 'swift' }}
190-
uses: swift-actions/setup-swift@v1
191-
with:
192-
swift-version: ${{ steps.versions.outputs.SWIFT_VERSION }}
193-
194-
- name: Set up Homebrew
195-
if: ${{ inputs.language == 'swift' }}
196-
id: set-up-homebrew
197-
uses: Homebrew/actions/setup-homebrew@master
198-
199-
- name: Cache Homebrew Bundler RubyGems
200-
if: ${{ inputs.language == 'swift' }}
201-
id: cache
202-
uses: actions/cache@v3
203-
with:
204-
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
205-
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
206-
restore-keys: ${{ runner.os }}-rubygems-
207-
208-
- name: Install swift-format
209-
if: ${{ inputs.language == 'swift' && steps.cache.outputs.cache-hit != 'true' }}
210-
shell: bash
211-
run: brew install swift-format

.github/workflows/check.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ concurrency:
2020
jobs:
2121
setup:
2222
runs-on: ubuntu-22.04
23+
container:
24+
image: ghcr.io/algolia/apic_base
25+
volumes: [./:/app]
2326
timeout-minutes: 10
2427
steps:
2528
- name: debugging - dump GitHub context
@@ -35,6 +38,9 @@ jobs:
3538
id: setup
3639
uses: ./.github/actions/setup
3740

41+
- name: Validate gradle wrapper
42+
uses: gradle/wrapper-validation-action@v1
43+
3844
# Computing jobs that should run
3945
- name: Setting diff outputs variables
4046
id: diff
@@ -98,6 +104,9 @@ jobs:
98104

99105
scripts:
100106
runs-on: ubuntu-22.04
107+
container:
108+
image: ghcr.io/algolia/apic_base
109+
volumes: [./:/app]
101110
timeout-minutes: 10
102111
needs: setup
103112
if: ${{ needs.setup.outputs.RUN_SCRIPTS == 'true' }}
@@ -106,8 +115,6 @@ jobs:
106115

107116
- name: Setup
108117
uses: ./.github/actions/setup
109-
with:
110-
type: minimal
111118

112119
- name: Check script linting
113120
run: yarn scripts:lint
@@ -120,6 +127,9 @@ jobs:
120127

121128
specs:
122129
runs-on: ubuntu-22.04
130+
container:
131+
image: ghcr.io/algolia/apic_base
132+
volumes: [./:/app]
123133
timeout-minutes: 10
124134
needs: setup
125135
steps:
@@ -135,8 +145,6 @@ jobs:
135145
- name: Setup
136146
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
137147
uses: ./.github/actions/setup
138-
with:
139-
type: minimal
140148

141149
- name: Building specs
142150
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -152,6 +160,9 @@ jobs:
152160
client_javascript_utils:
153161
timeout-minutes: 10
154162
runs-on: ubuntu-22.04
163+
container:
164+
image: ghcr.io/algolia/apic_base
165+
volumes: [./:/app]
155166
needs: setup
156167
if: ${{ needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' }}
157168
strategy:
@@ -184,8 +195,7 @@ jobs:
184195
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
185196
uses: ./.github/actions/setup
186197
with:
187-
type: minimal
188-
language: javascript
198+
javascript-utils: true
189199

190200
- name: Build '${{ matrix.client }}' client
191201
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -198,6 +208,9 @@ jobs:
198208
client_gen_javascript:
199209
timeout-minutes: 10
200210
runs-on: ubuntu-22.04
211+
container:
212+
image: ghcr.io/algolia/apic_base
213+
volumes: [./:/app]
201214
needs:
202215
- setup
203216
- client_javascript_utils
@@ -239,7 +252,7 @@ jobs:
239252
- name: Setup
240253
uses: ./.github/actions/setup
241254
with:
242-
language: javascript
255+
javascript-utils: true
243256

244257
- name: Generate clients
245258
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -303,7 +316,10 @@ jobs:
303316

304317
client_gen:
305318
timeout-minutes: 20
306-
runs-on: ${{ matrix.client.language == 'swift' && 'macos-12' || 'ubuntu-22.04' }}
319+
runs-on: 'ubuntu-22.04'
320+
container:
321+
image: ${{ format('ghcr.io/algolia/{0}', matrix.client.dockerImage }}
322+
volumes: [./:/app]
307323
needs:
308324
- setup
309325
- specs
@@ -337,8 +353,6 @@ jobs:
337353

338354
- name: Setup
339355
uses: ./.github/actions/setup
340-
with:
341-
language: ${{ matrix.client.language }}
342356

343357
- name: Generate clients
344358
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -384,6 +398,9 @@ jobs:
384398

385399
codegen:
386400
runs-on: ubuntu-22.04
401+
container:
402+
image: ghcr.io/algolia/apic_base
403+
volumes: [./:/app]
387404
timeout-minutes: 10
388405
needs:
389406
- setup
@@ -408,8 +425,6 @@ jobs:
408425

409426
- name: Setup
410427
uses: ./.github/actions/setup
411-
with:
412-
type: minimal
413428

414429
- name: Push generated code
415430
id: pushGeneratedCode

.github/workflows/codegen.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
jobs:
88
notification:
99
runs-on: ubuntu-22.04
10+
container:
11+
image: ghcr.io/algolia/apic_base
12+
volumes: [./:/app]
1013
timeout-minutes: 10
1114
if: (github.event.action == 'opened' || github.event.action == 'synchronize') && github.event.number
1215
steps:
@@ -17,8 +20,6 @@ jobs:
1720

1821
- name: Setup
1922
uses: ./.github/actions/setup
20-
with:
21-
type: minimal
2223

2324
- name: Add notification comment
2425
run: yarn workspace scripts upsertGenerationComment notification
@@ -29,6 +30,9 @@ jobs:
2930

3031
cleanup:
3132
runs-on: ubuntu-22.04
33+
container:
34+
image: ghcr.io/algolia/apic_base
35+
volumes: [./:/app]
3236
timeout-minutes: 10
3337
if: github.event.action == 'closed'
3438
steps:
@@ -39,8 +43,6 @@ jobs:
3943

4044
- name: Setup
4145
uses: ./.github/actions/setup
42-
with:
43-
type: minimal
4446

4547
- name: Add cleanup comment
4648
run: yarn workspace scripts upsertGenerationComment cleanup

.github/workflows/scheduled-release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ jobs:
2222
- name: Setup
2323
id: setup
2424
uses: ./.github/actions/setup
25-
with:
26-
type: minimal
27-
language: dart # we need the dart deps because we use melos to bump dependencies for its client
2825

2926
- run: yarn release
3027
env:

scripts/ci/githubActions/createMatrix.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as core from '@actions/core';
44
import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common.js';
55
import {
66
getClientsConfigField,
7+
getDockerImage,
78
getLanguageFolder,
89
getTestExtension,
910
getTestOutputFolder,
@@ -142,6 +143,7 @@ async function createClientMatrix(baseBranch: string): Promise<void> {
142143
testsToDelete,
143144
testsToStore,
144145
snippetsToStore,
146+
dockerImage: getDockerImage(language),
145147
});
146148
}
147149

0 commit comments

Comments
 (0)