Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ yarn build:bk:types

echo '--- Updating commit status for jobs'

npx ts-node scripts/pre_command.ts
# npx ts-node scripts/pre_command.ts

cd '../'
60 changes: 32 additions & 28 deletions .buildkite/scripts/pre_exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

import { execSync } from 'child_process';

import { yarnInstall } from './../utils/exec';
import { bkEnv, buildkiteGQLQuery, codeCheckIsCompleted, getJobMetadata, updateCheckStatus } from '../utils';

Expand All @@ -15,36 +17,38 @@ void (async function () {
const { checkId, jobId, jobUrl } = bkEnv;

if (checkId && jobId && !skipChecks.has(checkId)) {
await yarnInstall();
const jobStatus = await getJobStatus(jobId);

if (jobStatus) {
if (jobStatus.state === 'CANCELING') {
const user = getCancelledBy(jobStatus.events ?? []);
await updateCheckStatus(
{
status: 'completed',
conclusion: 'cancelled',
details_url: jobUrl,
},
checkId,
user && `Cancelled by ${user}`,
);
} else {
const isFailedJob = (await getJobMetadata('failed')) === 'true';
let root = process.cwd();
try {
root = execSync(`git rev-parse --show-toplevel`).toString().trim();
} catch (error: unknown) {
console.error(`Failed to get git root directory, falling back to current directory: ${process.cwd()}`, error);
}
const nodeModuleLsBefore = execSync(`ls -la ${root}/node_modules | head -n 10`);
console.log(`nodeModuleLsBefore: ${nodeModuleLsBefore}`);
const ee = await yarnInstall().catch((error) => {
console.error(`Failed to install dependencies`, error);
return error;
});
const nodeModuleLsAfter = execSync(`ls -la ${root}/node_modules | head -n 10`);
console.log(`nodeModuleLsAfter: ${nodeModuleLsAfter}`);

if (isFailedJob || !(await codeCheckIsCompleted())) {
await updateCheckStatus(
{
status: 'completed',
conclusion: isFailedJob ? 'failure' : 'success',
details_url: jobUrl,
},
checkId,
);
}
}
if (ee instanceof Error) {
console.error(`Failed to install dependencies`);
throw ee;
}

// if (isFailedJob || !(await codeCheckIsCompleted())) {
// await updateCheckStatus(
// {
// status: 'completed',
// conclusion: isFailedJob ? 'failure' : 'success',
// details_url: jobUrl,
// },
// checkId,
// );
// }
// }
// }
}
})();

Expand Down
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { bkEnv, startGroup } from '../../utils/buildkite';
import { ChangeContext } from '../../utils/github';

void (async () => {
return;
const changes = new ChangeContext();
await changes.init();
const hasLintConfigChanges = changes.files.has([
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/scripts/steps/ghp_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ void (async () => {
const outDir = '.out';

const docsSrc = '.buildkite/artifacts/docs/github.gz';
await downloadArtifacts(docsSrc, 'build_docs');
await downloadArtifacts(docsSrc, 'build_docs', '.', '019e4dc0-7d1d-4d4f-acc2-90db437e2e67');
await decompress({
src: docsSrc,
dest: outDir,
});

const storybookSrc = '.buildkite/artifacts/storybook.gz';
await downloadArtifacts(storybookSrc, 'build_storybook');
await downloadArtifacts(storybookSrc, 'build_storybook', '.', '019e4dc0-7d1d-4d4f-acc2-90db437e2e67');
await decompress({
src: storybookSrc,
dest: path.join(outDir, 'storybook'),
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/ghp_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { CustomCommandStep } from '../utils';
import { createStep, commandStepDefaults, bkEnv } from '../utils';

export const ghpDeployStep = createStep<CustomCommandStep>(() => {
const isMainBranch = bkEnv.isMainBranch;
const isMainBranch = true;

return {
...commandStepDefaults,
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/utils/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getBuildConfig = (): BuildConfig => {
{ name: 'Eslint', id: 'eslint' },
{ name: 'Prettier', id: 'prettier' },
{ name: 'Deploy - firebase', id: 'deploy_fb' },
...(bkEnv.isMainBranch ? [{ name: 'Deploy - GitHub Pages', id: 'deploy_ghp' }] : []),
// ...(bkEnv.isMainBranch ? [{ name: 'Deploy - GitHub Pages', id: 'deploy_ghp' }] : []),
{ name: 'Jest', id: 'jest' },
{ name: 'Playwright e2e VRT', id: 'playwright_vrt' },
{ name: 'Playwright e2e A11Y', id: 'playwright_a11y' },
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/utils/buildkite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const bkEnv = (() => {
const branch = bkBranch && bkBranch.split(':').reverse()[0];
const pullRequestNumber = getEnvNumber('BUILDKITE_PULL_REQUEST');
const checkId = getEnvString(ECH_CHECK_ID);
const isPullRequest = Boolean(pullRequestNumber);
const isPullRequest = false && Boolean(pullRequestNumber);
let username: string | undefined;

if (isPullRequest) {
Expand Down
11 changes: 10 additions & 1 deletion .buildkite/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

import { execSync } from 'child_process';

import type { StrategyOptions } from '@octokit/auth-app';
import { createAppAuth } from '@octokit/auth-app';
import type { components } from '@octokit/openapi-types';
Expand Down Expand Up @@ -377,6 +379,11 @@ export async function ghpDeploy(outDir: string) {
});

await new Promise<void>((resolve, reject) => {
console.log(`publishing to github pages: ${outDir}`);
const lsResult = execSync(`ls -la ${outDir}`);
console.log(`lsResult: ${lsResult}`);
const nodeModuleLsBefore = execSync(`ls -la /app/node_modules | head -n 10`);
console.log(`nodeModuleLsBefore: ${nodeModuleLsBefore}`);
ghpages.publish(
outDir,
{
Expand All @@ -385,7 +392,7 @@ export async function ghpDeploy(outDir: string) {
email: '98618603+elastic-datavis[bot]@users.noreply.github.com',
},
silent: false,
branch: 'gh-pages',
branch: 'gh-pages-test',
message: `Deploying ${bkEnv.commit ?? 'latest changes'} 🚀`,
repo: `https://git:${token}@github.com/elastic/elastic-charts.git`,
},
Expand All @@ -394,6 +401,8 @@ export async function ghpDeploy(outDir: string) {
else resolve();
},
);
const nodeModuleLsAfter = execSync(`ls -la /app/node_modules | head -n 10`);
console.log(`nodeModuleLsAfter: ${nodeModuleLsAfter}`);
});
}

Expand Down
7 changes: 7 additions & 0 deletions .buildkite/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ export async function getChartsPackageMetadata(required: boolean = false): Promi

if (!liveTarballFilename || !commitTarballFilename || !version || !commitSha || !commitShortSha) {
if (required) {
console.error('Failed to find complete charts package metadata', {
liveTarballFilename,
commitTarballFilename,
version,
commitSha,
commitShortSha,
});
throw new Error('Failed to find complete charts package metadata');
}

Expand Down