Skip to content

Commit

Permalink
Merge branch 'main' into feat/helper-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Jun 11, 2024
2 parents 608a212 + 072c38b commit 2207ebe
Show file tree
Hide file tree
Showing 6,712 changed files with 333,449 additions and 203,212 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
7 changes: 4 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
'**/target',
'**/.yarn',
'website/specs',
'**/project.packagespec.json'
'**/project.packagespec.json',
],

overrides: [
Expand Down Expand Up @@ -52,6 +52,7 @@ module.exports = {
files: ['specs/**/*.yml'],
rules: {
'automation-custom/end-with-dot': 'error',
'automation-custom/no-final-dot': 'error',
'automation-custom/single-quote-ref': 'error',
},
overrides: [
Expand Down Expand Up @@ -149,7 +150,7 @@ module.exports = {

parserOptions: {
tsconfigRootDir: __dirname,
project: './clients/algoliasearch-client-javascript/tsconfig.json'
project: './clients/algoliasearch-client-javascript/tsconfig.json',
},

rules: {
Expand Down Expand Up @@ -183,6 +184,6 @@ module.exports = {
rules: {
'automation-custom/no-new-line': 'error',
},
}
},
],
};
1 change: 0 additions & 1 deletion .github/.cache_version

This file was deleted.

33 changes: 15 additions & 18 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ inputs:
runs:
using: composite
steps:
- name: Read current GitHub Actions cache version
shell: bash
run: |
echo "CACHE_VERSION=$(< .github/.cache_version)" >> $GITHUB_ENV
# Java for code generation
- name: Install Java
if: inputs.type != 'minimal'
uses: actions/setup-java@v4
uses: actions/setup-java@v4.2.1
with:
distribution: zulu
java-version-file: config/.java-version

- name: Validate gradle wrapper
if: inputs.type != 'minimal'
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Setup gradle
if: inputs.type != 'minimal'
Expand All @@ -39,7 +34,7 @@ runs:
- name: Download Java formatter
if: inputs.type != 'minimal'
shell: bash
run: curl --retry 3 -L "https://github.com/google/google-java-format/releases/download/v1.20.0/google-java-format-1.20.0-all-deps.jar" > /tmp/java-formatter.jar
run: curl --retry 3 -L "https://github.com/google/google-java-format/releases/download/v1.22.0/google-java-format-1.22.0-all-deps.jar" > /tmp/java-formatter.jar

# JavaScript for monorepo and tooling
- name: Install Node
Expand All @@ -57,8 +52,7 @@ runs:
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir.outputs.dir || '.yarn/cache' }}
# let yarn handle the cache hash
key: yarn-cache-${{ env.CACHE_VERSION }}
key: yarn-cache-monorepo-${{ hashFiles('yarn.lock') }}

- name: Install JavaScript dependencies
shell: bash
Expand Down Expand Up @@ -93,15 +87,14 @@ runs:
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-client.outputs.dir || 'clients/algoliasearch-client-javascript/.yarn/cache' }}
# let yarn handle the cache hash
key: yarn-cache-client-${{ env.CACHE_VERSION }}
key: yarn-cache-clients-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}

- name: Cache js-client node modules
if: ${{ inputs.language == 'javascript' }}
uses: actions/cache@v4
with:
path: clients/algoliasearch-client-javascript/node_modules
key: node-modules-client-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}
key: node-modules-clients-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}

- name: Install JavaScript client dependencies
if: ${{ inputs.language == 'javascript' }}
Expand Down Expand Up @@ -135,7 +128,7 @@ runs:
if: ${{ inputs.language == 'go' }}
shell: bash
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
go install golang.org/x/tools/cmd/goimports@latest
Expand All @@ -144,15 +137,15 @@ runs:
uses: actions/cache@v4
with:
path: ~/.cache/golangci-lint
key: golangci-lint-${{ env.CACHE_VERSION }}-${{ steps.versions.outputs.GO_VERSION }}-${{ hashFiles('clients/algoliasearch-client-go/go.sum') }}
key: golangci-lint-${{ steps.versions.outputs.GO_VERSION }}-${{ hashFiles('clients/algoliasearch-client-go/go.sum') }}

# Kotlin
- name: Cache spotless
if: ${{ inputs.language == 'kotlin' }}
uses: actions/cache@v4
with:
path: clients/algoliasearch-client-kotlin/client/build/spotless
key: spotless-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-kotlin/build.gradle.kts') }}
key: spotless-${{ hashFiles('clients/algoliasearch-client-kotlin/build.gradle.kts') }}

# Dart
- name: Install dart
Expand Down Expand Up @@ -201,7 +194,11 @@ runs:
# Swift deps
- name: Install swift
if: ${{ inputs.language == 'swift' }}
uses: swift-actions/setup-swift@v1
# WORKAROUND for: https://github.com/swift-actions/setup-swift/issues/591
# BY GitHub Staff developer: redsun82
# IN pull request: https://github.com/github/codeql/pull/16153
# uses: swift-actions/setup-swift@v2
uses: redsun82/setup-swift@b2b6f77ab14f6a9b136b520dc53ec8eca27d2b99
with:
swift-version: ${{ steps.versions.outputs.SWIFT_VERSION }}

Expand All @@ -219,7 +216,7 @@ runs:
uses: actions/cache@v4
with:
path: swiftformat/.build
key: swiftformat-build-0.53.0-${{ runner.os }}-${{ env.CACHE_VERSION }}
key: swiftformat-build-0.53.0-${{ runner.os }}

- name: Build swiftformat
if: ${{ inputs.language == 'swift' && steps.cache-swiftformat.outputs.cache-hit != 'true' }}
Expand Down
105 changes: 60 additions & 45 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
diff=$(git status --porcelain ./scripts/ci/actions | wc -l)
if [[ $diff > 0 ]]; then
echo "Build the custom github actions by running `yarn workspace scripts build:actions`"
echo "Build the custom github actions by running \`yarn workspace scripts build:actions\`"
fi
exit $diff
Expand Down Expand Up @@ -96,6 +96,9 @@ jobs:
JAVASCRIPT_DATA: ${{ steps.gen-matrix.outputs.JAVASCRIPT_DATA }}
RUN_GEN_JAVASCRIPT: ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT }}

SWIFT_DATA: ${{ steps.gen-matrix.outputs.SWIFT_DATA }}
RUN_MACOS_SWIFT_CTS: ${{ steps.gen-matrix.outputs.RUN_MACOS_SWIFT_CTS }}

scripts:
runs-on: ubuntu-22.04
timeout-minutes: 10
Expand Down Expand Up @@ -125,21 +128,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache bundled specs
id: cache
uses: actions/cache@v4
with:
key: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).cacheKey }}
path: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).bundledPath }}

- name: Setup
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/setup
with:
type: minimal

- name: Building specs
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }}

- name: Store bundled specs
Expand Down Expand Up @@ -170,7 +164,7 @@ jobs:
uses: actions/cache@v4
with:
key: |
${{ matrix.client }}-${{ env.CACHE_VERSION }}-${{ hashFiles(
${{ matrix.client }}-${{ hashFiles(
format('clients/algoliasearch-client-javascript/packages/{0}/**', matrix.client),
'clients/algoliasearch-client-javascript/yarn.lock'
)}}
Expand Down Expand Up @@ -215,22 +209,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache clients folder
if: ${{ github.ref != 'refs/heads/main' }}
id: cache
uses: actions/cache@v4
with:
key: ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).cacheKey }}
path: ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).path }}

- name: Download specs artifacts
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ./scripts/ci/actions/restore-artifacts
with:
type: specs

- name: Remove generated clients
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(env.head_ref, 'chore/prepare-release-') }}
if: ${{ startsWith(env.head_ref, 'chore/prepare-release-') }}
run: |
cd clients/algoliasearch-client-javascript/packages
ls | grep -v -E "(client-common|requester-*|algoliasearch)" | xargs rm -rf
Expand All @@ -243,22 +228,20 @@ jobs:
language: javascript

- name: Generate clients
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: yarn cli generate javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}

- name: Update `yarn.lock` for JavaScript
run: cd clients/algoliasearch-client-javascript && YARN_ENABLE_HARDENED_MODE=0 YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install

- name: Build clients
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).buildCommand }}

- name: Test JavaScript bundle size
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(env.head_ref, 'chore/prepare-release-') }}
if: ${{ startsWith(env.head_ref, 'chore/prepare-release-') }}
run: cd clients/algoliasearch-client-javascript && yarn test:size

- name: Run JavaScript 'algoliasearch' client tests
if: ${{ steps.cache.outputs.cache-hit != 'true' && contains(fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun,'algoliasearch') }}
if: ${{ contains(fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun,'algoliasearch') }}
run: cd clients/algoliasearch-client-javascript && yarn workspace algoliasearch test

- name: Remove previous CTS output
Expand All @@ -277,14 +260,13 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-tests.outputs.dir || 'tests/output/javascript/.yarn/cache' }}
# let yarn handle the cache hash
key: yarn-cache-tests-${{ env.CACHE_VERSION }}
key: yarn-cache-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}

- name: Cache js tests node modules
uses: actions/cache@v4
with:
path: tests/output/javascript/node_modules
key: node-modules-tests-${{ env.CACHE_VERSION }}-${{ hashFiles('tests/output/javascript/yarn.lock') }}
key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}

- name: Run CTS
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
Expand All @@ -304,7 +286,7 @@ jobs:

client_gen:
timeout-minutes: 20
runs-on: 'ubuntu-22.04'
runs-on: ubuntu-22.04
needs:
- setup
- specs
Expand All @@ -324,16 +306,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache clients folder
if: ${{ github.ref != 'refs/heads/main' }}
id: cache
uses: actions/cache@v4
with:
key: ${{ matrix.client.cacheKey }}
path: ${{ matrix.client.path }}

- name: Download specs artifacts
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ./scripts/ci/actions/restore-artifacts
with:
type: specs
Expand All @@ -344,19 +317,25 @@ jobs:
language: ${{ matrix.client.language }}

- name: Generate clients
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: yarn cli generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}

- name: Update composer.lock
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'php' && startsWith(env.head_ref, 'chore/renovateBaseBranch') }}
if: ${{ matrix.client.language == 'php' && startsWith(env.head_ref, 'chore/renovateBaseBranch') }}
run: cd ${{ matrix.client.path }} && composer update

- name: Check for file duplicates in Swift
if: ${{ matrix.client.language == 'swift' }}
run: |
set -eo pipefail
cd clients/algoliasearch-client-swift
find Sources -type f | rev | cut -d '/' -f1 | rev | sort | uniq -d
[ $(find Sources -type f | rev | cut -d '/' -f1 | rev | sort | uniq -d | wc -l) -gt 0 ] && echo "Duplicates found" && exit 1 || echo "No duplicate found"
- name: Build clients
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: ${{ matrix.client.buildCommand }}

- name: Run Java 'algoliasearch' public API validation
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'java' }}
if: ${{ matrix.client.language == 'java' }}
run: |
cd ${{ matrix.client.path }}
./gradlew :api:japicmp || exit 0
Expand Down Expand Up @@ -389,15 +368,53 @@ jobs:
name: clients-${{matrix.client.language }}
path: clients-${{matrix.client.language }}.zip

swift_cts_macos:
timeout-minutes: 20
runs-on: macos-latest
needs:
- setup
- client_gen
if: |
always() &&
startsWith(github.head_ref, 'chore/prepare-release-') &&
needs.setup.outputs.RUN_GEN == 'true' &&
needs.setup.outputs.RUN_MACOS_SWIFT_CTS == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
env:
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
MONITORING_API_KEY: ${{ secrets.MONITORING_API_KEY }}
steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: languages
languages: |
swift
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
language: swift

- name: Run CTS
run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }}

codegen:
runs-on: ubuntu-22.04
timeout-minutes: 15
needs:
- setup
- client_gen
- client_gen_javascript
- swift_cts_macos
if: |
always() &&
(needs.swift_cts_macos.result == 'success' || needs.swift_cts_macos.result == 'skipped') &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
outputs:
Expand All @@ -410,7 +427,6 @@ jobs:
token: ${{ secrets.ALGOLIA_BOT_TOKEN }}

- name: Download all artifacts
if: ${{ needs.setup.outputs.RUN_GEN == 'true' || needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' }}
uses: ./scripts/ci/actions/restore-artifacts
with:
type: all
Expand All @@ -421,14 +437,13 @@ jobs:
type: minimal

- name: Generate documentation specs with code snippets
if: ${{ needs.setup.outputs.RUN_GEN == 'true' || needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' }}
run: yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }} --docs

- name: Build website
run: yarn website:build

- name: Deploy documentation
uses: nwtgck/actions-netlify@v2.1
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: 'website/build'
production-branch: main
Expand Down
Loading

0 comments on commit 2207ebe

Please sign in to comment.