Skip to content

Commit

Permalink
chore: CI generated commit hash and no gen comment (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Jul 2, 2024
1 parent 01ef934 commit 5c07d4e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
### 🔨 The generated code will be pushed at the end of the CI.
### 🪓 The generated code will be pushed at the end of the CI.
Action triggered by commit [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}).
Expand Down Expand Up @@ -472,13 +472,24 @@ jobs:

- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT == '' }}
with:
message: |
### No code generated
_If you believe code should've been generated, please, [report the issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=bug%2Ctriage&projects=&template=Bug_report.yml&title=%5Bbug%5D%3A+)._
- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT != '' }}
with:
message: |
### ✔️ Code generated!
| Name | Link |
|---------------------------------|------------------------|
| 🔨 Triggered by | [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}) |
| 🪓 Triggered by | [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}) |
| 🍃 Generated commit | [`${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}) |
| 🌲 Generated branch | [`generated/${{ github.head_ref }}`](${{ github.event.pull_request.base.repo.html_url }}/tree/generated/${{ github.head_ref }}) |
- name: Spread generation to each repository
Expand Down
4 changes: 4 additions & 0 deletions scripts/ci/codegen/pushGeneratedCode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-console */
import { setOutput } from '@actions/core';

import { configureGitHubAuthor, ensureGitHubToken, MAIN_BRANCH, run } from '../../common.js';
import { getNbGitDiff } from '../utils.js';

Expand Down Expand Up @@ -76,6 +78,8 @@ Co-authored-by: %an <%ae>
await run('git add .');
await run(`git commit -m "${message}"`);
await run(`git push origin ${branchToPush}`);

setOutput('GENERATED_COMMIT', await run('git rev-parse HEAD'));
}

if (import.meta.url.endsWith(process.argv[1])) {
Expand Down
18 changes: 9 additions & 9 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-case-declarations */
import * as core from '@actions/core';
import { setOutput } from '@actions/core';

import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common.js';
import { getLanguageFolder, getTestExtension, getTestOutputFolder } from '../../config.js';
Expand Down Expand Up @@ -139,31 +139,31 @@ async function createClientMatrix(baseBranch: string): Promise<void> {
// If there are updates for the Swift client, we allow ourselves to run the CTS on macOS
const swiftData = clientMatrix.client.find((c) => c.language === 'swift');
if (swiftData) {
core.setOutput('SWIFT_DATA', JSON.stringify(swiftData));
core.setOutput('RUN_MACOS_SWIFT_CTS', true);
setOutput('SWIFT_DATA', JSON.stringify(swiftData));
setOutput('RUN_MACOS_SWIFT_CTS', true);
}

// If there are updates for the Kotlin client, we allow ourselves to run the build step on macOS
const runKotlin = clientMatrix.client.find((c) => c.language === 'kotlin');
if (runKotlin) {
core.setOutput('RUN_MACOS_KOTLIN_BUILD', true);
setOutput('RUN_MACOS_KOTLIN_BUILD', true);
}

const javascriptData = clientMatrix.client.find((c) => c.language === 'javascript');
if (javascriptData) {
core.setOutput('JAVASCRIPT_DATA', JSON.stringify(javascriptData));
core.setOutput('RUN_GEN_JAVASCRIPT', true);
setOutput('JAVASCRIPT_DATA', JSON.stringify(javascriptData));
setOutput('RUN_GEN_JAVASCRIPT', true);
clientMatrix.client = clientMatrix.client.filter((c) => c.language !== 'javascript');
}

const shouldRun = clientMatrix.client.length > 0;

core.setOutput('RUN_GEN', shouldRun);
core.setOutput('GEN_MATRIX', JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX));
setOutput('RUN_GEN', shouldRun);
setOutput('GEN_MATRIX', JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX));
}

function createSpecMatrix(): void {
core.setOutput(
setOutput(
'MATRIX',
JSON.stringify({
bundledPath: 'specs/bundled',
Expand Down

0 comments on commit 5c07d4e

Please sign in to comment.