Skip to content

Commit

Permalink
chore: loose cache key computing by including CTS (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Apr 19, 2023
1 parent 4f150f7 commit e195668
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/ci/githubActions/setRunVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const JAVA_CLIENT_FOLDER = getLanguageFolder('java');
const PHP_CLIENT_FOLDER = getLanguageFolder('php');
const GO_CLIENT_FOLDER = getLanguageFolder('go');

// Files that are common to every clients
// Files that are common to every clients, this is used to determine if we should generate the matrix for this job.
const CLIENTS_COMMON_FILES = [
'config/openapitools.json',
'config/clients.config.json',
Expand Down Expand Up @@ -63,18 +63,21 @@ export const DEPENDENCIES = {
JAVA_CLIENT_CHANGED: [
...CLIENTS_COMMON_FILES,
JAVA_CLIENT_FOLDER,
'config/.java-version',
'templates/java',
'generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java',
],
PHP_CLIENT_CHANGED: [
...CLIENTS_COMMON_FILES,
PHP_CLIENT_FOLDER,
'config/.php-version',
'templates/php',
'generators/src/main/java/com/algolia/codegen/AlgoliaPhpGenerator.java',
],
GO_CLIENT_CHANDED: [
...CLIENTS_COMMON_FILES,
GO_CLIENT_FOLDER,
'config/.go-version',
'templates/go',
'generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java',
],
Expand Down
16 changes: 14 additions & 2 deletions scripts/ci/githubActions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,30 @@ const commonCacheKey = (async function (): Promise<string> {
const scriptsHash = await hashElement(toAbsolutePath('scripts'), {
encoding: 'hex',
folders: { exclude: ['docker', '__tests__'] },
files: { include: ['**'] },
});
const configHash = await hashElement(toAbsolutePath('.'), {
encoding: 'hex',
folders: { include: ['config'] },
files: { include: ['openapitools.json', 'clients.config.json'] },
files: {
include: [
'openapitools.json',
'clients.config.json',
'base.tsconfig.json',
],
},
});
const ctsHash = await hashElement(toAbsolutePath('tests'), {
encoding: 'hex',
folders: { include: ['CTS'] },
files: { include: ['**'] },
});
const depsHash = await hashElement(toAbsolutePath('.'), {
encoding: 'hex',
files: { include: ['yarn.lock'] },
});

return `${ghHash.hash}-${scriptsHash.hash}-${configHash.hash}-${depsHash}`;
return `${ghHash.hash}-${scriptsHash.hash}-${configHash.hash}-${depsHash.hash}-${ctsHash.hash}`;
})();

/**
Expand Down

0 comments on commit e195668

Please sign in to comment.