Skip to content

Commit

Permalink
wipwipwip
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrozenberg committed Feb 27, 2024
1 parent 523cc64 commit 03e977c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 45 deletions.
38 changes: 29 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ dist_job: &dist_job
type: enum
enum: ['Test', 'Bundle Size']

test_types_job: &test_types_job
parameters:
test_type:
description: 'Which test type to run'
type: enum
enum: ['Unit', 'Integration', 'End-to-End']

executors:
base-docker-small:
docker:
Expand Down Expand Up @@ -391,34 +398,37 @@ jobs:
browser_tests_safari:
executor:
name: macos-medium
<<: *test_types_job
steps:
- setup_vm
- enable_safari_automation
- run:
name: '⭐⭐⭐ Browser Tests (Safari) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=safari
name: '⭐⭐⭐ << parameters.test_type >> Tests (Safari) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=safari --type=<< parameters.test_type >>
- store_test_output
- teardown_vm
browser_tests_firefox:
executor:
name: node-docker-medium
<<: *test_types_job
steps:
- setup_vm
- install_firefox
- run:
name: '⭐⭐⭐ Browser Tests (Firefox) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=firefox
name: '⭐⭐⭐ << parameters.test_type >> Tests (Firefox) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=firefox --type=<< parameters.test_type >>
- store_test_output
- teardown_vm
browser_tests_edge:
executor:
name: node-docker-medium
<<: *test_types_job
steps:
- setup_vm
- install_edge
- run:
name: '⭐⭐⭐ Browser Tests (Edge) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=edge
name: '⭐⭐⭐ << parameters.test_type >> Tests (Edge) ⭐⭐⭐'
command: node build-system/pr-check/browser-tests.js --browser=edge --type=<< parameters.test_type >>
- store_test_output
- teardown_vm
experiment_build:
Expand Down Expand Up @@ -602,20 +612,30 @@ workflows:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_safari:
name: 'Browser Tests (Safari)'
name: '<< matrix.test_type >> Tests (Safari)'
matrix:
parameters:
test_type: ['Unit', 'Integration', 'End-to-End']
<<: *push_and_pr_builds
requires:
- 'Initialize for Mac OS'
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_firefox:
name: 'Browser Tests (Firefox)'
name: '<< matrix.test_type >> Tests (Firefox)'
matrix:
parameters:
test_type: ['Unit', 'Integration', 'End-to-End']
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
- 'Nomodule 3p Build (Test)'
- browser_tests_edge:
name: 'Browser Tests (Edge)'
name: '<< matrix.test_type >> Tests (Edge)'
matrix:
parameters:
# Note: we can't run e2e tests on Edge.
test_type: ['Unit', 'Integration']
<<: *push_and_pr_builds
requires:
- '⛓️ Nomodule Build (Test)'
Expand Down
58 changes: 22 additions & 36 deletions build-system/pr-check/browser-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,34 @@
* @fileoverview Script that runs tests on Safari / Firefox / Edge during CI.
*/

const {
skipDependentJobs,
timedExecOrDie,
timedExecOrThrow,
} = require('./utils');
const {browser} = require('minimist')(process.argv.slice(2));
const {skipDependentJobs, timedExecOrThrow} = require('./utils');
const {runCiJob} = require('./ci-job');
const {Targets, buildTargetsInclude} = require('./build-targets');

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

const jobName = 'browser-tests.js';

const COMMANDS = {
'Unit': `amp unit --${browser}`,
'Integration': `amp integration --nobuild --minified --${browser}`,
'End-to-End': `amp e2e --nobuild --minified --browsers=${browser}`,
};

const INDIVIDUAL_TARGET = {
'Unit': Targets.UNIT_TEST,
'Integration': Targets.INTEGRATION_TEST,
'End-to-End': Targets.E2E_TEST,
};

/**
* Steps to run during push builds.
*/
function pushBuildWorkflow() {
try {
timedExecOrThrow(`amp unit --${browser}`, 'Unit tests failed!');
timedExecOrThrow(
`amp integration --nobuild --minified --${browser}`,
'Integration tests failed!'
);
timedExecOrThrow(
`amp e2e --nobuild --minified --browsers=${browser}`,
'End-to-end tests failed!'
);
timedExecOrThrow(COMMANDS[type], `${type} tests failed!`);
} catch (e) {
if (e.status) {
process.exitCode = e.status;
Expand All @@ -40,32 +43,15 @@ function pushBuildWorkflow() {
* Steps to run during PR builds.
*/
function prBuildWorkflow() {
if (
!buildTargetsInclude(
Targets.RUNTIME,
Targets.UNIT_TEST,
Targets.E2E_TEST,
Targets.INTEGRATION_TEST
)
) {
if (!buildTargetsInclude(Targets.RUNTIME, INDIVIDUAL_TARGET[type])) {
skipDependentJobs(
jobName,
'this PR does not affect the runtime, unit tests, integration tests, or end-to-end tests'
`this PR does not affect the runtime or ${type} tests`
);
return;
}
if (buildTargetsInclude(Targets.RUNTIME, Targets.UNIT_TEST)) {
timedExecOrDie(`amp unit --${browser}`);
}
if (buildTargetsInclude(Targets.RUNTIME, Targets.INTEGRATION_TEST)) {
timedExecOrDie(`amp integration --nobuild --minified --${browser}`);
}
if (
buildTargetsInclude(Targets.RUNTIME, Targets.E2E_TEST) &&
['safari', 'firefox'].includes(browser) // E2E tests can't be run on Edge.
) {
timedExecOrDie(`amp e2e --nobuild --minified --browsers=${browser}`);
}

pushBuildWorkflow();
}

runCiJob(jobName, pushBuildWorkflow, prBuildWorkflow);

0 comments on commit 03e977c

Please sign in to comment.