Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable triggering azure pipelines #1274

Draft
wants to merge 35 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9d541b1
Merge pull request #1049 from w3c/releases
howard-e Apr 8, 2024
3669e0a
Merge pull request #1063 from w3c/releases
howard-e Apr 29, 2024
f51c320
Merge branch 'releases'
alflennik May 6, 2024
41b2101
May 28, 2024 Production Release (#1113)
howard-e May 28, 2024
4488588
Merge branch 'refs/heads/releases'
howard-e May 28, 2024
ee8fd6a
Merge pull request #1130 from w3c/releases
howard-e Jun 12, 2024
7d933eb
Merge pull request #1134 from w3c/releases
howard-e Jun 24, 2024
24c9b0c
Merge pull request #1164 from w3c/releases
howard-e Jul 22, 2024
7cc97aa
Merge pull request #1179 from w3c/releases
howard-e Jul 29, 2024
d8f58cc
Merge pull request #1199 from w3c/releases
howard-e Aug 26, 2024
862cb25
Merge pull request #1217 from w3c/releases: September 18, 2024 Produc…
howard-e Sep 18, 2024
0d8fad7
Merge pull request #1221 from w3c/releases
howard-e Sep 23, 2024
553c905
Merge pull request #1223 from w3c/releases
howard-e Sep 23, 2024
1f87b26
Merge pull request #1234 from w3c/releases
howard-e Oct 9, 2024
a63a253
Merge pull request #1239 from w3c/releases
howard-e Oct 10, 2024
1a511e2
Merge pull request #1246 from w3c/releases
howard-e Oct 16, 2024
8873bf0
Merge pull request #1264 from w3c/releases
howard-e Oct 28, 2024
20cd8d1
Merge pull request #1273 from w3c/releases
howard-e Nov 7, 2024
fed3203
Merge pull request #1285 from w3c/releases
howard-e Dec 10, 2024
4413183
Merge pull request #1295 from w3c/releases
howard-e Dec 18, 2024
c17c549
Create AzurePipelinesService.js
outofambit Sep 11, 2024
b41043a
add automation service field to TestPlanRun model
outofambit Nov 14, 2024
ff7eb1b
unnecessary
outofambit Nov 14, 2024
fbdb5dd
support triggering azure from CollectionJobService
outofambit Nov 14, 2024
996ef2c
fix missing types
outofambit Nov 21, 2024
812ae60
include migration and seeder
outofambit Nov 21, 2024
e302f83
rework azure pipeline service
outofambit Dec 18, 2024
dd35f28
initialize azure pipeline service too
outofambit Jan 6, 2025
73bfef5
update sandbox secrets
outofambit Jan 6, 2025
586b392
parameters, not variables for devops api
outofambit Jan 7, 2025
4e19ada
serialize parameters properly
outofambit Jan 7, 2025
7e928d5
Update config-sandbox.env
outofambit Jan 22, 2025
5ef12a1
Update dev.env
outofambit Jan 22, 2025
41a40dd
comments
outofambit Jan 22, 2025
808af2d
hardcode for testing
outofambit Jan 22, 2025
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
9 changes: 9 additions & 0 deletions config/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ AUTOMATION_SCHEDULER_URL=http://localhost:8866
AUTOMATION_SCHEDULER_SECRET=3Bq10QMDcca2IuxrTr23!eAsDCoILhHrrlBda7-3-WE9?El2S?R5REWXTyE3B72!
AUTOMATION_SCHEDULER_PORT=8866
AUTOMATION_CALLBACK_FQDN=

AZURE_DEVOPS_ORGANIZATION=bocoup
AZURE_DEVOPS_PROJECT=aria-at-automation

# replace with a real values
AZURE_CLIENT_ID=1a111111-1111-111a-aa1a-1111a1111111
AZURE_CLIENT_SECRET=aaa1a~a1aaaaaaaaaaa1aaa1a1aaaaa1aa1aaaaaa
AZURE_TENANT_ID=1111111a-1a1a-1aa1-a111-1aa1111aa1a1
AZURE_APP_TOKEN=111a11aa-1111-111a-aa11-111aa1111111/.default
95 changes: 55 additions & 40 deletions deploy/files/config-sandbox.env
Original file line number Diff line number Diff line change
@@ -1,41 +1,56 @@
$ANSIBLE_VAULT;1.1;AES256
30663031343864653133313365303935306566663531306138343464353631343730653964376239
3363306662346534646433333130343264346631623035650a356564633964366262623631633138
38666339633665636466363962366633623634333839623833636537646366373566626163633265
6337626339343937330a636438653362366166643538343834646162383563343163663666636237
31666330303834393032626264643064343864353566653763356338343135363633323364386139
38323163623265316333316538333339656533373935376366616135386338303930356335313530
31396434666337306164353637386662633037613435383136646330333137653362376437653937
39663433653837363762666637643364356131636130636163313232613336343565653133353263
37663331643633383739366164663830646339336562366338633463306335666237653335336530
66393261363066346261383865316237636361323738356364336665323063373864656237326430
38343532373463633738623032343730646533316263656232373937653439306263643938643336
37326235663163653339366266633965363239616339393833346665393731363138326530663164
32633035333636656333623536353937656530626664626164343037633965366330623538326230
39616635363039333063333637386531636434613333363733343135663538353639323839396566
38646130633630353138326532393235326438373336383434616565353231613834633563633066
30343965366430613263633038326437643461336539663266316666646132626137356163393034
61346537353937313862353637366666366137356538396535353236333639363362643139616662
63323932306264306162313765666164663265313264313963303334383330316331336261393735
64366463646563306132396564636630393736646136613465343934326166303134336138366264
33383130323334616566393765333239333138343235363935653237366237306266333032303365
65646561396661323938396461623030663566646638343038633230633263393938396165616265
30643839653133306236613061376264633263663463303531363761663262633865653066383864
39323765393535613865326531383262666564396436656131333562303863353138613339373936
66393237613562623039653930616635333261613833323932313265616138323866356633346661
63353538333731626435363334336330303266343135613432363738306365346239636264393635
30336165303634353463363831646361623538303535366465323536626239626231643837346137
39313235316164353365396335306238623936366561633533343230616533613664316233663062
61363538373965346364373837323864643138333832656466643737626363313836616637326566
38613331343238333231316436353366366331346663333536653138303561613962636132363438
39396164363838393935316635643435306336323531626336363162666165386538663561666339
31396261363163356664653961353630383432323735383633626231356637326265333938323433
66633263626330356564376435376364653263303136646536303134383232653163643664373830
34383436363862353962396234333137643866663336326563323234313463363032326165363066
31666230656564346663313732666635643864316461303837386464336162306538313165313566
38633939356631383334313162633462633163336130656663613164393864326635613662366564
31356533373137333466303439383637633239663165303438326265323363643361326261643461
33663762366266326161313364643764303563383936323938313738623566613634343933623736
38386138396538326365363834623436363861316632353031663865636336343365323439363366
38333037323632663265306137663232633731313539333930616133333735626638623931643233
63626136333030616562
31376432663138623163373235626534616235376538336562623539313561363930666430643661
3266323339633435663635316236333834383132653932630a346132386630623034393264333161
63343333323539326535316231333564363235326436343663383039313264313139343430386563
3735383137306435320a626563663031353932393531663631643961343237383736666263633366
64623833333863343034323464323638323839343339316531636461613234336537386239303538
34323662393235323834623166306536313032323761666666663034663861326433383539313039
37636337346538343237653564393233646666666332646264356539633833373838313239663863
31363130633739376338373539633232636635366537373034313835653830336261383735353065
64313537623830353131663539393835646632383261653361366536653230326562633434376535
61353830646163396538366131363638336633373033376339663765643263663463373738336666
30323438656231363937346437633834393532623466663965393832393737623033323438343630
66626263663737333265653038363937336233353432353764323064393261656663326461333739
30636665383235366430396465393833393761346332613662343662353438623261316662326335
61303635393862653631303363633131353937656130623065356332306430363866316466633837
62323635366535356363393030633465383834396535313465333437376134373539366666623431
37376162373365653131613230633738323362346537373335623462373533303033653039303032
61333363643864356135373064303037376564343939386434333061336465326538363132643565
30313866383130313032376336363437663237643262323563326534323131653634356165346564
66323632643530363466393362366435363439393064616138353634616264313161373933393533
64646335373663313630613638633066666265343465313936613933363261636133373562316663
33363263656532346431356138653965386431663131303239663138326537646363343261393632
32373038653136393966353563633931316661323434313863326363383233316139613161306131
39643262613132383965623066623137313262306663663738313736366534656430633831313132
37656330636231353734356661666636643438373661626562383734323466373563616138343333
61656538396331353135316636363631386464633139643365356332626439353962306431356234
34396334616263333438323130303739643139353261316633326161633132386239656364363764
38383831636134366465323636616261326336336339633635663662633164306562333432383538
31353938643134363638666664613861653266643565623137353937616330643038353938306638
35333766356634663363613336363535373033646462633165303362633236333731333566343862
37383532333538353535353935353239333262363063386132323861363033346439343462636164
38393736356633356162323836366364663835353764656433333031313663623832613635636230
61343131646434316530386332613332373135633661613633633263346136613431663934313839
35386634376132616330336565656237646335663837396166633239363266643763656133656662
66613734656538336366663334333330663536666231336336313834316664643634613334306564
65326532623930333439623364646636656138323631343339383939373134396634316262623532
64653236616634373330386662663038333732323034313266396166623730346630323631396431
34366263643965653735396139313738366136306630643565366163363934376337323161376366
34333162343636396361613564336461386231323766343166626663646463383337663365393461
39316666343139316533666565333764393636366239326161383065623337313365616331623964
38366466633163353437643033396365303830363631613362613964633332303061303664373131
39346363393237373034653363383633613838313264353765363538663637633066653936386330
38643065626131623432633130363635326334303636636337373536396334393766326533333636
64363936303962666136346530313461656430363266626139346432623434383536656136353235
35323639623633333162336632633364306662323932343766376437353836346466376564366131
66333839623931613330646363313065376362313336393364303835613262316634373736336262
31326237643864313138663837363631306664333664613034333339336266393038643133373639
34363138323332336662653062356432653833386361633733386665353931326661633939643032
30383036343730306638633339633165383461376638373866343761373736636362323536343132
33613036666636363261326664333163333961633562646538643733653132633665353765356532
65373832326361393238616539363765613337366564323163656165313738323461333938343666
63393032346332366664653364343534356163636563663933306566326633353465383264313832
35323034386164633239323732343430316664666431333834623561323632663034633431353264
62633734353633653835353965363437396539393038303363373965653038653466633134376262
37393733613133663839386661643630316366616561366462383335323261373066333533393563
363966303732373635303861616663653431
4 changes: 3 additions & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ listener.route('/aria-at/:branch*').get(
proxyMiddleware.proxyPath(baseUrl)
);

// Conditionally initialize github workflow service, or mock automation scheduler
// Conditionally initialize github workflow and azure pipelines services,
// or mock automation scheduler
if (
process.env.ENVIRONMENT === 'production' ||
process.env.ENVIRONMENT === 'staging' ||
process.env.ENVIRONMENT === 'sandbox' ||
process.env.AUTOMATION_CALLBACK_FQDN
) {
require('./services/GithubWorkflowService').setup();
require('./services/AzurePipelinesService').setup();
} else {
setupMockAutomationSchedulerServer().catch(error => {
console.error('Failed to initialize mock automation server:', error);
Expand Down
16 changes: 16 additions & 0 deletions server/migrations/20241121003538-addAutomationServiceColumn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('TestPlanRun', 'automationService', {
type: Sequelize.STRING,
allowNull: true,
defaultValue: null
});
},

async down(queryInterface) {
await queryInterface.removeColumn('TestPlanRun', 'automationService');
}
};
10 changes: 10 additions & 0 deletions server/models/TestPlanRun.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { AUTOMATION_SERVICE } = require('../util/enums');

const MODEL_NAME = 'TestPlanRun';

module.exports = function (sequelize, DataTypes) {
Expand All @@ -18,6 +20,11 @@ module.exports = function (sequelize, DataTypes) {
allowNull: false,
defaultValue: false
},
automationService: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null
},
isPrimary: {
type: DataTypes.BOOLEAN,
allowNull: true,
Expand All @@ -30,6 +37,9 @@ module.exports = function (sequelize, DataTypes) {
}
);

Model.GITHUB_ACTIONS = AUTOMATION_SERVICE.GITHUB_ACTIONS;
Model.AZURE_PIPELINES = AUTOMATION_SERVICE.AZURE_PIPELINES;

Model.TEST_RESULT_ASSOCIATION = { as: 'testResults' };

Model.TEST_PLAN_REPORT_ASSOCIATION = { foreignKey: 'testPlanReportId' };
Expand Down
64 changes: 53 additions & 11 deletions server/models/services/CollectionJobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const {
USER_ATTRIBUTES,
COLLECTION_JOB_TEST_STATUS_ATTRIBUTES
} = require('./helpers');
const { COLLECTION_JOB_STATUS } = require('../../util/enums');
const {
COLLECTION_JOB_STATUS,
AUTOMATION_SERVICE
} = require('../../util/enums');
const { Op } = require('sequelize');
const {
createTestPlanRun,
Expand All @@ -24,7 +27,10 @@ const {
default: createGithubWorkflow,
isEnabled: isGithubWorkflowEnabled
} = require('../../services/GithubWorkflowService');

const {
default: triggerAzurePipeline,
isEnabled: isAzurePipelinesEnabled
} = require('../../services/AzurePipelinesService');
const {
startCollectionJobSimulation
} = require('../../tests/util/mock-automation-scheduler-server');
Expand Down Expand Up @@ -125,6 +131,7 @@ const nestedTestPlanRunAssociation = (

/**
* @param {string[]} testPlanVersionAttributes - TestPlanVersion attributes to be returned in the result
* @param {string[]} testPlanAttributes - TestPlan attributes to be returned in the result
* @returns {{association: string, attributes: string[]}}
*/
const testPlanVersionAssociation = (
Expand All @@ -137,7 +144,7 @@ const testPlanVersionAssociation = (
});

/**
* @param {string[]} testPlanVersionAttributes - TestPlanVersion attributes to be returned in the result
* @param {string[]} testPlanAttributes - TestPlan attributes to be returned in the result
* @returns {{association: string, attributes: string[]}}
*/
const testPlanAssociation = testPlanAttributes => ({
Expand All @@ -146,7 +153,7 @@ const testPlanAssociation = testPlanAttributes => ({
});

/**
* @param browserAttributes - Browser attributes to be returned in the result
* @param {string[]} browserAttributes - Browser attributes to be returned in the result
* @returns {{association: string, attributes: string[]}}
*/
const browserAssociation = browserAttributes => ({
Expand All @@ -155,7 +162,7 @@ const browserAssociation = browserAttributes => ({
});

/**
* @param atAttributes - At attributes to be returned in the result
* @param {string[]} atAttributes - At attributes to be returned in the result
* @returns {{association: string, attributes: string[]}}
*/
const atAssociation = atAttributes => ({
Expand Down Expand Up @@ -381,18 +388,44 @@ const getCollectionJobs = async ({
* @param {object} job - CollectionJob to trigger workflow for.
* @param {number[]} testIds - Array of testIds
* @param {object} atVersion - AtVersion to use for the workflow
* @param {string} workflowService - Use GitHub Actions or Azure Pipelines
* @param {object} options
* @param {*} options.transaction - Sequelize transaction
* @returns Promise<CollectionJob>
*/
const triggerWorkflow = async (job, testIds, atVersion, { transaction }) => {
const triggerWorkflow = async (
job,
testIds,
atVersion,
workflowService,
{ transaction }
) => {
const { testPlanVersion } = job.testPlanRun.testPlanReport;
const { gitSha, directory } = testPlanVersion;

// hardcode for testing
workflowService = AUTOMATION_SERVICE.AZURE_PIPELINES;
Comment on lines +406 to +407
Copy link
Contributor Author

@outofambit outofambit Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded for testing, do not merge!


try {
if (isGithubWorkflowEnabled()) {
// TODO: pass the reduced list of testIds along / deal with them somehow
await createGithubWorkflow({ job, directory, gitSha, atVersion });
if (workflowService === AUTOMATION_SERVICE.GITHUB_ACTIONS) {
if (isGithubWorkflowEnabled()) {
// TODO: pass the reduced list of testIds along / deal with them somehow
await createGithubWorkflow({ job, directory, gitSha, atVersion });
} else {
console.error(
'GitHub Workflow Service is not enabled. Starting simulation job.'
);
await startCollectionJobSimulation(job, atVersion, transaction);
}
} else if (workflowService === AUTOMATION_SERVICE.AZURE_PIPELINES) {
if (isAzurePipelinesEnabled()) {
await triggerAzurePipeline({ job, directory, gitSha, atVersion });
} else {
console.error(
'Azure Pipelines Service is not enabled. Starting simulation job.'
);
await startCollectionJobSimulation(job, atVersion, transaction);
}
} else {
await startCollectionJobSimulation(job, testIds, atVersion, transaction);
}
Expand Down Expand Up @@ -515,20 +548,25 @@ const retryCanceledCollections = async ({ collectionJob }, { transaction }) => {
transaction
});

return triggerWorkflow(job, testIds, atVersion, { transaction });
const { automationService } = collectionJob.testPlanRun;

return triggerWorkflow(job, testIds, atVersion, automationService, {
transaction
});
};

/**
* Schedule a collection job with Response Scheduler
* @param {object} input object for request to schedule job
* @param {string} input.testPlanReportId id of test plan report to use for scheduling
* @param {string} input.workflowService
* @param {Array<string>} input.testIds optional: ids of tests to run
* @param {object} options
* @param {*} options.transaction - Sequelize transaction
* @returns {Promise<*>}
*/
const scheduleCollectionJob = async (
{ testPlanReportId, testIds = null },
{ testPlanReportId, workflowService, testIds = null },
{ transaction }
) => {
const context = getGraphQLContext({ req: { transaction } });
Expand Down Expand Up @@ -596,6 +634,7 @@ const scheduleCollectionJob = async (
job,
testIds ?? tests.map(test => test.id),
atVersion,
workflowService,
{
transaction
}
Expand Down Expand Up @@ -693,10 +732,13 @@ const restartCollectionJob = async ({ id }, { transaction }) => {
transaction
});

const { automationService } = job.testPlanRun;

return triggerWorkflow(
job,
tests.map(test => test.id),
atVersion,
automationService,
{ transaction }
);
};
Expand Down
7 changes: 5 additions & 2 deletions server/models/services/TestPlanRunService.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const getTestPlanRuns = async ({
/**
* @param {object} options
* @param {object} options.values - values to be used to create the TestPlanRun
* @param {string} options.values.automationService
* @param {string[]} options.testPlanRunAttributes - TestPlanRun attributes to be returned in the result
* @param {string[]} options.nestedTestPlanRunAttributes - TestPlanRun attributes associated to the TestPlanReport model to be returned
* @param {string[]} options.testPlanReportAttributes - TestPlanReport attributes to be returned in the result
Expand All @@ -233,7 +234,8 @@ const createTestPlanRun = async ({
testerUserId,
testPlanReportId,
testResults = [],
isAutomated = false
isAutomated = false,
automationService = null
},
testPlanRunAttributes = TEST_PLAN_RUN_ATTRIBUTES,
nestedTestPlanRunAttributes = TEST_PLAN_RUN_ATTRIBUTES,
Expand Down Expand Up @@ -270,7 +272,8 @@ const createTestPlanRun = async ({
testerUserId,
testPlanReportId,
testResults,
initiatedByAutomation: isAutomated
initiatedByAutomation: isAutomated,
automationService
},
transaction
});
Expand Down
Loading
Loading