Skip to content

Commit da63d66

Browse files
authored
chore(scripts): fix version for everything and use debian in docker (#1349)
1 parent fb83313 commit da63d66

File tree

12 files changed

+65
-22
lines changed

12 files changed

+65
-22
lines changed

.github/actions/setup/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424
uses: actions/setup-java@v3
2525
with:
2626
distribution: zulu
27-
java-version: 11.0.4
27+
java-version-file: config/.java-version
2828
cache: gradle
2929

3030
- name: Validate gradle wrapper
@@ -93,6 +93,21 @@ runs:
9393
run: cd clients/algoliasearch-client-javascript && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
9494

9595
# PHP deps
96+
- name: Get PHP version
97+
if: ${{ inputs.language == 'php' }}
98+
id: php-version
99+
shell: bash
100+
run: |
101+
# remove patch from version
102+
echo "PHP_VERSION=$(cat config/.php-version | cut -d '.' -f 1,2)" >> $GITHUB_OUTPUT
103+
104+
- name: Install PHP
105+
if: ${{ inputs.language == 'php' }}
106+
uses: shivammathur/setup-php@v2
107+
with:
108+
php-version: ${{ steps.php-version.outputs.PHP_VERSION }}
109+
tools: composer
110+
96111
- name: Run composer update
97112
if: ${{ inputs.language == 'php' }}
98113
shell: bash

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"generators/**/*.java": "docker exec -t api-clients-automation yarn cli format java generators",
2+
"generators/**/*.java": "docker exec -t api-clients-automation bash -lc \"yarn cli format java generators\"",
33
".github/**/*.yml": "yarn github-actions:lint --fix",
44
"*.json": "yarn fix:json",
55
"scripts/**/*.(js|ts)": "yarn scripts:lint --fix"

Dockerfile

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
ARG NODE_VERSION=18.14.2
2+
ARG JAVA_VERSION=11.0.18
3+
ARG PHP_VERSION=8.1.16
24

3-
FROM node:$NODE_VERSION-alpine3.17
5+
# PHP is so complicated (and long) to install that we use the docker image directly
6+
FROM php:${PHP_VERSION}-bullseye
7+
8+
ARG NODE_VERSION
9+
ARG JAVA_VERSION
410

511
ENV DOCKER=true
612

7-
RUN apk -U add openjdk11 jq bash perl build-base python3
8-
ENV JAVA_HOME=/usr/lib/jvm/default-jvm
13+
# use bash for subsequent commands
14+
SHELL ["/bin/bash", "--login", "-c"]
15+
16+
# PHP composer
17+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
18+
19+
RUN apt-get update && apt-get install -y \
20+
curl \
21+
zip \
22+
unzip \
23+
# python is used by nvm to install some packages
24+
python3 \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Javascript (node)
28+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
29+
RUN nvm install ${NODE_VERSION}
30+
RUN npm install -g yarn
31+
32+
# Java
33+
RUN curl -s "https://get.sdkman.io" | bash
34+
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
35+
RUN sdk install java ${JAVA_VERSION}-zulu
936

1037
# Java formatter
1138
ADD https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar /tmp/java-formatter.jar
1239

13-
# PHP dependencies
14-
RUN apk add -U composer php8 php8-tokenizer php8-dom php8-xml php8-xmlwriter
15-
1640
WORKDIR /app
1741

18-
CMD ["bash"]
42+
CMD bash

clients/algoliasearch-client-java-2/.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-java@v3
2424
with:
2525
distribution: zulu
26-
java-version: 11.0.4
26+
java-version-file: config/.java-version
2727
cache: gradle
2828

2929
- name: Validate gradle wrapper

config/.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.0.18

config/.php-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.1.16

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build:eslint": "yarn workspace eslint-plugin-automation-custom build && yarn install",
1313
"clean": "rm -rf **/dist **/build **/node_modules **/.gradle **/vendor || true",
1414
"cli": "yarn workspace scripts ts-node --transpile-only ./cli/index.ts",
15-
"docker": "docker exec -it api-clients-automation yarn cli $*",
15+
"docker": "docker exec -it api-clients-automation bash -lc \"yarn cli $*\"",
1616
"docker:build": "./scripts/docker/build.sh",
1717
"docker:clean": "docker stop api-clients-automation; docker rm -f api-clients-automation; docker image rm -f api-clients-automation",
1818
"docker:mount": "./scripts/docker/mount.sh",

scripts/cts/runCts.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CI, run, runComposerUpdate } from '../common';
1+
import { run, runComposerUpdate } from '../common';
22
import { createSpinner } from '../oraLog';
33

44
async function runCtsOne(language: string, verbose: boolean): Promise<void> {
@@ -23,10 +23,8 @@ async function runCtsOne(language: string, verbose: boolean): Promise<void> {
2323
break;
2424
case 'php': {
2525
await runComposerUpdate(verbose);
26-
let php = 'php8';
27-
if (CI) php = 'php';
2826
await run(
29-
`${php} ./clients/algoliasearch-client-php/vendor/bin/phpunit tests/output/php`,
27+
`php ./clients/algoliasearch-client-php/vendor/bin/phpunit tests/output/php`,
3028
{ verbose }
3129
);
3230
break;

scripts/docker/build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)/../.."
44

55
cd $ROOT
66

7+
JAVA_VERSION=$(cat config/.java-version)
78
NODE_VERSION=$(cat .nvmrc)
9+
PHP_VERSION=$(cat config/.php-version)
810

9-
docker build --build-arg NODE_VERSION=$NODE_VERSION -t api-clients-automation .
11+
docker build \
12+
--build-arg JAVA_VERSION=$JAVA_VERSION \
13+
--build-arg NODE_VERSION=$NODE_VERSION \
14+
--build-arg PHP_VERSION=$PHP_VERSION \
15+
-t api-clients-automation .

scripts/formatter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CI, run, runComposerUpdate } from './common';
1+
import { run, runComposerUpdate } from './common';
22
import { createSpinner } from './oraLog';
33

44
export async function formatter(
@@ -27,9 +27,7 @@ export async function formatter(
2727
case 'php':
2828
await runComposerUpdate(verbose);
2929
cmd = `yarn run prettier ${folder} --write \
30-
&& PHP_CS_FIXER_IGNORE_ENV=1 ${
31-
CI ? 'php' : 'php8'
32-
} clients/algoliasearch-client-php/vendor/bin/php-cs-fixer fix ${folder} --using-cache=no --allow-risky=yes`;
30+
&& PHP_CS_FIXER_IGNORE_ENV=1 php clients/algoliasearch-client-php/vendor/bin/php-cs-fixer fix ${folder} --using-cache=no --allow-risky=yes`;
3331
break;
3432
default:
3533
return;

scripts/playground.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function playground({
3232
composer update && \
3333
composer dump-autoload && \
3434
cd ../../playground/php/src && \
35-
php8 ${client}.php`,
35+
php ${client}.php`,
3636
{ verbose }
3737
);
3838
break;

templates/javascript/clients/client/api/hosts.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#hasRegionalHost}}
22
export const REGIONS = [{{#allowedRegions}}'{{.}}'{{^-last}},{{/-last}}{{/allowedRegions}}] as const;
3-
export type Region = typeof REGIONS[number];
3+
export type Region = (typeof REGIONS)[number];
44
{{/hasRegionalHost}}
55

66
{{^hasRegionalHost}}

0 commit comments

Comments
 (0)