Skip to content

Commit

Permalink
wipwip
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrozenberg committed Feb 27, 2024
1 parent d8ab82c commit 523cc64
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 291 deletions.
87 changes: 44 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ experiment_job: &experiment_job
environment:
FLAVOR: experiment<< parameters.exp >>

dist_job: &dist_job
parameters:
module:
description: 'Whether to build Module or Nomodule'
type: enum
enum: ['Module', 'Nomodule']
purpose:
description: 'What is the downstream purpose of this build'
type: enum
enum: ['Test', 'Bundle Size']

executors:
base-docker-small:
docker:
Expand Down Expand Up @@ -236,45 +247,26 @@ jobs:
name: '⭐⭐⭐ Unminified Build ⭐⭐⭐'
command: node build-system/pr-check/unminified-build.js
- teardown_vm
nomodule_build_test:
executor:
name: node-docker-xlarge
parallelism: 6
steps:
- setup_vm
- run:
name: '⭐⭐⭐ Nomodule Build ⭐⭐⭐'
command: node build-system/pr-check/nomodule-build.js
- teardown_vm
module_build_test:
executor:
name: node-docker-xlarge
parallelism: 6
steps:
- setup_vm
- run:
name: '⭐⭐⭐ Module Build ⭐⭐⭐'
command: node build-system/pr-check/module-build.js
- teardown_vm
nomodule_build_bundle_size:
dist:
executor:
name: node-docker-xlarge
parallelism: 6
<<: *dist_job
parallelism: 4
steps:
- setup_vm
- run:
name: '⭐⭐⭐ Nomodule Build ⭐⭐⭐'
command: node build-system/pr-check/bundle-size-nomodule-build.js
name: '⭐⭐⭐ << parameters.module >> Build (<< parameters.purpose >>) ⭐⭐⭐'
command: node build-system/pr-check/dist.js --type "<< parameters.module >> Build (<< parameters.purpose >>)"
- teardown_vm
module_build_bundle_size:
dist_3p:
executor:
name: node-docker-xlarge
parallelism: 6
<<: *dist_job
steps:
- setup_vm
- run:
name: '⭐⭐⭐ Module Build ⭐⭐⭐'
command: node build-system/pr-check/bundle-size-module-build.js
name: '⭐⭐⭐ << parameters.module >> 3p Build (<< parameters.purpose >>) ⭐⭐⭐'
command: node build-system/pr-check/dist.js --type "<< parameters.module >> 3p Build (<< parameters.purpose >>)"
- teardown_vm
bundle_size:
executor:
Expand Down Expand Up @@ -529,23 +521,21 @@ workflows:
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
- nomodule_build_test:
name: '⛓️ Nomodule Build (Test)'
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
- module_build_test:
name: '⛓️ Module Build (Test)'
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
- nomodule_build_bundle_size:
name: '⛓️ Nomodule Build (Bundle Size)'
- dist:
matrix:
parameters:
module: ['Module', 'Nomodule']
purpose: ['Test', 'Bundle Size']
name: '⛓️ << matrix.module >> Build (<< matrix.purpose >>)'
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
- module_build_bundle_size:
name: '⛓️ Module Build (Bundle Size)'
- dist_3p:
matrix:
parameters:
module: ['Module', 'Nomodule']
purpose: ['Test', 'Bundle Size']
name: '<< matrix.module >> 3p Build (<< matrix.purpose >>)'
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
Expand All @@ -554,7 +544,9 @@ workflows:
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Bundle Size)'
- 'Nomodule 3p Build (Bundle Size)'
- '⛓️ Module Build (Bundle Size)'
- 'Module 3p Build (Bundle Size)'
- validator_tests:
name: 'Validator Tests'
<<: *push_and_pr_builds
Expand All @@ -565,7 +557,9 @@ workflows:
<<: *push_and_pr_builds
requires:
- '⛓️ Module Build (Test)'
- 'Module 3p Build (Test)'
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- local_unit_tests:
name: 'Local Unit Tests'
<<: *push_and_pr_builds
Expand All @@ -589,36 +583,43 @@ workflows:
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- module_tests:
name: 'Module Tests (<< matrix.config >>)'
matrix:
parameters:
config: ['prod', 'canary']
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- '⛓️ Module Build (Test)'
- 'Module 3p Build (Test)'
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- end_to_end_tests:
name: '⛓️ End-to-End Tests'
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_safari:
name: 'Browser Tests (Safari)'
<<: *push_and_pr_builds
requires:
- 'Initialize for Mac OS'
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_firefox:
name: 'Browser Tests (Firefox)'
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_edge:
name: 'Browser Tests (Edge)'
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- experiment_build:
name: 'Experiment << matrix.exp >> Build'
matrix:
Expand Down
52 changes: 0 additions & 52 deletions build-system/pr-check/bundle-size-module-build.js

This file was deleted.

52 changes: 0 additions & 52 deletions build-system/pr-check/bundle-size-nomodule-build.js

This file was deleted.

111 changes: 111 additions & 0 deletions build-system/pr-check/dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
'use strict';

/**
* @fileoverview Script that builds the module AMP runtime for bundle-size during CI.
*/

const {
skipDependentJobs,
storeBuildOutputToWorkspace,
timedExecOrDie,
} = require('./utils');
const {runCiJob} = require('./ci-job');
const {Targets, buildTargetsInclude} = require('./build-targets');
const {maybeParallelizeCommand} = require('./parallelization');

const {type} = require('minimist')(process.argv.slice(2));

const jobName = 'dist.js';

// Mapping from build type name to the command to execute.
const COMMANDS = {
'Module Build (Test)': 'amp dist --esm --fortesting',
'Module 3p Build (Test)':
'amp dist --esm --fortesting --core_runtime_only --vendor_configs',
'Nomodule Build (Test)': 'amp dist --fortesting',
'Nomodule 3p Build (Test)':
'amp dist --fortesting --core_runtime_only --vendor_configs',
'Module Build (Bundle Size)':
'amp dist --noconfig --esm --version_override 0000000000000 --nomanglecache',
'Module 3p Build (Bundle Size)':
'amp dist --noconfig --esm --core_runtime_only --vendor_configs --version_override 0000000000000 --nomanglecache',
'Nomodule Build (Bundle Size)':
'amp dist --noconfig --version_override 0000000000000 --nomanglecache',
'Nomodule 3p Build (Bundle Size)':
'amp dist --noconfig --core_runtime_only --vendor_configs --version_override 0000000000000 --nomanglecache',
};

// Mapping from Build type name to which build targets should trigger this build in pull requests.
const PR_TARGETS = {
'Module Build (Test)': [
Targets.RUNTIME,
Targets.INTEGRATION_TEST,
Targets.VISUAL_DIFF,
],
'Module 3p Build (Test)': [
Targets.RUNTIME,
Targets.INTEGRATION_TEST,
Targets.VISUAL_DIFF,
],
'Nomodule Build (Test)': [
Targets.RUNTIME,
Targets.INTEGRATION_TEST,
Targets.E2E_TEST,
Targets.VISUAL_DIFF,
],
'Nomodule 3p Build (Test)': [
Targets.RUNTIME,
Targets.INTEGRATION_TEST,
Targets.E2E_TEST,
Targets.VISUAL_DIFF,
],
'Module Build (Bundle Size)': [Targets.RUNTIME],
'Module 3p Build (Bundle Size)': [Targets.RUNTIME],
'Nomodule Build (Bundle Size)': [Targets.RUNTIME],
'Nomodule 3p Build (Bundle Size)': [Targets.RUNTIME],
};

// We require a special exception for running an empty visual diff build when skipping module test builds.
// Run this on the 3p Build since that one is not parallelized!
const RUN_ON_SKIP = {
'Module 3p Build (Test)': () => {
timedExecOrDie('amp visual-diff --empty');
},
};

// We gracefully halt uneffected tests, but want to run the Bundle Size step regardless.
const gracefullyHaltNextJobs = type.endsWith('(Test)');

/**
* Steps to run during push builds.
*/
function pushBuildWorkflow() {
const command = maybeParallelizeCommand(
COMMANDS[type],
'extensions/amp-*',
(results) =>
`--extensions=${results.replaceAll(/\bextensions\//g, '').replaceAll(' ', ',')}`
);

timedExecOrDie(command);
storeBuildOutputToWorkspace();
}

/**
* Steps to run during PR builds.
*/
function prBuildWorkflow() {
if (buildTargetsInclude(...PR_TARGETS[type])) {
pushBuildWorkflow();
return;
}

RUN_ON_SKIP[type]?.();
skipDependentJobs(
jobName,
'this PR does not affect relevant files for this build',
gracefullyHaltNextJobs
);
}

runCiJob(jobName, pushBuildWorkflow, prBuildWorkflow);
Loading

0 comments on commit 523cc64

Please sign in to comment.