Skip to content

Commit f497e1c

Browse files
committed
fix(ci): make CTS only run generated tests
1 parent 1320647 commit f497e1c

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

.github/actions/restore-artifacts/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ runs:
7171
shell: bash
7272
run: |
7373
rm -rf clients/algoliasearch-client-javascript
74-
rm -rf tests/output/javascript/src/client || true
75-
rm -rf tests/output/javascript/src/methods || true
7674
unzip -q -o clients-javascript.zip && rm clients-javascript.zip
7775
7876
# PHP
@@ -87,8 +85,6 @@ runs:
8785
shell: bash
8886
run: |
8987
rm -rf clients/algoliasearch-client-php
90-
rm -rf tests/output/php/src/client || true
91-
rm -rf tests/output/php/src/methods || true
9288
unzip -q -o clients-php.zip && rm clients-php.zip
9389
9490
# Java
@@ -103,6 +99,4 @@ runs:
10399
shell: bash
104100
run: |
105101
rm -rf clients/algoliasearch-client-java-2
106-
rm -rf tests/output/java/src/test/java/com/algolia/client || true
107-
rm -rf tests/output/java/src/test/java/com/algolia/methods || true
108102
unzip -q -o clients-java.zip && rm clients-java.zip

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ jobs:
246246
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' }}
247247
run: cd ${{ matrix.client.path }} && yarn workspace algoliasearch test
248248

249-
- name: Remove CTS output before generate
249+
- name: Remove previous CTS output
250250
run: rm -rf ${{ matrix.client.testsToDelete }} || true
251251

252252
- name: Generate CTS
@@ -278,7 +278,7 @@ jobs:
278278
run: yarn cli cts run ${{ matrix.client.language }}
279279

280280
- name: Zip artifact before storing
281-
run: zip -r -y clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsRootFolder }} -x "**/node_modules**" "**/.yarn/cache/**" "**/build/**" "**/dist/**" "**/.gradle/**" "**/bin/**" "**/vendor/**"
281+
run: zip -r -y clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsToStore }} -x "**/node_modules**" "**/.yarn/cache/**" "**/build/**" "**/dist/**" "**/.gradle/**" "**/bin/**" "**/vendor/**"
282282

283283
- name: Store ${{ matrix.client.language }} clients
284284
uses: actions/upload-artifact@v3

scripts/ci/githubActions/createMatrix.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,28 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
8686
const testsOutputBase = `${testsRootFolder}/${getTestOutputFolder(
8787
language
8888
)}`;
89-
const testsToDelete = matrix[language].toRun
89+
// We delete all tests because the CTS runs everything present in the folder
90+
// but we then re-generate the ones that needs to run
91+
const testsToDelete = `${testsOutputBase}/client ${testsOutputBase}/methods/requests`;
92+
93+
// We only store tests of clients that ran during this job, the rest stay as is
94+
let testsToStore = matrix[language].toRun
9095
.map((client) => {
9196
const clientName = createClientName(client, language);
9297
const extension = getTestExtension(language);
93-
// REMOVE THIS IN NEXT PR !!
94-
const oldPath =
95-
language === 'php' ? createClientName(client, language) : client;
96-
const tmpPath = `${testsOutputBase}/client/${oldPath}${extension} ${testsOutputBase}/methods/requests/${oldPath}${extension}`;
9798

98-
return `${testsOutputBase}/client/${clientName}${extension} ${testsOutputBase}/methods/requests/${clientName}${extension} ${tmpPath}`;
99+
return `${testsOutputBase}/client/${clientName}${extension} ${testsOutputBase}/methods/requests/${clientName}${extension}`;
99100
})
100101
.join(' ');
101102

103+
switch (language) {
104+
case 'java':
105+
testsToStore = `${testsToStore} ${testsRootFolder}/build.gradle`;
106+
break;
107+
default:
108+
break;
109+
}
110+
102111
clientMatrix.client.push({
103112
language,
104113
path: matrix[language].path,
@@ -111,6 +120,7 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
111120
]),
112121
testsRootFolder,
113122
testsToDelete,
123+
testsToStore,
114124
});
115125
console.log(`::set-output name=RUN_GEN_${language.toUpperCase()}::true`);
116126
}

scripts/ci/githubActions/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export type ClientMatrix = BaseMatrix & {
3737
* The test output path to delete before running the CTS generation.
3838
*/
3939
testsToDelete: string;
40+
/**
41+
* The test output path to store in the artifact.
42+
*/
43+
testsToStore: string;
4044
};
4145

4246
export type SpecMatrix = Pick<BaseMatrix, 'cacheKey' | 'toRun'> & {

0 commit comments

Comments
 (0)