Skip to content

Commit adf323c

Browse files
authored
chore(ci): generate the CTS on the CI (#489)
1 parent 6e0f6d9 commit adf323c

File tree

8 files changed

+21
-23
lines changed

8 files changed

+21
-23
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ runs:
6262
- name: Unzip clients-javascript artifact
6363
if: ${{ inputs.javascript == 'true' && inputs.type == 'all' }}
6464
shell: bash
65-
run: unzip -q -o clients-javascript.zip
65+
run: unzip -q -o clients-javascript.zip && rm clients-javascript.zip
6666

6767
# PHP
6868
- name: Download clients-php artifact
@@ -74,7 +74,7 @@ runs:
7474
- name: Unzip clients-php artifact
7575
if: ${{ inputs.php == 'true' && inputs.type == 'all' }}
7676
shell: bash
77-
run: unzip -q -o clients-php.zip
77+
run: unzip -q -o clients-php.zip && rm clients-php.zip
7878

7979
# Java
8080
- name: Download clients-java artifact
@@ -86,4 +86,4 @@ runs:
8686
- name: Unzip clients-java artifact
8787
if: ${{ inputs.java == 'true' && inputs.type == 'all' }}
8888
shell: bash
89-
run: unzip -q -o clients-java.zip
89+
run: unzip -q -o clients-java.zip && rm clients-java.zip

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ runs:
9393
id: js-utils
9494
shell: bash
9595
run: |
96-
if [[ ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT || steps.diff.outputs.JS_ALGOLIASEARCH_CHANGED > 0 }} ]]; then
96+
if ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT || steps.diff.outputs.JS_ALGOLIASEARCH_CHANGED > 0 }}; then
9797
echo "Running algoliasearch: true"
9898
echo "::set-output name=RUN_JS_ALGOLIASEARCH::true"
9999
fi
100100
101-
if [[ ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT || steps.diff.outputs.JAVASCRIPT_UTILS_CHANGED > 0 }} ]]; then
101+
if ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT || steps.diff.outputs.JAVASCRIPT_UTILS_CHANGED > 0 }}; then
102102
echo "Running JavaScript utils: true"
103103
echo "::set-output name=RUN_JS_UTILS::true"
104104
fi

.github/workflows/check.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,16 @@ jobs:
217217
run: yarn cli build clients ${{ matrix.client.language }} ${{ matrix.client.toRun }}
218218

219219
- name: Clean CTS output before generate
220-
run: rm -rf ${{ matrix.client.testsOutputPathToClean }} || true
220+
run: rm -rf ${{ matrix.client.testsOutputPath }} || true
221221

222222
- name: Generate CTS
223223
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}
224224

225-
- name: Check diff with pushed CTS
226-
run: |
227-
git --no-pager diff -- ${{ matrix.client.testsOutputPathToClean }}
228-
exit $(git diff --name-only --diff-filter=d ${{ matrix.client.testsOutputPathToClean }} | wc -l)
229-
230225
- name: Run CTS
231226
run: yarn cli cts run ${{ matrix.client.language }}
232227

233228
- name: Zip artifact before storing
234-
run: zip -q -r clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} -x "${{ matrix.client.path }}/node_modules/.**"
229+
run: zip -q -r clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsOutputPath }} -x "${{ matrix.client.path }}/node_modules/.**"
235230

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

config/generation.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ module.exports = {
1717
'!clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/exceptions/**',
1818
'!clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/**',
1919

20+
'tests/output/java/src/test/java/com/algolia/methods/**', // this could be added automatically by the script, but with overhead
21+
'tests/output/java/src/test/java/com/algolia/client/**',
22+
2023
// JavaScript
2124
'!clients/algoliasearch-client-javascript/*',
2225
'!clients/algoliasearch-client-javascript/.github/**',
@@ -26,6 +29,9 @@ module.exports = {
2629
'!clients/algoliasearch-client-javascript/packages/requester-*/**',
2730
'!clients/algoliasearch-client-javascript/packages/client-common/**',
2831

32+
'tests/output/javascript/src/methods/**',
33+
'tests/output/javascript/src/client/**',
34+
2935
// PHP
3036
'!clients/algoliasearch-client-php/*',
3137
'!clients/algoliasearch-client-php/.*',
@@ -39,5 +45,8 @@ module.exports = {
3945
'!clients/algoliasearch-client-php/lib/Support/**',
4046
'!clients/algoliasearch-client-php/lib/Configuration/ConfigWithRegion.php',
4147
'clients/algoliasearch-client-php/lib/Configuration/Configuration.php',
48+
49+
'tests/output/php/src/methods/**',
50+
'tests/output/php/src/client/**',
4251
],
4352
};

scripts/ci/codegen/pushGeneratedCode.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { getNbGitDiff } from '../utils';
66
import text from './text';
77

88
const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10);
9-
const FOLDERS_TO_CHECK =
10-
'yarn.lock config/openapitools.json clients specs/bundled';
119

1210
async function isUpToDate(baseBranch: string): Promise<boolean> {
1311
await run('git fetch origin');
@@ -33,7 +31,6 @@ export async function pushGeneratedCode(): Promise<void> {
3331
const nbDiff = await getNbGitDiff({
3432
branch: baseBranch,
3533
head: null,
36-
path: FOLDERS_TO_CHECK,
3734
});
3835

3936
if (nbDiff === 0) {
@@ -46,7 +43,7 @@ export async function pushGeneratedCode(): Promise<void> {
4643
return;
4744
}
4845

49-
console.log(`${nbDiff} changes found for ${FOLDERS_TO_CHECK}`);
46+
console.log(`${nbDiff} changes found`);
5047

5148
// determine generated branch name based on current branch
5249
const branchToPush = isMainBranch ? baseBranch : `generated/${baseBranch}`;
@@ -72,10 +69,8 @@ export async function pushGeneratedCode(): Promise<void> {
7269
Co-authored-by: %an <%ae>
7370
%(trailers:key=Co-authored-by)"`);
7471

75-
console.log(
76-
`Pushing code for folders '${FOLDERS_TO_CHECK}' to generated branch: '${branchToPush}'`
77-
);
78-
await run(`git add ${FOLDERS_TO_CHECK}`);
72+
console.log(`Pushing code to generated branch: '${branchToPush}'`);
73+
await run(`git add .`);
7974
await run(`git commit -m "${commitMessage}"`);
8075
await run(`git push origin ${branchToPush}`);
8176

scripts/ci/githubActions/createMatrix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
9797
`templates/${language}`,
9898
`generators/src`,
9999
]),
100-
testsOutputPathToClean: `${testOutputBase}/client ${testOutputBase}/methods`,
100+
testsOutputPath: `${testOutputBase}/client ${testOutputBase}/methods`,
101101
});
102102
console.log(`::set-output name=RUN_GEN_${language.toUpperCase()}::true`);
103103
}

scripts/ci/githubActions/setRunVariables.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const COMMON_DEPENDENCIES = {
4242
*/
4343
export const DEPENDENCIES = {
4444
...COMMON_DEPENDENCIES,
45-
TESTS_CHANGED: ['tests'],
4645
JS_ALGOLIASEARCH_CHANGED: [
4746
`${JS_CLIENT_FOLDER}/packages/algoliasearch`,
4847
`${JS_CLIENT_FOLDER}/packages/client-search`,

scripts/ci/githubActions/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type ClientMatrix = BaseMatrix & {
3232
/**
3333
* The test output path to clean.
3434
*/
35-
testsOutputPathToClean: string;
35+
testsOutputPath: string;
3636
};
3737

3838
export type SpecMatrix = BaseMatrix & {

0 commit comments

Comments
 (0)