From b0fb37b6cb78bc95bc9099e3811e3534977529d2 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 12:07:43 -0500 Subject: [PATCH 01/65] Attempt incremental run and upload incremental report --- .github/workflows/scheduled.yml | 22 ++++++++++++++-------- stryker.config.mjs | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index cd01e8c..dc1701e 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -1,8 +1,8 @@ -name: FleetWebClientScheduled +name: LetsLearnCI/CD on: - schedule: - - cron: '18 23 * * 1' + pull_request: + branches: ["master"] env: ENVIRONMENT_PATH: src/assets/environment.json @@ -28,10 +28,16 @@ jobs: run: npm i - name: Run Stryker - run: npx stryker run | tee stryker-output.txt + run: npx stryker run --incremental - - name: Upload Stryker Report - uses: actions/upload-artifact@v2 + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 with: - name: stryker-report - path: reports/mutation/mutation.html + name: stryker-incremental + path: reports/stryker-incremental.json + + - name: Upload Stryker Coverage Report + uses: actions/upload-artifact@v4 + with: + name: stryker-coverage + path: reports/mutation/mutation.html \ No newline at end of file diff --git a/stryker.config.mjs b/stryker.config.mjs index 7246427..4d653b0 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -2,7 +2,7 @@ /** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */ const config = { mutate: [ - "src/**/*component.ts", + "src/**/*form.component.ts", "!src/**/*.spec.ts", "!src/test.ts", "!src/environments/*.ts", From 5ac1db1d6ddc4c7c06a4919adc90b396a75b7005 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 13:35:08 -0500 Subject: [PATCH 02/65] Attempt to retrieve incremental report for next run --- .github/workflows/download-artifact.js | 89 ++++++++++++++++++++++++++ .github/workflows/scheduled.yml | 27 ++++++-- stryker.config.mjs | 3 +- 3 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/download-artifact.js diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js new file mode 100644 index 0000000..37c09c9 --- /dev/null +++ b/.github/workflows/download-artifact.js @@ -0,0 +1,89 @@ +const axios = require('axios'); +const AdmZip = require('adm-zip'); +const fs = require('fs'); +const path = require('path'); + +const GITHUB_TOKEN = process.env.GITHUB_TOKEN; +const OWNER = process.env.OWNER; +const REPO = process.env.REPO; +const WORKFLOW_ID = process.env.WORKFLOW_ID; +const ARTIFACT_NAME = process.env.ARTIFACT_NAME; + +async function getLatestSuccessfulRun() { + const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + }, + params: { + status: 'success', + per_page: 1 + } + }); + + const run = response.data.workflow_runs[0]; + return run ? run.id : null; +} + +async function getArtifactId(runId) { + const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + } + }); + + const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); + return artifact ? artifact.id : null; +} + +async function downloadArtifact(artifactId) { + const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + }, + responseType: 'arraybuffer' + }); + + const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); + fs.writeFileSync(zipPath, Buffer.from(response.data)); + return zipPath; +} + +function extractArtifact(zipPath) { + const zip = new AdmZip(zipPath); + const extractPath = path.join(__dirname, 'extracted_artifact'); + zip.extractAllTo(extractPath, true); + return extractPath; +} + +(async () => { + try { + const runId = await getLatestSuccessfulRun(); + if (!runId) { + console.log('No successful workflow run found'); + fs.writeFileSync('artifact_error.flag', ''); + return; + } + + const artifactId = await getArtifactId(runId); + if (!artifactId) { + console.log(`Artifact ${ARTIFACT_NAME} not found`); + fs.writeFileSync('artifact_error.flag', ''); + return; + } + + const zipPath = await downloadArtifact(artifactId); + const extractPath = extractArtifact(zipPath); + + const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); + if (!fs.existsSync(artifactFilePath)) { + console.log(`Artifact file ${artifactFilePath} not found`); + fs.writeFileSync('artifact_error.flag', ''); + return; + } + + console.log(`Artifact extracted to ${extractPath}`); + } catch (error) { + console.error(`Error: ${error.message}`); + fs.writeFileSync('artifact_error.flag', ''); + } +})(); \ No newline at end of file diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index dc1701e..0d6eef3 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -15,20 +15,39 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Setup Node - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: npm install run: npm i - + + - name: Install Temporary Dependencies + run: npm install axios adm-zip + + - name: Download and Extract Artifact + run: node .github/workflows/download-artifact.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + WORKFLOW_ID: your_workflow_id + ARTIFACT_NAME: stryker-incremental + - name: Run Stryker - run: npx stryker run --incremental + run: | + if [ -f artifact_error.flag ]; then + echo "Artifact error, initializing Stryker incremental run." + npx stryker run + else + echo "Artifact found, continuing Stryker incremental run." + npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json + fi - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 diff --git a/stryker.config.mjs b/stryker.config.mjs index 4d653b0..db43945 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -20,6 +20,7 @@ const config = { concurrency_comment: "Recommended to use about half of your available cores when running stryker with Angular", coverageAnalysis: "perTest", - ignoreStatic: true + ignoreStatic: true, + incremental: true }; export default config; From dbbb9cb11f620c1646a77bb6919edc6a1469d9c8 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 13:35:46 -0500 Subject: [PATCH 03/65] Change test name for incremental diff --- src/app/reactive-form/reactive-form.component.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/reactive-form/reactive-form.component.spec.ts b/src/app/reactive-form/reactive-form.component.spec.ts index f7fc62a..1073650 100644 --- a/src/app/reactive-form/reactive-form.component.spec.ts +++ b/src/app/reactive-form/reactive-form.component.spec.ts @@ -22,7 +22,7 @@ describe('ReactiveFormComponent', () => { expect(component).toBeTruthy(); }); - describe("timesTwo", () => { + describe("timesTwoTest", () => { it("should return the input value multiplied by two", () => { let results = component.timesTwo(2); @@ -30,7 +30,7 @@ describe('ReactiveFormComponent', () => { }); }); - describe("timesFour", () => { + describe("timesFourTest", () => { it("should return the input value multiplied by four", () => { let results = component.timesFour(2); @@ -38,7 +38,7 @@ describe('ReactiveFormComponent', () => { }); }); - describe("timesEight", () => { + describe("timesEightTest", () => { it("should return the input value multiplied by eight", () => { let results = component.timesEight(2); From 03352906ddc24d8c3624de44ff1e88ed275805fe Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 13:50:23 -0500 Subject: [PATCH 04/65] Add mega logging to JS.. --- .github/workflows/download-artifact.js | 35 +++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 37c09c9..7a99b19 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -10,7 +10,10 @@ const WORKFLOW_ID = process.env.WORKFLOW_ID; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function getLatestSuccessfulRun() { - const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`, { + console.log(`Fetching latest successful run for workflow ID: ${WORKFLOW_ID}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; + console.log(`Request URL: ${url}`); + const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, @@ -20,29 +23,38 @@ async function getLatestSuccessfulRun() { } }); + console.log(`Response status: ${response.status}`); const run = response.data.workflow_runs[0]; return run ? run.id : null; } async function getArtifactId(runId) { - const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`, { + console.log(`Fetching artifacts for run ID: ${runId}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; + console.log(`Request URL: ${url}`); + const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` } }); + console.log(`Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); return artifact ? artifact.id : null; } async function downloadArtifact(artifactId) { - const response = await axios.get(`https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`, { + console.log(`Downloading artifact with ID: ${artifactId}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; + console.log(`Request URL: ${url}`); + const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, responseType: 'arraybuffer' }); + console.log(`Response status: ${response.status}`); const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); fs.writeFileSync(zipPath, Buffer.from(response.data)); return zipPath; @@ -57,33 +69,38 @@ function extractArtifact(zipPath) { (async () => { try { + console.log('Starting artifact download process...'); const runId = await getLatestSuccessfulRun(); if (!runId) { console.log('No successful workflow run found'); - fs.writeFileSync('artifact_error.flag', ''); + fs.writeFileSync('artifact_not_found.flag', ''); return; } + console.log(`Found successful run with ID: ${runId}`); const artifactId = await getArtifactId(runId); if (!artifactId) { console.log(`Artifact ${ARTIFACT_NAME} not found`); - fs.writeFileSync('artifact_error.flag', ''); + fs.writeFileSync('artifact_not_found.flag', ''); return; } + console.log(`Found artifact with ID: ${artifactId}`); const zipPath = await downloadArtifact(artifactId); + console.log(`Artifact downloaded to: ${zipPath}`); + const extractPath = extractArtifact(zipPath); + console.log(`Artifact extracted to: ${extractPath}`); const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); if (!fs.existsSync(artifactFilePath)) { console.log(`Artifact file ${artifactFilePath} not found`); - fs.writeFileSync('artifact_error.flag', ''); + fs.writeFileSync('artifact_not_found.flag', ''); return; } - - console.log(`Artifact extracted to ${extractPath}`); + console.log(`Artifact file found at: ${artifactFilePath}`); } catch (error) { console.error(`Error: ${error.message}`); - fs.writeFileSync('artifact_error.flag', ''); + fs.writeFileSync('artifact_not_found.flag', ''); } })(); \ No newline at end of file From 4614ddd5c14c3624e2098158c9f312a5d27a3f1c Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 14:02:00 -0500 Subject: [PATCH 05/65] Fetch the workflow id --- .github/workflows/download-artifact.js | 41 ++++++++++++++++++-------- .github/workflows/scheduled.yml | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 7a99b19..d7361fb 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -6,26 +6,43 @@ const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; const REPO = process.env.REPO; -const WORKFLOW_ID = process.env.WORKFLOW_ID; +const WORKFLOW_FILE_NAME = process.env.WORKFLOW_FILE_NAME; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; +async function fetchWorkflowId() { + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; + const response = await axios.get(url, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + } + }); + + const workflow = response.data.workflows.find(wf => wf.path.endsWith(WORKFLOW_FILE_NAME)); + if (!workflow) { + throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); + } + + return workflow.id; +} + async function getLatestSuccessfulRun() { - console.log(`Fetching latest successful run for workflow ID: ${WORKFLOW_ID}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; - console.log(`Request URL: ${url}`); - const response = await axios.get(url, { + const WORKFLOW_ID = await fetchWorkflowId(); + console.log(`Fetching latest successful run for workflow ID: ${WORKFLOW_ID}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; + console.log(`Request URL: ${url}`); + const response = await axios.get(url, { headers: { - Authorization: `token ${GITHUB_TOKEN}` + Authorization: `token ${GITHUB_TOKEN}` }, params: { - status: 'success', - per_page: 1 + status: 'success', + per_page: 1 } - }); + }); - console.log(`Response status: ${response.status}`); - const run = response.data.workflow_runs[0]; - return run ? run.id : null; + console.log(`Response status: ${response.status}`); + const run = response.data.workflow_runs[0]; + return run ? run.id : null; } async function getArtifactId(runId) { diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 0d6eef3..8f72b3b 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -36,7 +36,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} - WORKFLOW_ID: your_workflow_id + WORKFLOW_FILE_NAME: scheduled.yml ARTIFACT_NAME: stryker-incremental - name: Run Stryker From a4e26c8048a8cb31c5a1fb5f06b00a2a2213abab Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 14:11:40 -0500 Subject: [PATCH 06/65] Change paths to reports folder --- .github/workflows/scheduled.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 8f72b3b..104d1ee 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -46,17 +46,17 @@ jobs: npx stryker run else echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json + npx stryker run --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json fi - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 with: name: stryker-incremental - path: reports/stryker-incremental.json + path: /home/runner/work/lets-learn-angular/lets-learn-angular/reports/stryker-incremental.json - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 with: name: stryker-coverage - path: reports/mutation/mutation.html \ No newline at end of file + path: /home/runner/work/lets-learn-angular/lets-learn-angular/reports/mutation/mutation.html \ No newline at end of file From 3340e360129481c16a7801fc41cac3a016a2c352 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 15:27:53 -0500 Subject: [PATCH 07/65] Redo logging and change filepath --- .github/workflows/download-artifact.js | 26 +++++++++++++++----------- .github/workflows/scheduled.yml | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index d7361fb..bea2f5e 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -10,6 +10,7 @@ const WORKFLOW_FILE_NAME = process.env.WORKFLOW_FILE_NAME; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function fetchWorkflowId() { + console.log(`fetchWorkflowId: ${WORKFLOW_FILE_NAME}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; const response = await axios.get(url, { headers: { @@ -17,19 +18,21 @@ async function fetchWorkflowId() { } }); + console.log(`fetchWorkflowId Response status: ${response.status}`); + const workflow = response.data.workflows.find(wf => wf.path.endsWith(WORKFLOW_FILE_NAME)); if (!workflow) { throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); } + console.log(`fetchWorkflowId= ${workflow.id}`); return workflow.id; } async function getLatestSuccessfulRun() { const WORKFLOW_ID = await fetchWorkflowId(); - console.log(`Fetching latest successful run for workflow ID: ${WORKFLOW_ID}`); + console.log(`getLatestSuccessfulRun: ${WORKFLOW_ID}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; - console.log(`Request URL: ${url}`); const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` @@ -40,28 +43,29 @@ async function getLatestSuccessfulRun() { } }); - console.log(`Response status: ${response.status}`); + console.log(`getLatestSuccessfulRun Response status: ${response.status}`); const run = response.data.workflow_runs[0]; + console.log(`getLatestSuccessfulRun= ${run.id}`); return run ? run.id : null; } async function getArtifactId(runId) { - console.log(`Fetching artifacts for run ID: ${runId}`); + console.log(`getArtifactId: ${runId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; - console.log(`Request URL: ${url}`); const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` } }); - console.log(`Response status: ${response.status}`); + console.log(`getArtifactId Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); + console.log(`getArtifactId: ${artifact}`); return artifact ? artifact.id : null; } async function downloadArtifact(artifactId) { - console.log(`Downloading artifact with ID: ${artifactId}`); + console.log(`downloadArtifact: ${artifactId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; console.log(`Request URL: ${url}`); const response = await axios.get(url, { @@ -71,29 +75,30 @@ async function downloadArtifact(artifactId) { responseType: 'arraybuffer' }); - console.log(`Response status: ${response.status}`); + console.log(`downloadArtifact Response status: ${response.status}`); const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); fs.writeFileSync(zipPath, Buffer.from(response.data)); + console.log(`downloadArtifact: ${zipPath}`); return zipPath; } function extractArtifact(zipPath) { + console.log(`extractArtifact: ${zipPath}`); const zip = new AdmZip(zipPath); const extractPath = path.join(__dirname, 'extracted_artifact'); zip.extractAllTo(extractPath, true); + console.log(`extractArtifact: ${extractPath}`); return extractPath; } (async () => { try { - console.log('Starting artifact download process...'); const runId = await getLatestSuccessfulRun(); if (!runId) { console.log('No successful workflow run found'); fs.writeFileSync('artifact_not_found.flag', ''); return; } - console.log(`Found successful run with ID: ${runId}`); const artifactId = await getArtifactId(runId); if (!artifactId) { @@ -101,7 +106,6 @@ function extractArtifact(zipPath) { fs.writeFileSync('artifact_not_found.flag', ''); return; } - console.log(`Found artifact with ID: ${artifactId}`); const zipPath = await downloadArtifact(artifactId); console.log(`Artifact downloaded to: ${zipPath}`); diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 104d1ee..3ca876b 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -46,7 +46,7 @@ jobs: npx stryker run else echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json fi - name: Upload Stryker Incremental Report From 3495c307bffc9843f824502464884534b5dd19e4 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 15:34:12 -0500 Subject: [PATCH 08/65] Debugging setup --- .github/workflows/download-artifact.js | 1 + .github/workflows/scheduled.yml | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index bea2f5e..758ceb4 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -59,6 +59,7 @@ async function getArtifactId(runId) { }); console.log(`getArtifactId Response status: ${response.status}`); + console.log(`getArtifactId: ${response.data.artifacts}`); const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); console.log(`getArtifactId: ${artifact}`); return artifact ? artifact.id : null; diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 3ca876b..f145b87 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -43,20 +43,18 @@ jobs: run: | if [ -f artifact_error.flag ]; then echo "Artifact error, initializing Stryker incremental run." - npx stryker run else echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json fi - - name: Upload Stryker Incremental Report - uses: actions/upload-artifact@v4 - with: - name: stryker-incremental - path: /home/runner/work/lets-learn-angular/lets-learn-angular/reports/stryker-incremental.json + # - name: Upload Stryker Incremental Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-incremental + # path: reports/stryker-incremental.json - - name: Upload Stryker Coverage Report - uses: actions/upload-artifact@v4 - with: - name: stryker-coverage - path: /home/runner/work/lets-learn-angular/lets-learn-angular/reports/mutation/mutation.html \ No newline at end of file + # - name: Upload Stryker Coverage Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-coverage + # path: reports/mutation/mutation.html \ No newline at end of file From c8485d48cb8a10fb4a9176a1368adf96ff7639ff Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 15:36:19 -0500 Subject: [PATCH 09/65] Remove useless debugging and fix upload paths --- .github/workflows/scheduled.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index f145b87..8f72b3b 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -43,18 +43,20 @@ jobs: run: | if [ -f artifact_error.flag ]; then echo "Artifact error, initializing Stryker incremental run." + npx stryker run else echo "Artifact found, continuing Stryker incremental run." + npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json fi - # - name: Upload Stryker Incremental Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-incremental - # path: reports/stryker-incremental.json + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 + with: + name: stryker-incremental + path: reports/stryker-incremental.json - # - name: Upload Stryker Coverage Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-coverage - # path: reports/mutation/mutation.html \ No newline at end of file + - name: Upload Stryker Coverage Report + uses: actions/upload-artifact@v4 + with: + name: stryker-coverage + path: reports/mutation/mutation.html \ No newline at end of file From bf02e15750bc25beacf8813ef15ed365f151b189 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:11:05 -0500 Subject: [PATCH 10/65] Another debug --- .github/workflows/download-artifact.js | 7 ++++--- .github/workflows/scheduled.yml | 15 +-------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 758ceb4..fee7c49 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -6,7 +6,7 @@ const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; const REPO = process.env.REPO; -const WORKFLOW_FILE_NAME = process.env.WORKFLOW_FILE_NAME; +const WORKFLOW_NAME = process.env.WORKFLOW_FILE_NAME; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function fetchWorkflowId() { @@ -18,9 +18,10 @@ async function fetchWorkflowId() { } }); - console.log(`fetchWorkflowId Response status: ${response.status}`); + console.log(`fetchWorkflowId Response is: ${response}`); - const workflow = response.data.workflows.find(wf => wf.path.endsWith(WORKFLOW_FILE_NAME)); + + const workflow = response.data.workflows.find(wf => wf.name.contains(WORKFLOW_NAME)); if (!workflow) { throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); } diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 8f72b3b..f71fec1 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -36,27 +36,14 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} - WORKFLOW_FILE_NAME: scheduled.yml + WORKFLOW_NAME: LetsLearnCI/CD ARTIFACT_NAME: stryker-incremental - name: Run Stryker run: | if [ -f artifact_error.flag ]; then echo "Artifact error, initializing Stryker incremental run." - npx stryker run else echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incrementalFile extracted_artifact/stryker-incremental.json fi - - name: Upload Stryker Incremental Report - uses: actions/upload-artifact@v4 - with: - name: stryker-incremental - path: reports/stryker-incremental.json - - - name: Upload Stryker Coverage Report - uses: actions/upload-artifact@v4 - with: - name: stryker-coverage - path: reports/mutation/mutation.html \ No newline at end of file From 47b7278ab980905cf970775340c609565d154374 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:13:44 -0500 Subject: [PATCH 11/65] Fix typo --- .github/workflows/download-artifact.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index fee7c49..099af88 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -6,11 +6,11 @@ const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; const REPO = process.env.REPO; -const WORKFLOW_NAME = process.env.WORKFLOW_FILE_NAME; +const WORKFLOW_NAME = process.env.WORKFLOW_NAME; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function fetchWorkflowId() { - console.log(`fetchWorkflowId: ${WORKFLOW_FILE_NAME}`); + console.log(`fetchWorkflowId: ${WORKFLOW_NAME}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; const response = await axios.get(url, { headers: { From 52209fab0a0ac6ac219f7941dc320e3e8c8e4984 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:18:15 -0500 Subject: [PATCH 12/65] Fix more mistakes --- .github/workflows/download-artifact.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 099af88..7d663de 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -18,10 +18,10 @@ async function fetchWorkflowId() { } }); - console.log(`fetchWorkflowId Response is: ${response}`); + console.log(`fetchWorkflowId Response status: ${response.status}`); - const workflow = response.data.workflows.find(wf => wf.name.contains(WORKFLOW_NAME)); + const workflow = response.data.workflows.find(wf => wf.name.includes(WORKFLOW_NAME)); if (!workflow) { throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); } From 20cc58408b1f0a74aa837588415ffdf890092065 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:33:54 -0500 Subject: [PATCH 13/65] Tryin' something else, ugh --- .github/workflows/download-artifact.js | 1 - .github/workflows/scheduled.yml | 19 ++++++++++++++++--- stryker.config.mjs | 3 +-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 7d663de..eac546d 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -60,7 +60,6 @@ async function getArtifactId(runId) { }); console.log(`getArtifactId Response status: ${response.status}`); - console.log(`getArtifactId: ${response.data.artifacts}`); const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); console.log(`getArtifactId: ${artifact}`); return artifact ? artifact.id : null; diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index f71fec1..74eb908 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -41,9 +41,22 @@ jobs: - name: Run Stryker run: | - if [ -f artifact_error.flag ]; then - echo "Artifact error, initializing Stryker incremental run." - else + if [ -f extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." + npx stryker run --incremental --incrementalFile extracted_artifact/stryker-incremental.json + else + echo "Artifact not found, initializing full Stryker run." + npx stryker run --incremental fi + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 + with: + name: stryker-incremental + path: reports/stryker-incremental.json + + - name: Upload Stryker Coverage Report + uses: actions/upload-artifact@v4 + with: + name: stryker-coverage + path: reports/mutation/mutation.html \ No newline at end of file diff --git a/stryker.config.mjs b/stryker.config.mjs index db43945..4d653b0 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -20,7 +20,6 @@ const config = { concurrency_comment: "Recommended to use about half of your available cores when running stryker with Angular", coverageAnalysis: "perTest", - ignoreStatic: true, - incremental: true + ignoreStatic: true }; export default config; From 677fb969e55939a3504a33a4ab862cad58971fcd Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:36:26 -0500 Subject: [PATCH 14/65] Changing tests to test incremental stryker --- src/app/reactive-form/reactive-form.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/reactive-form/reactive-form.component.spec.ts b/src/app/reactive-form/reactive-form.component.spec.ts index 1073650..bd6f1f5 100644 --- a/src/app/reactive-form/reactive-form.component.spec.ts +++ b/src/app/reactive-form/reactive-form.component.spec.ts @@ -22,7 +22,7 @@ describe('ReactiveFormComponent', () => { expect(component).toBeTruthy(); }); - describe("timesTwoTest", () => { + describe("timesTwoTestChange", () => { it("should return the input value multiplied by two", () => { let results = component.timesTwo(2); @@ -30,7 +30,7 @@ describe('ReactiveFormComponent', () => { }); }); - describe("timesFourTest", () => { + describe("timesFourTestChange", () => { it("should return the input value multiplied by four", () => { let results = component.timesFour(2); From 5c59ced4eaf602d6bb9ffd215799ea6dcf2789e3 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:39:07 -0500 Subject: [PATCH 15/65] Try full path name for incremental.json --- .github/workflows/scheduled.yml | 2 +- src/app/reactive-form/reactive-form.component.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 74eb908..1654c1d 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -43,7 +43,7 @@ jobs: run: | if [ -f extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incremental --incrementalFile extracted_artifact/stryker-incremental.json + npx stryker run --incremental --incrementalFile home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "Artifact not found, initializing full Stryker run." npx stryker run --incremental diff --git a/src/app/reactive-form/reactive-form.component.spec.ts b/src/app/reactive-form/reactive-form.component.spec.ts index bd6f1f5..1073650 100644 --- a/src/app/reactive-form/reactive-form.component.spec.ts +++ b/src/app/reactive-form/reactive-form.component.spec.ts @@ -22,7 +22,7 @@ describe('ReactiveFormComponent', () => { expect(component).toBeTruthy(); }); - describe("timesTwoTestChange", () => { + describe("timesTwoTest", () => { it("should return the input value multiplied by two", () => { let results = component.timesTwo(2); @@ -30,7 +30,7 @@ describe('ReactiveFormComponent', () => { }); }); - describe("timesFourTestChange", () => { + describe("timesFourTest", () => { it("should return the input value multiplied by four", () => { let results = component.timesFour(2); From 2dbc282bded0e67c1b1969627160dea5c276d8c2 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:41:14 -0500 Subject: [PATCH 16/65] Fix the other path too, d'oh --- .github/workflows/scheduled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 1654c1d..8e481cf 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -41,7 +41,7 @@ jobs: - name: Run Stryker run: | - if [ -f extracted_artifact/stryker-incremental.json ]; then + if [ -f home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." npx stryker run --incremental --incrementalFile home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else From 56c4892a293b494f75f8d71c62bc15644b62da93 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:43:15 -0500 Subject: [PATCH 17/65] Add leading slash to urls --- .github/workflows/scheduled.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 8e481cf..d41df20 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -41,9 +41,9 @@ jobs: - name: Run Stryker run: | - if [ -f home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then + if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incremental --incrementalFile home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "Artifact not found, initializing full Stryker run." npx stryker run --incremental From 6579ba1b6c502662b38e757e95e8e8a46f016e38 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 16:46:07 -0500 Subject: [PATCH 18/65] Fix upload path --- .github/workflows/scheduled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index d41df20..c1fb4cd 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -53,7 +53,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: stryker-incremental - path: reports/stryker-incremental.json + path: /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From e63a7bc7b89b6c731085a94a43afe59ab8a716a4 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:17:32 -0500 Subject: [PATCH 19/65] Update path logic depending on which run runs --- .github/workflows/scheduled.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index c1fb4cd..e3e4ade 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -8,6 +8,7 @@ env: ENVIRONMENT_PATH: src/assets/environment.json DIST_PATH: dist NODE_VERSION: "20.9.0" + INCREMENTAL_PATH: reports/stryker-incremental.json jobs: buildClient: @@ -44,6 +45,7 @@ jobs: if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV else echo "Artifact not found, initializing full Stryker run." npx stryker run --incremental @@ -53,7 +55,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: stryker-incremental - path: /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From 66d1acf7c629a8e8eaa464b196c452d684c57040 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:20:14 -0500 Subject: [PATCH 20/65] Test change to trigger incremental run --- src/app/reactive-form/reactive-form.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/reactive-form/reactive-form.component.spec.ts b/src/app/reactive-form/reactive-form.component.spec.ts index 1073650..bd6f1f5 100644 --- a/src/app/reactive-form/reactive-form.component.spec.ts +++ b/src/app/reactive-form/reactive-form.component.spec.ts @@ -22,7 +22,7 @@ describe('ReactiveFormComponent', () => { expect(component).toBeTruthy(); }); - describe("timesTwoTest", () => { + describe("timesTwoTestChange", () => { it("should return the input value multiplied by two", () => { let results = component.timesTwo(2); @@ -30,7 +30,7 @@ describe('ReactiveFormComponent', () => { }); }); - describe("timesFourTest", () => { + describe("timesFourTestChange", () => { it("should return the input value multiplied by four", () => { let results = component.timesFour(2); From debb3c3fbbf36b474b2e66b54dfeec13970fbd05 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:25:28 -0500 Subject: [PATCH 21/65] Update config to stryke all component files --- stryker.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stryker.config.mjs b/stryker.config.mjs index 4d653b0..905343a 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -2,7 +2,7 @@ /** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */ const config = { mutate: [ - "src/**/*form.component.ts", + "src/**/*.component.ts", "!src/**/*.spec.ts", "!src/test.ts", "!src/environments/*.ts", From 91f4f0a247df316a5d726d15b94b4a13a3b5caa1 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:43:01 -0500 Subject: [PATCH 22/65] Clean up JS logging --- .github/workflows/download-artifact.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index eac546d..950e80e 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -10,7 +10,7 @@ const WORKFLOW_NAME = process.env.WORKFLOW_NAME; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function fetchWorkflowId() { - console.log(`fetchWorkflowId: ${WORKFLOW_NAME}`); + console.log(`fetchWorkflowId for: ${WORKFLOW_NAME}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; const response = await axios.get(url, { headers: { @@ -26,13 +26,13 @@ async function fetchWorkflowId() { throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); } - console.log(`fetchWorkflowId= ${workflow.id}`); + console.log(`workflowId= ${workflow.id}`); return workflow.id; } async function getLatestSuccessfulRun() { const WORKFLOW_ID = await fetchWorkflowId(); - console.log(`getLatestSuccessfulRun: ${WORKFLOW_ID}`); + console.log(`getLatestSuccessfulRun for ${WORKFLOW_ID}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; const response = await axios.get(url, { headers: { @@ -46,12 +46,12 @@ async function getLatestSuccessfulRun() { console.log(`getLatestSuccessfulRun Response status: ${response.status}`); const run = response.data.workflow_runs[0]; - console.log(`getLatestSuccessfulRun= ${run.id}`); + console.log(`latestSuccessfulRunId= ${run.id}`); return run ? run.id : null; } async function getArtifactId(runId) { - console.log(`getArtifactId: ${runId}`); + console.log(`getArtifactId for run#: ${runId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; const response = await axios.get(url, { headers: { @@ -61,14 +61,13 @@ async function getArtifactId(runId) { console.log(`getArtifactId Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); - console.log(`getArtifactId: ${artifact}`); + console.log(`artifactId= ${artifact.id}`); return artifact ? artifact.id : null; } async function downloadArtifact(artifactId) { console.log(`downloadArtifact: ${artifactId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; - console.log(`Request URL: ${url}`); const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` @@ -79,16 +78,16 @@ async function downloadArtifact(artifactId) { console.log(`downloadArtifact Response status: ${response.status}`); const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); fs.writeFileSync(zipPath, Buffer.from(response.data)); - console.log(`downloadArtifact: ${zipPath}`); + console.log(`zipped artifact path: ${zipPath}`); return zipPath; } function extractArtifact(zipPath) { - console.log(`extractArtifact: ${zipPath}`); + console.log(`extractArtifact from: ${zipPath}`); const zip = new AdmZip(zipPath); const extractPath = path.join(__dirname, 'extracted_artifact'); zip.extractAllTo(extractPath, true); - console.log(`extractArtifact: ${extractPath}`); + console.log(`extracted artifact path: ${extractPath}`); return extractPath; } @@ -97,14 +96,12 @@ function extractArtifact(zipPath) { const runId = await getLatestSuccessfulRun(); if (!runId) { console.log('No successful workflow run found'); - fs.writeFileSync('artifact_not_found.flag', ''); return; } const artifactId = await getArtifactId(runId); if (!artifactId) { console.log(`Artifact ${ARTIFACT_NAME} not found`); - fs.writeFileSync('artifact_not_found.flag', ''); return; } @@ -117,12 +114,10 @@ function extractArtifact(zipPath) { const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); if (!fs.existsSync(artifactFilePath)) { console.log(`Artifact file ${artifactFilePath} not found`); - fs.writeFileSync('artifact_not_found.flag', ''); return; } console.log(`Artifact file found at: ${artifactFilePath}`); } catch (error) { console.error(`Error: ${error.message}`); - fs.writeFileSync('artifact_not_found.flag', ''); } })(); \ No newline at end of file From a41fd271272d8decde86bf7d7b1d6805ec7fcfc3 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:54:14 -0500 Subject: [PATCH 23/65] Attempt clean stryker run from scratch with no starting file --- .github/workflows/scheduled.yml | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index e3e4ade..8cf189a 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -28,28 +28,21 @@ jobs: - name: npm install run: npm i - - name: Install Temporary Dependencies - run: npm install axios adm-zip - - - name: Download and Extract Artifact - run: node .github/workflows/download-artifact.js - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} - WORKFLOW_NAME: LetsLearnCI/CD - ARTIFACT_NAME: stryker-incremental + # - name: Install Temporary Dependencies + # run: npm install axios adm-zip + + # - name: Download and Extract Artifact + # run: node .github/workflows/download-artifact.js + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # OWNER: ${{ github.repository_owner }} + # REPO: ${{ github.event.repository.name }} + # WORKFLOW_NAME: LetsLearnCI/CD + # ARTIFACT_NAME: stryker-incremental - name: Run Stryker run: | - if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then - echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - else - echo "Artifact not found, initializing full Stryker run." npx stryker run --incremental - fi - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 From 3141a6f9ce88e396a4cb3b1ac1a8b14fdd9f3d40 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Sun, 22 Sep 2024 17:56:37 -0500 Subject: [PATCH 24/65] Add back incremental file to workflow --- .github/workflows/scheduled.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 8cf189a..e3e4ade 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -28,21 +28,28 @@ jobs: - name: npm install run: npm i - # - name: Install Temporary Dependencies - # run: npm install axios adm-zip - - # - name: Download and Extract Artifact - # run: node .github/workflows/download-artifact.js - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # OWNER: ${{ github.repository_owner }} - # REPO: ${{ github.event.repository.name }} - # WORKFLOW_NAME: LetsLearnCI/CD - # ARTIFACT_NAME: stryker-incremental + - name: Install Temporary Dependencies + run: npm install axios adm-zip + + - name: Download and Extract Artifact + run: node .github/workflows/download-artifact.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + WORKFLOW_NAME: LetsLearnCI/CD + ARTIFACT_NAME: stryker-incremental - name: Run Stryker run: | + if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then + echo "Artifact found, continuing Stryker incremental run." + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV + else + echo "Artifact not found, initializing full Stryker run." npx stryker run --incremental + fi - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 From 00cd11c4e15bbbbbf1fe96bc0a3ab012827a3780 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Mon, 23 Sep 2024 16:39:12 -0500 Subject: [PATCH 25/65] Attempt wild component incrementing scheme, haha --- .github/workflows/download-artifact.js | 78 ++++++++++++++++---------- .github/workflows/scheduled.yml | 28 ++++++--- 2 files changed, 66 insertions(+), 40 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 950e80e..00c68a5 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -2,48 +2,27 @@ const axios = require('axios'); const AdmZip = require('adm-zip'); const fs = require('fs'); const path = require('path'); +const core = require('@actions/core'); +const github = require('@actions/github'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; const REPO = process.env.REPO; -const WORKFLOW_NAME = process.env.WORKFLOW_NAME; +const WORKFLOW_ID = process.env.WORKFLOW_ID; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; -async function fetchWorkflowId() { - console.log(`fetchWorkflowId for: ${WORKFLOW_NAME}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; - const response = await axios.get(url, { - headers: { - Authorization: `token ${GITHUB_TOKEN}` - } - }); - - console.log(`fetchWorkflowId Response status: ${response.status}`); - - - const workflow = response.data.workflows.find(wf => wf.name.includes(WORKFLOW_NAME)); - if (!workflow) { - throw new Error(`Workflow file ${WORKFLOW_FILE_NAME} not found`); - } - - console.log(`workflowId= ${workflow.id}`); - return workflow.id; -} +let previousCount = 0; async function getLatestSuccessfulRun() { - const WORKFLOW_ID = await fetchWorkflowId(); console.log(`getLatestSuccessfulRun for ${WORKFLOW_ID}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; const response = await axios.get(url, { - headers: { - Authorization: `token ${GITHUB_TOKEN}` - }, - params: { - status: 'success', - per_page: 1 - } + headers: { Authorization: `token ${GITHUB_TOKEN}` }, + params: { + status: 'success', + per_page: 1 + } }); - console.log(`getLatestSuccessfulRun Response status: ${response.status}`); const run = response.data.workflow_runs[0]; console.log(`latestSuccessfulRunId= ${run.id}`); @@ -60,7 +39,10 @@ async function getArtifactId(runId) { }); console.log(`getArtifactId Response status: ${response.status}`); - const artifact = response.data.artifacts.find(artifact => artifact.name === ARTIFACT_NAME); + const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); + if (artifact.name.includes('_')) { + previousCount = artifact.name.split('_')[1]; + } console.log(`artifactId= ${artifact.id}`); return artifact ? artifact.id : null; } @@ -91,6 +73,37 @@ function extractArtifact(zipPath) { return extractPath; } +async function getComponentFiles() { + if (previousCount === 'complete') { + core.exportVariable('COMPONENT_COUNT', 'complete'); + return; + } + try { + const { context } = github; + const { data: files } = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + + const componentFiles = files + .map(file => file.filename) + .filter(filename => filename.endsWith('.component.ts')); + + const componentsToStryke = componentFiles.slice(0, previousCount+1); + + if (componentFiles.length > 0 && componentFiles.length === componentsToStryke.length) { + core.exportVariable('COMPONENT_COUNT', 'complete'); + } else { + core.exportVariable('COMPONENT_FILES', componentsToStryke.join(', ')); + core.exportVariable('COMPONENT_COUNT', previousCount+1); + } + + } catch (error) { + core.setFailed(error.message); + } + } + (async () => { try { const runId = await getLatestSuccessfulRun(); @@ -117,6 +130,9 @@ function extractArtifact(zipPath) { return; } console.log(`Artifact file found at: ${artifactFilePath}`); + + getComponentFiles(); + } catch (error) { console.error(`Error: ${error.message}`); } diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index e3e4ade..4e09878 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -5,10 +5,10 @@ on: branches: ["master"] env: - ENVIRONMENT_PATH: src/assets/environment.json - DIST_PATH: dist NODE_VERSION: "20.9.0" INCREMENTAL_PATH: reports/stryker-incremental.json + COMPONENT_COUNT: 1 + COMPONENT_FILES: '' jobs: buildClient: @@ -29,32 +29,42 @@ jobs: run: npm i - name: Install Temporary Dependencies - run: npm install axios adm-zip + run: npm install axios adm-zip @actions/core @actions/github - - name: Download and Extract Artifact + - name: Download and Extract Incremental File run: node .github/workflows/download-artifact.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} - WORKFLOW_NAME: LetsLearnCI/CD + WORKFLOW_ID: 116600610 ARTIFACT_NAME: stryker-incremental - name: Run Stryker run: | if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + if [ "$COMPONENT_COUNT" = 'complete' ]; then + echo "Component counting is complete, running Stryker incremental with all files." + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + else if [ "$COMPONENT_FILES" != '']; then + echo "Component count is $COMPONENT_COUNT, running Stryker incremental with $COMPONENT_FILES." + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json --files "$COMPONENT_FILES" + else + echo "Component count is $COMPONENT_COUNT, but no component files were defined to stryke. Unable to run Stryker incremental." + fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV + else if [ "$COMPONENT_FILES" = '']; then + echo "Artifact not found, and no component files were defined to stryke. Unable to run Stryker incremental." else - echo "Artifact not found, initializing full Stryker run." - npx stryker run --incremental + echo "Artifact not found, running Stryker incremental with $COMPONENT_FILES." + npx stryker run --incremental --files "$COMPONENT_FILES" fi - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 with: - name: stryker-incremental + name: stryker-incremental_${{ env.COMPONENT_COUNT }} path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report From 5909890c0736883dd53f46a97d6273a100083aff Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Mon, 23 Sep 2024 16:43:10 -0500 Subject: [PATCH 26/65] Fix mistake in octokit call --- .github/workflows/download-artifact.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 00c68a5..8a91f42 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -80,7 +80,10 @@ async function getComponentFiles() { } try { const { context } = github; - const { data: files } = await github.rest.pulls.listFiles({ + const token = core.getInput('GITHUB_TOKEN'); + const octokit = github.getOctokit(token); + + const { data: files } = await octokit.rest.pulls.listFiles({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number From 6db0f9f1768718efdfcccaab81762ff6aba77c07 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Mon, 23 Sep 2024 16:46:21 -0500 Subject: [PATCH 27/65] Try to fix token issue --- .github/workflows/download-artifact.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 8a91f42..aa03f61 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -80,8 +80,7 @@ async function getComponentFiles() { } try { const { context } = github; - const token = core.getInput('GITHUB_TOKEN'); - const octokit = github.getOctokit(token); + const octokit = github.getOctokit(GITHUB_TOKEN); const { data: files } = await octokit.rest.pulls.listFiles({ owner: context.repo.owner, From 25e90b24bd8cbd0603213482a1637abac0d563d9 Mon Sep 17 00:00:00 2001 From: Stephanie Leazer Date: Mon, 23 Sep 2024 16:50:35 -0500 Subject: [PATCH 28/65] Fix else/if syntax for stryker run logic --- .github/workflows/scheduled.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 4e09878..7b3817d 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -47,18 +47,18 @@ jobs: if [ "$COMPONENT_COUNT" = 'complete' ]; then echo "Component counting is complete, running Stryker incremental with all files." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - else if [ "$COMPONENT_FILES" != '']; then + elif [ "$COMPONENT_FILES" != '' ]; then echo "Component count is $COMPONENT_COUNT, running Stryker incremental with $COMPONENT_FILES." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json --files "$COMPONENT_FILES" else - echo "Component count is $COMPONENT_COUNT, but no component files were defined to stryke. Unable to run Stryker incremental." + echo "Component count is $COMPONENT_COUNT, but no component files were defined to stryke. Unable to run Stryker incremental." fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - else if [ "$COMPONENT_FILES" = '']; then - echo "Artifact not found, and no component files were defined to stryke. Unable to run Stryker incremental." + elif [ "$COMPONENT_FILES" = '' ]; then + echo "Artifact not found, and no component files were defined to stryke. Unable to run Stryker incremental." else echo "Artifact not found, running Stryker incremental with $COMPONENT_FILES." - npx stryker run --incremental --files "$COMPONENT_FILES" + npx stryker run --incremental --files "$COMPONENT_FILES" fi - name: Upload Stryker Incremental Report From 3869548932b2715cd4a1f073896b42e8db10de30 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Tue, 10 Dec 2024 20:03:39 -0600 Subject: [PATCH 29/65] Try to stryke all files that have a .spec file --- .github/workflows/download-artifact.js | 37 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index aa03f61..4624e53 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -82,19 +82,38 @@ async function getComponentFiles() { const { context } = github; const octokit = github.getOctokit(GITHUB_TOKEN); - const { data: files } = await octokit.rest.pulls.listFiles({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number - }); + async function getAllFiles(octokit, owner, repo, path) { + const { data: items } = await octokit.rest.repos.getContent({ + owner, + repo, + path + }); + + let files = []; + + for (const item of items) { + if (item.type === 'file') { + files.push(item.path); + } else if (item.type === 'dir') { + const subFiles = await getAllFiles(octokit, owner, repo, item.path); + files = files.concat(subFiles); + } + } + + return files; + } + + const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); + console.log(files); - const componentFiles = files + const filesWithTests = allFiles .map(file => file.filename) - .filter(filename => filename.endsWith('.component.ts')); + .filter(filename => filename.endsWith('.spec.ts')) + .map(testFile => testFile.replace('.spec.ts', '.ts')); - const componentsToStryke = componentFiles.slice(0, previousCount+1); + const filesToStryke = filesWithTests.slice(0, previousCount+1); - if (componentFiles.length > 0 && componentFiles.length === componentsToStryke.length) { + if (filesToStryke.length > 0 && filesToStryke.length === filesToStryke.length) { core.exportVariable('COMPONENT_COUNT', 'complete'); } else { core.exportVariable('COMPONENT_FILES', componentsToStryke.join(', ')); From 52aadfdf5abd16058818b8e903218056ff9e3910 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Tue, 10 Dec 2024 20:14:44 -0600 Subject: [PATCH 30/65] Fix mistakes in .js logic --- .github/workflows/download-artifact.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 4624e53..d739b90 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -104,10 +104,9 @@ async function getComponentFiles() { } const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); - console.log(files); + console.log(allFiles); const filesWithTests = allFiles - .map(file => file.filename) .filter(filename => filename.endsWith('.spec.ts')) .map(testFile => testFile.replace('.spec.ts', '.ts')); From 157d630caf9a5f3dd8f77b2365ae96ab419eeff9 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 07:03:23 -0600 Subject: [PATCH 31/65] Change a few logging lines for clarity --- .github/workflows/download-artifact.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index d739b90..4b09ca6 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -14,7 +14,7 @@ const ARTIFACT_NAME = process.env.ARTIFACT_NAME; let previousCount = 0; async function getLatestSuccessfulRun() { - console.log(`getLatestSuccessfulRun for ${WORKFLOW_ID}`); + console.log(`gettingLatestSuccessfulRun for ${WORKFLOW_ID}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, @@ -30,7 +30,7 @@ async function getLatestSuccessfulRun() { } async function getArtifactId(runId) { - console.log(`getArtifactId for run#: ${runId}`); + console.log(`gettingArtifactId for run#: ${runId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; const response = await axios.get(url, { headers: { @@ -48,7 +48,7 @@ async function getArtifactId(runId) { } async function downloadArtifact(artifactId) { - console.log(`downloadArtifact: ${artifactId}`); + console.log(`downloadingArtifact: ${artifactId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; const response = await axios.get(url, { headers: { @@ -60,16 +60,16 @@ async function downloadArtifact(artifactId) { console.log(`downloadArtifact Response status: ${response.status}`); const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); fs.writeFileSync(zipPath, Buffer.from(response.data)); - console.log(`zipped artifact path: ${zipPath}`); + // console.log(`zipped artifact path: ${zipPath}`); return zipPath; } function extractArtifact(zipPath) { - console.log(`extractArtifact from: ${zipPath}`); + console.log(`extractingArtifact from: ${zipPath}`); const zip = new AdmZip(zipPath); const extractPath = path.join(__dirname, 'extracted_artifact'); zip.extractAllTo(extractPath, true); - console.log(`extracted artifact path: ${extractPath}`); + // console.log(`extracted artifact path: ${extractPath}`); return extractPath; } @@ -103,12 +103,13 @@ async function getComponentFiles() { return files; } - const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); - console.log(allFiles); + const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); const filesWithTests = allFiles - .filter(filename => filename.endsWith('.spec.ts')) + .filter(filename => filename.endsWith('.spec.ts'))`` .map(testFile => testFile.replace('.spec.ts', '.ts')); + + console.log(filesWithTests); const filesToStryke = filesWithTests.slice(0, previousCount+1); From 81f1ba7ffb80175016ecabde341fd69353acbfd0 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 09:00:43 -0600 Subject: [PATCH 32/65] Big logic change for stryking + reset count back to 0 --- .github/workflows/download-artifact.js | 194 ++++++++++++------------- .github/workflows/scheduled.yml | 14 +- 2 files changed, 98 insertions(+), 110 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 4b09ca6..35b10a7 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -25,136 +25,132 @@ async function getLatestSuccessfulRun() { }); console.log(`getLatestSuccessfulRun Response status: ${response.status}`); const run = response.data.workflow_runs[0]; - console.log(`latestSuccessfulRunId= ${run.id}`); + console.log(`latestSuccessfulRunId = ${run.id}`); return run ? run.id : null; } async function getArtifactId(runId) { - console.log(`gettingArtifactId for run#: ${runId}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; - const response = await axios.get(url, { - headers: { - Authorization: `token ${GITHUB_TOKEN}` + if (!runId) { + console.log('NULL runId provided, unable to get artifactId'); + return null; } - }); + console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; + const response = await axios.get(url, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + } + }); - console.log(`getArtifactId Response status: ${response.status}`); - const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - if (artifact.name.includes('_')) { - previousCount = artifact.name.split('_')[1]; - } - console.log(`artifactId= ${artifact.id}`); - return artifact ? artifact.id : null; + console.log(`getArtifactId Response status: ${response.status}`); + const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); + // if (artifact.name.includes('_')) { + // previousCount = artifact.name.split('_')[1]; + // } + console.log(`artifactId = ${artifact.id}`); + return artifact ? artifact.id : null; } async function downloadArtifact(artifactId) { - console.log(`downloadingArtifact: ${artifactId}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; - const response = await axios.get(url, { - headers: { - Authorization: `token ${GITHUB_TOKEN}` - }, - responseType: 'arraybuffer' - }); - - console.log(`downloadArtifact Response status: ${response.status}`); - const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); - fs.writeFileSync(zipPath, Buffer.from(response.data)); - // console.log(`zipped artifact path: ${zipPath}`); - return zipPath; + if (!artifactId) { + console.log('NULL artifactId provided, unable to download artifact'); + return null; + } + console.log(`Valid artifactId provided, downloadingArtifact: ${artifactId}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; + const response = await axios.get(url, { + headers: { + Authorization: `token ${GITHUB_TOKEN}` + }, + responseType: 'arraybuffer' + }); + + console.log(`downloadArtifact Response status: ${response.status}`); + const zipPath = path.join(__dirname, `${ARTIFACT_NAME}.zip`); + fs.writeFileSync(zipPath, Buffer.from(response.data)); + console.log(`zipped artifact path: ${zipPath}`); + return zipPath; } function extractArtifact(zipPath) { - console.log(`extractingArtifact from: ${zipPath}`); - const zip = new AdmZip(zipPath); - const extractPath = path.join(__dirname, 'extracted_artifact'); - zip.extractAllTo(extractPath, true); - // console.log(`extracted artifact path: ${extractPath}`); - return extractPath; + if (!zipPath) { + console.log('NULL zipPath provided, unable to extract artifact'); + return null; + } + console.log(`Valid zipPath provided, extractingArtifact from: ${zipPath}`); + const zip = new AdmZip(zipPath); + const extractPath = path.join(__dirname, 'extracted_artifact'); + zip.extractAllTo(extractPath, true); + console.log(`extracted artifact path: ${extractPath}`); + return extractPath; } -async function getComponentFiles() { - if (previousCount === 'complete') { - core.exportVariable('COMPONENT_COUNT', 'complete'); - return; +async function getAllFiles(octokit, owner, repo, path) { + const { data: items } = await octokit.rest.repos.getContent({ + owner, + repo, + path + }); + + let files = []; + + for (const item of items) { + if (item.type === 'file') { + files.push(item.path); + } else if (item.type === 'dir') { + const subFiles = await getAllFiles(octokit, owner, repo, item.path); + files = files.concat(subFiles); + } } + + return files; +} + +async function getComponentFiles() { try { const { context } = github; const octokit = github.getOctokit(GITHUB_TOKEN); - - async function getAllFiles(octokit, owner, repo, path) { - const { data: items } = await octokit.rest.repos.getContent({ - owner, - repo, - path - }); - - let files = []; - - for (const item of items) { - if (item.type === 'file') { - files.push(item.path); - } else if (item.type === 'dir') { - const subFiles = await getAllFiles(octokit, owner, repo, item.path); - files = files.concat(subFiles); - } - } - - return files; - } - + const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); - const filesWithTests = allFiles - .filter(filename => filename.endsWith('.spec.ts'))`` + const allFilesWithTests = allFiles + .filter(filename => filename.endsWith('.spec.ts')) .map(testFile => testFile.replace('.spec.ts', '.ts')); - - console.log(filesWithTests); + console.log(filesWithTests); - const filesToStryke = filesWithTests.slice(0, previousCount+1); - - if (filesToStryke.length > 0 && filesToStryke.length === filesToStryke.length) { - core.exportVariable('COMPONENT_COUNT', 'complete'); - } else { - core.exportVariable('COMPONENT_FILES', componentsToStryke.join(', ')); + if (allFilesWithTests.length() === 0) { + core.exportVariable('COMPONENT_FILES', ''); + + } else if (allFilesWithTests.length() > previousCount) { + const filesToStryke = allFilesWithTests.slice(0, previousCount+1); + core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); core.exportVariable('COMPONENT_COUNT', previousCount+1); - } + } else if (allFilesWithTests.length() === previousCount) { + core.exportVariable('COMPONENT_FILES', allFilesWithTests.join(', ')); + } + } catch (error) { core.setFailed(error.message); } } (async () => { - try { - const runId = await getLatestSuccessfulRun(); - if (!runId) { - console.log('No successful workflow run found'); - return; - } - - const artifactId = await getArtifactId(runId); - if (!artifactId) { - console.log(`Artifact ${ARTIFACT_NAME} not found`); - return; - } - - const zipPath = await downloadArtifact(artifactId); - console.log(`Artifact downloaded to: ${zipPath}`); + try { + const runId = await getLatestSuccessfulRun(); + const artifactId = await getArtifactId(runId); + const zipPath = await downloadArtifact(artifactId); + const extractPath = extractArtifact(zipPath); + const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); + + if (!fs.existsSync(artifactFilePath)) { + console.log(`Artifact file ${artifactFilePath} not found`); + } + console.log(`Artifact file found at: ${artifactFilePath}`); - const extractPath = extractArtifact(zipPath); - console.log(`Artifact extracted to: ${extractPath}`); + getComponentFiles(); - const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); - if (!fs.existsSync(artifactFilePath)) { - console.log(`Artifact file ${artifactFilePath} not found`); - return; + } catch (error) { + console.error(`Error: ${error.message}`); } - console.log(`Artifact file found at: ${artifactFilePath}`); - - getComponentFiles(); - - } catch (error) { - console.error(`Error: ${error.message}`); - } })(); \ No newline at end of file diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 7b3817d..b22208c 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -44,21 +44,13 @@ jobs: run: | if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Artifact found, continuing Stryker incremental run." - if [ "$COMPONENT_COUNT" = 'complete' ]; then - echo "Component counting is complete, running Stryker incremental with all files." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - elif [ "$COMPONENT_FILES" != '' ]; then - echo "Component count is $COMPONENT_COUNT, running Stryker incremental with $COMPONENT_FILES." + if [ "$COMPONENT_FILES" != '' ]; then + echo "Running Stryker incremental with $COMPONENT_FILES." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json --files "$COMPONENT_FILES" else - echo "Component count is $COMPONENT_COUNT, but no component files were defined to stryke. Unable to run Stryker incremental." + echo "No component files were defined to stryke. Unable to run Stryker incremental." fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - elif [ "$COMPONENT_FILES" = '' ]; then - echo "Artifact not found, and no component files were defined to stryke. Unable to run Stryker incremental." - else - echo "Artifact not found, running Stryker incremental with $COMPONENT_FILES." - npx stryker run --incremental --files "$COMPONENT_FILES" fi - name: Upload Stryker Incremental Report From 6c2f1bb751b62c8792e4f21e76ccd4cf653f52d8 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 09:02:57 -0600 Subject: [PATCH 33/65] Fix missed renambed variable --- .github/workflows/download-artifact.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 35b10a7..e281f9e 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -116,7 +116,7 @@ async function getComponentFiles() { const allFilesWithTests = allFiles .filter(filename => filename.endsWith('.spec.ts')) .map(testFile => testFile.replace('.spec.ts', '.ts')); - console.log(filesWithTests); + console.log(allFilesWithTests); if (allFilesWithTests.length() === 0) { core.exportVariable('COMPONENT_FILES', ''); From f02ab56fbe5b1103a76e62034735155faca500f9 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 09:05:14 -0600 Subject: [PATCH 34/65] Fix stupid mistake --- .github/workflows/download-artifact.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index e281f9e..539b7a9 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -118,15 +118,15 @@ async function getComponentFiles() { .map(testFile => testFile.replace('.spec.ts', '.ts')); console.log(allFilesWithTests); - if (allFilesWithTests.length() === 0) { + if (allFilesWithTests.length === 0) { core.exportVariable('COMPONENT_FILES', ''); - } else if (allFilesWithTests.length() > previousCount) { + } else if (allFilesWithTests.length > previousCount) { const filesToStryke = allFilesWithTests.slice(0, previousCount+1); core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); core.exportVariable('COMPONENT_COUNT', previousCount+1); - } else if (allFilesWithTests.length() === previousCount) { + } else if (allFilesWithTests.length === previousCount) { core.exportVariable('COMPONENT_FILES', allFilesWithTests.join(', ')); } From 4d73152265c94cd36ff7cbd9c5d307c9bb46de83 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 10:37:42 -0600 Subject: [PATCH 35/65] BIG logic change, using stryker.config for files, etc --- .github/workflows/determine-files.js | 52 +++++++++++++++++++++++++ .github/workflows/download-artifact.js | 54 -------------------------- .github/workflows/scheduled.yml | 20 ++++++++-- stryker.config.mjs | 7 +--- 4 files changed, 70 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/determine-files.js diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js new file mode 100644 index 0000000..12e1a24 --- /dev/null +++ b/.github/workflows/determine-files.js @@ -0,0 +1,52 @@ +const core = require('@actions/core'); +const github = require('@actions/github'); + +async function getAllFiles(octokit, owner, repo, path) { + const { data: items } = await octokit.rest.repos.getContent({ + owner, + repo, + path + }); + + let files = []; + + for (const item of items) { + if (item.type === 'file') { + files.push(item.path); + } else if (item.type === 'dir') { + const subFiles = await getAllFiles(octokit, owner, repo, item.path); + files = files.concat(subFiles); + } + } + + return files; +} + +(async () => { + try { + const { context } = github; + const octokit = github.getOctokit(process.env.GITHUB_TOKEN); + let prevCount = parseInt(process.env.COMPONENT_COUNT, 10); + + const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src/app'); + + const allFilesWithTests = allFiles + .filter(filename => filename.endsWith('.spec.ts')) + .map(testFile => testFile.replace('.spec.ts', '.ts')); + + if (allFilesWithTests.length === 0) { + console.log('No test files found'); + core.exportVariable('COMPONENT_FILES', ''); + core.exportVariable('COMPONENT_COUNT', 0); + } else if (allFilesWithTests.length > prevCount) { + const filesToStryke = allFilesWithTests.slice(0, previousCount+1); + core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); + core.exportVariable('COMPONENT_COUNT', prevCount+1); + } else { + core.exportVariable('COMPONENT_FILES', allFilesWithTests.join(', ')); + } + + } catch (error) { + core.setFailed(error.message); + } +})(); \ No newline at end of file diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 539b7a9..e5d0e4d 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -2,8 +2,6 @@ const axios = require('axios'); const AdmZip = require('adm-zip'); const fs = require('fs'); const path = require('path'); -const core = require('@actions/core'); -const github = require('@actions/github'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; @@ -85,56 +83,6 @@ function extractArtifact(zipPath) { return extractPath; } -async function getAllFiles(octokit, owner, repo, path) { - const { data: items } = await octokit.rest.repos.getContent({ - owner, - repo, - path - }); - - let files = []; - - for (const item of items) { - if (item.type === 'file') { - files.push(item.path); - } else if (item.type === 'dir') { - const subFiles = await getAllFiles(octokit, owner, repo, item.path); - files = files.concat(subFiles); - } - } - - return files; -} - -async function getComponentFiles() { - try { - const { context } = github; - const octokit = github.getOctokit(GITHUB_TOKEN); - - const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src'); - - const allFilesWithTests = allFiles - .filter(filename => filename.endsWith('.spec.ts')) - .map(testFile => testFile.replace('.spec.ts', '.ts')); - console.log(allFilesWithTests); - - if (allFilesWithTests.length === 0) { - core.exportVariable('COMPONENT_FILES', ''); - - } else if (allFilesWithTests.length > previousCount) { - const filesToStryke = allFilesWithTests.slice(0, previousCount+1); - core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); - core.exportVariable('COMPONENT_COUNT', previousCount+1); - - } else if (allFilesWithTests.length === previousCount) { - core.exportVariable('COMPONENT_FILES', allFilesWithTests.join(', ')); - } - - } catch (error) { - core.setFailed(error.message); - } - } - (async () => { try { const runId = await getLatestSuccessfulRun(); @@ -148,8 +96,6 @@ async function getComponentFiles() { } console.log(`Artifact file found at: ${artifactFilePath}`); - getComponentFiles(); - } catch (error) { console.error(`Error: ${error.message}`); } diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index b22208c..f066421 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -40,18 +40,32 @@ jobs: WORKFLOW_ID: 116600610 ARTIFACT_NAME: stryker-incremental + - name: Determine Files to Stryke + run: node .github/workflows/determine-files.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPONENT_COUNT: ${{ env.COMPONENT_COUNT }} + - name: Run Stryker run: | if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then - echo "Artifact found, continuing Stryker incremental run." + echo "Incremental artifact found, continuing Stryker incremental run." if [ "$COMPONENT_FILES" != '' ]; then echo "Running Stryker incremental with $COMPONENT_FILES." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json --files "$COMPONENT_FILES" + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "No component files were defined to stryke. Unable to run Stryker incremental." fi - echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV + else + echo "No incremental artifact round, running Stryker as initial incremental run." + if [ "$COMPONENT_FILES" != '' ]; then + echo "Running Stryker with $COMPONENT_FILES." + npx stryker run --incremental + else + echo "No component files were defined to stryke. Unable to run Stryker." + fi fi + echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - name: Upload Stryker Incremental Report uses: actions/upload-artifact@v4 diff --git a/stryker.config.mjs b/stryker.config.mjs index 905343a..7bc42d1 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -1,12 +1,7 @@ // @ts-check /** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */ const config = { - mutate: [ - "src/**/*.component.ts", - "!src/**/*.spec.ts", - "!src/test.ts", - "!src/environments/*.ts", - ], + mutate: process.env.COMPONENT_FILES ? process.env.COMPONENT_FILES.split(', ') : [], testRunner: "karma", karma: { configFile: "karma.conf.js", From 4485e05335828174316565388319a0a373c806de Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 10:39:44 -0600 Subject: [PATCH 36/65] Fix missed variable rename --- .github/workflows/determine-files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index 12e1a24..441c9e7 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -39,7 +39,7 @@ async function getAllFiles(octokit, owner, repo, path) { core.exportVariable('COMPONENT_FILES', ''); core.exportVariable('COMPONENT_COUNT', 0); } else if (allFilesWithTests.length > prevCount) { - const filesToStryke = allFilesWithTests.slice(0, previousCount+1); + const filesToStryke = allFilesWithTests.slice(0, prevCount+1); core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); core.exportVariable('COMPONENT_COUNT', prevCount+1); } else { From 079d1adf5088a2370b4d289adb215934575cf05c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 10:50:18 -0600 Subject: [PATCH 37/65] Re-implement getting prev count from artifact to continue the stryking --- .github/workflows/determine-files.js | 2 +- .github/workflows/download-artifact.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index 441c9e7..20a305a 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -49,4 +49,4 @@ async function getAllFiles(octokit, owner, repo, path) { } catch (error) { core.setFailed(error.message); } -})(); \ No newline at end of file +})(); diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index e5d0e4d..711f151 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -1,5 +1,6 @@ const axios = require('axios'); const AdmZip = require('adm-zip'); +const core = require('@actions/core'); const fs = require('fs'); const path = require('path'); @@ -9,8 +10,6 @@ const REPO = process.env.REPO; const WORKFLOW_ID = process.env.WORKFLOW_ID; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; -let previousCount = 0; - async function getLatestSuccessfulRun() { console.log(`gettingLatestSuccessfulRun for ${WORKFLOW_ID}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; @@ -42,9 +41,10 @@ async function getArtifactId(runId) { console.log(`getArtifactId Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - // if (artifact.name.includes('_')) { - // previousCount = artifact.name.split('_')[1]; - // } + if (artifact.name.includes('_')) { + let previousCount = artifact.name.split('_')[1]; + core.exportVariable('COMPONENT_COUNT', previousCount); + } console.log(`artifactId = ${artifact.id}`); return artifact ? artifact.id : null; } From df27bbaf4ac4550b3088952fcf298b7c2859d4d6 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 11:16:46 -0600 Subject: [PATCH 38/65] Adding a comment to inspect what the next run does --- .github/workflows/determine-files.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index 20a305a..3de7aab 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -50,3 +50,5 @@ async function getAllFiles(octokit, owner, repo, path) { core.setFailed(error.message); } })(); + +//commenting a change to see what the next Stryker run does \ No newline at end of file From 80c633caeb54c4ba73e5c9aed0db1af9a76ffdc1 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 11:21:17 -0600 Subject: [PATCH 39/65] Forcing NULL artifact workflow to test fresh incremental run --- .github/workflows/download-artifact.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 711f151..1553c88 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -27,7 +27,11 @@ async function getLatestSuccessfulRun() { } async function getArtifactId(runId) { - if (!runId) { + if (true) { + console.log('NULL on purpose to negate artifact workflow'); + return null; + } + if (!runId) { console.log('NULL runId provided, unable to get artifactId'); return null; } From df263c43577c7a281bf8120283418ac33e3a800c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 11:46:00 -0600 Subject: [PATCH 40/65] Update files to match glob pattern for stryker.config --- .github/workflows/determine-files.js | 4 +--- .github/workflows/download-artifact.js | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index 3de7aab..aee2f97 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -32,7 +32,7 @@ async function getAllFiles(octokit, owner, repo, path) { const allFilesWithTests = allFiles .filter(filename => filename.endsWith('.spec.ts')) - .map(testFile => testFile.replace('.spec.ts', '.ts')); + .map(testFile => `src/app/**/${testFile.replace('.spec.ts', '.ts')}`); if (allFilesWithTests.length === 0) { console.log('No test files found'); @@ -50,5 +50,3 @@ async function getAllFiles(octokit, owner, repo, path) { core.setFailed(error.message); } })(); - -//commenting a change to see what the next Stryker run does \ No newline at end of file diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 1553c88..308bdd3 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -27,10 +27,10 @@ async function getLatestSuccessfulRun() { } async function getArtifactId(runId) { - if (true) { - console.log('NULL on purpose to negate artifact workflow'); - return null; - } + // if (true) { + // console.log('NULL on purpose to negate artifact workflow'); + // return null; + // } if (!runId) { console.log('NULL runId provided, unable to get artifactId'); return null; From 4cd883adfd661db4029674576bf42d02551941f6 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 11:55:06 -0600 Subject: [PATCH 41/65] Add logging to check files --- .github/workflows/determine-files.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index aee2f97..f82f59e 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -29,10 +29,12 @@ async function getAllFiles(octokit, owner, repo, path) { let prevCount = parseInt(process.env.COMPONENT_COUNT, 10); const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src/app'); + console.log("All files: ", allFiles); const allFilesWithTests = allFiles .filter(filename => filename.endsWith('.spec.ts')) - .map(testFile => `src/app/**/${testFile.replace('.spec.ts', '.ts')}`); + .map(testFile => testFile.replace('.spec.ts', '.ts')); + console.log("All files with tests: ", allFilesWithTests); if (allFilesWithTests.length === 0) { console.log('No test files found'); @@ -50,3 +52,5 @@ async function getAllFiles(octokit, owner, repo, path) { core.setFailed(error.message); } })(); + +//commenting a change to see what the next Stryker run does \ No newline at end of file From 79db3202b60810ead4b9e5bbc3fc7c3b7cc943ca Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 12:00:51 -0600 Subject: [PATCH 42/65] Adding random tests to check progress --- .../angular-resources.component.spec.ts | 25 +++++++++++++++++++ .../angular-resources.component.ts | 13 ++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/app/angular-resources/angular-resources.component.spec.ts b/src/app/angular-resources/angular-resources.component.spec.ts index cf489b3..4eb1568 100644 --- a/src/app/angular-resources/angular-resources.component.spec.ts +++ b/src/app/angular-resources/angular-resources.component.spec.ts @@ -20,4 +20,29 @@ describe('AngularResourcesComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe("timesTwoTestChange", () => { + it("should return the input value multiplied by two", () => { + let results = component.timesTwo(2); + + expect(results).toBe(4); + }); + }); + + describe("timesFourTestChange", () => { + it("should return the input value multiplied by four", () => { + let results = component.timesFour(2); + + expect(results).toBe(8); + }); + }); + + describe("timesEightTest", () => { + it("should return the input value multiplied by eight", () => { + let results = component.timesEight(2); + + expect(results).toBe(16); + }); + }); + }); diff --git a/src/app/angular-resources/angular-resources.component.ts b/src/app/angular-resources/angular-resources.component.ts index c97c257..823e4e0 100644 --- a/src/app/angular-resources/angular-resources.component.ts +++ b/src/app/angular-resources/angular-resources.component.ts @@ -10,6 +10,19 @@ export class AngularResourcesComponent implements OnInit { constructor() { } ngOnInit(): void { + + } + + timesTwo(entry: number): number { + return entry * 2; + } + + timesFour(entry: number): number { + return entry * 4; + } + + timesEight(entry: number): number { + return entry * 8; } } From 85b4dd82179fb402aa3c693657879018e78dd623 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 12:11:43 -0600 Subject: [PATCH 43/65] Add incrementalFile path to npx command --- .github/workflows/scheduled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index f066421..47fae63 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -60,7 +60,7 @@ jobs: echo "No incremental artifact round, running Stryker as initial incremental run." if [ "$COMPONENT_FILES" != '' ]; then echo "Running Stryker with $COMPONENT_FILES." - npx stryker run --incremental + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "No component files were defined to stryke. Unable to run Stryker." fi From 4a2529e4d6f3fc4dd5861c53b114b30f108c2892 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 14:55:44 -0600 Subject: [PATCH 44/65] Update logging for clarity and null guard artifact --- .github/workflows/download-artifact.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 308bdd3..6e5478b 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -27,12 +27,8 @@ async function getLatestSuccessfulRun() { } async function getArtifactId(runId) { - // if (true) { - // console.log('NULL on purpose to negate artifact workflow'); - // return null; - // } if (!runId) { - console.log('NULL runId provided, unable to get artifactId'); + console.log('Invalid runId provided, unable to get artifactId'); return null; } console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); @@ -45,7 +41,7 @@ async function getArtifactId(runId) { console.log(`getArtifactId Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - if (artifact.name.includes('_')) { + if (artifact && artifact.name.includes('_')) { let previousCount = artifact.name.split('_')[1]; core.exportVariable('COMPONENT_COUNT', previousCount); } @@ -55,7 +51,7 @@ async function getArtifactId(runId) { async function downloadArtifact(artifactId) { if (!artifactId) { - console.log('NULL artifactId provided, unable to download artifact'); + console.log('Invalid artifactId provided, unable to download artifact'); return null; } console.log(`Valid artifactId provided, downloadingArtifact: ${artifactId}`); @@ -76,7 +72,7 @@ async function downloadArtifact(artifactId) { function extractArtifact(zipPath) { if (!zipPath) { - console.log('NULL zipPath provided, unable to extract artifact'); + console.log('Invalid zipPath provided, unable to extract artifact'); return null; } console.log(`Valid zipPath provided, extractingArtifact from: ${zipPath}`); From f8fb54598906782d41f56763df4c24cf13f55e7b Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 14:56:15 -0600 Subject: [PATCH 45/65] Temporarily remove uploading artifact to test something --- .github/workflows/scheduled.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 47fae63..fd69da8 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -67,11 +67,11 @@ jobs: fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - - name: Upload Stryker Incremental Report - uses: actions/upload-artifact@v4 - with: - name: stryker-incremental_${{ env.COMPONENT_COUNT }} - path: ${{ env.INCREMENTAL_PATH }} + # - name: Upload Stryker Incremental Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-incremental_${{ env.COMPONENT_COUNT }} + # path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From 522654c50fed5f386442a7b796bfb78b0a7f34bd Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 15:02:29 -0600 Subject: [PATCH 46/65] Commenting a change to see what the next run does --- .github/workflows/download-artifact.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 6e5478b..74913e1 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -99,4 +99,6 @@ function extractArtifact(zipPath) { } catch (error) { console.error(`Error: ${error.message}`); } -})(); \ No newline at end of file +})(); + +// Commenting a change to see what the next Stryker run does \ No newline at end of file From b9c00a45513ca3075e59e173ba6209af4d1fd476 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 15:06:52 -0600 Subject: [PATCH 47/65] Move console log to prevent errors --- .github/workflows/download-artifact.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 74913e1..2f21d16 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -44,8 +44,8 @@ async function getArtifactId(runId) { if (artifact && artifact.name.includes('_')) { let previousCount = artifact.name.split('_')[1]; core.exportVariable('COMPONENT_COUNT', previousCount); + console.log(`artifactId = ${artifact.id}`); } - console.log(`artifactId = ${artifact.id}`); return artifact ? artifact.id : null; } From 9666f7f8585701053cf4472f6dddceabefb3a38c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:10:48 -0600 Subject: [PATCH 48/65] Rework logic in artifact download --- .github/workflows/download-artifact.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 2f21d16..6af0b7a 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -78,9 +78,17 @@ function extractArtifact(zipPath) { console.log(`Valid zipPath provided, extractingArtifact from: ${zipPath}`); const zip = new AdmZip(zipPath); const extractPath = path.join(__dirname, 'extracted_artifact'); + zip.extractAllTo(extractPath, true); - console.log(`extracted artifact path: ${extractPath}`); - return extractPath; + console.log(`extracted artifact to: ${extractPath}`); + + const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); + + if (fs.existsSync(artifactFilePath)) { + console.log(`Artifact file found at: ${artifactFilePath}`); + } else { + console.log(`Artifact file ${artifactFilePath} not found`); + } } (async () => { @@ -88,13 +96,7 @@ function extractArtifact(zipPath) { const runId = await getLatestSuccessfulRun(); const artifactId = await getArtifactId(runId); const zipPath = await downloadArtifact(artifactId); - const extractPath = extractArtifact(zipPath); - const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); - - if (!fs.existsSync(artifactFilePath)) { - console.log(`Artifact file ${artifactFilePath} not found`); - } - console.log(`Artifact file found at: ${artifactFilePath}`); + extractArtifact(zipPath); } catch (error) { console.error(`Error: ${error.message}`); From aa0a6a19563712cd4ece1cf6a9dba5b65956b704 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:16:46 -0600 Subject: [PATCH 49/65] Update logging for clarity --- .github/workflows/download-artifact.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 6af0b7a..c7e4e9f 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -28,7 +28,7 @@ async function getLatestSuccessfulRun() { async function getArtifactId(runId) { if (!runId) { - console.log('Invalid runId provided, unable to get artifactId'); + console.log(`Invalid runId provided (${runId}), unable to get artifactId`); return null; } console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); @@ -51,7 +51,7 @@ async function getArtifactId(runId) { async function downloadArtifact(artifactId) { if (!artifactId) { - console.log('Invalid artifactId provided, unable to download artifact'); + console.log(`Invalid artifactId provided (${artifactId}), unable to download artifact`); return null; } console.log(`Valid artifactId provided, downloadingArtifact: ${artifactId}`); @@ -72,7 +72,7 @@ async function downloadArtifact(artifactId) { function extractArtifact(zipPath) { if (!zipPath) { - console.log('Invalid zipPath provided, unable to extract artifact'); + console.log(`Invalid zipPath provided (${zipPath}), unable to extract artifact`); return null; } console.log(`Valid zipPath provided, extractingArtifact from: ${zipPath}`); From f56db47db1e41bca7aeafca9f6dd0d46056f2840 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:30:43 -0600 Subject: [PATCH 50/65] Moar logging --- .github/workflows/download-artifact.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index c7e4e9f..fe0c9ac 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -31,6 +31,7 @@ async function getArtifactId(runId) { console.log(`Invalid runId provided (${runId}), unable to get artifactId`); return null; } + console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; const response = await axios.get(url, { @@ -41,12 +42,16 @@ async function getArtifactId(runId) { console.log(`getArtifactId Response status: ${response.status}`); const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - if (artifact && artifact.name.includes('_')) { - let previousCount = artifact.name.split('_')[1]; - core.exportVariable('COMPONENT_COUNT', previousCount); - console.log(`artifactId = ${artifact.id}`); + + if (!artifact) { + console.log(`No artifact found for runId ${runId} with name: ${ARTIFACT_NAME}`); + return null; } - return artifact ? artifact.id : null; + + let previousCount = artifact.name.split('_')[1]; + core.exportVariable('COMPONENT_COUNT', previousCount); + console.log(`artifactId = ${artifact.id}`); + return artifact.id; } async function downloadArtifact(artifactId) { @@ -85,7 +90,7 @@ function extractArtifact(zipPath) { const artifactFilePath = path.join(extractPath, 'stryker-incremental.json'); if (fs.existsSync(artifactFilePath)) { - console.log(`Artifact file found at: ${artifactFilePath}`); + console.log(`Artifact file found at: ${artifactFilePath}!`); } else { console.log(`Artifact file ${artifactFilePath} not found`); } From d1e78e54c85091fa8fb44cd27df1ca761f7e1d50 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:34:30 -0600 Subject: [PATCH 51/65] Add more fake tests.. -for science --- .../app-footer/app-footer.component.spec.ts | 24 ++++++++++++++++++ src/app/app-footer/app-footer.component.ts | 11 ++++++++ src/app/app-home/app-home.component.spec.ts | 25 +++++++++++++++++++ src/app/app-home/app-home.component.ts | 11 ++++++++ 4 files changed, 71 insertions(+) diff --git a/src/app/app-footer/app-footer.component.spec.ts b/src/app/app-footer/app-footer.component.spec.ts index f6c0775..13a40ac 100644 --- a/src/app/app-footer/app-footer.component.spec.ts +++ b/src/app/app-footer/app-footer.component.spec.ts @@ -20,4 +20,28 @@ describe('AppFooterComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe("timesTwoTestChange", () => { + it("should return the input value multiplied by two", () => { + let results = component.timesTwo(2); + + expect(results).toBe(4); + }); + }); + + describe("timesFourTestChange", () => { + it("should return the input value multiplied by four", () => { + let results = component.timesFour(2); + + expect(results).toBe(8); + }); + }); + + describe("timesEightTest", () => { + it("should return the input value multiplied by eight", () => { + let results = component.timesEight(2); + + expect(results).toBe(16); + }); + }); }); diff --git a/src/app/app-footer/app-footer.component.ts b/src/app/app-footer/app-footer.component.ts index 4818149..fb3f10d 100644 --- a/src/app/app-footer/app-footer.component.ts +++ b/src/app/app-footer/app-footer.component.ts @@ -15,4 +15,15 @@ export class AppFooterComponent implements OnInit { ngOnInit(): void { } + timesTwo(entry: number): number { + return entry * 2; + } + + timesFour(entry: number): number { + return entry * 4; + } + + timesEight(entry: number): number { + return entry * 8; + } } diff --git a/src/app/app-home/app-home.component.spec.ts b/src/app/app-home/app-home.component.spec.ts index db9bbf8..a45293c 100644 --- a/src/app/app-home/app-home.component.spec.ts +++ b/src/app/app-home/app-home.component.spec.ts @@ -20,4 +20,29 @@ describe('AppHomeComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe("timesTwoTestChange", () => { + it("should return the input value multiplied by two", () => { + let results = component.timesTwo(2); + + expect(results).toBe(4); + }); + }); + + describe("timesFourTestChange", () => { + it("should return the input value multiplied by four", () => { + let results = component.timesFour(2); + + expect(results).toBe(8); + }); + }); + + describe("timesEightTest", () => { + it("should return the input value multiplied by eight", () => { + let results = component.timesEight(2); + + expect(results).toBe(16); + }); + }); + }); diff --git a/src/app/app-home/app-home.component.ts b/src/app/app-home/app-home.component.ts index d090cf6..13480b9 100644 --- a/src/app/app-home/app-home.component.ts +++ b/src/app/app-home/app-home.component.ts @@ -12,4 +12,15 @@ export class AppHomeComponent implements OnInit { ngOnInit(): void { } + timesTwo(entry: number): number { + return entry * 2; + } + + timesFour(entry: number): number { + return entry * 4; + } + + timesEight(entry: number): number { + return entry * 8; + } } From 907a8d95b79a89b8ac69fb546f02d64e1ef8a0f0 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:44:18 -0600 Subject: [PATCH 52/65] Rename env variables for clarity --- .github/workflows/determine-files.js | 12 ++++++------ .github/workflows/download-artifact.js | 2 +- .github/workflows/scheduled.yml | 16 ++++++++-------- stryker.config.mjs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index f82f59e..bb63ed6 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -26,7 +26,7 @@ async function getAllFiles(octokit, owner, repo, path) { try { const { context } = github; const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - let prevCount = parseInt(process.env.COMPONENT_COUNT, 10); + let prevCount = parseInt(process.env.FILESTOSTRYKE_COUNT, 10); const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src/app'); console.log("All files: ", allFiles); @@ -38,14 +38,14 @@ async function getAllFiles(octokit, owner, repo, path) { if (allFilesWithTests.length === 0) { console.log('No test files found'); - core.exportVariable('COMPONENT_FILES', ''); - core.exportVariable('COMPONENT_COUNT', 0); + core.exportVariable('FILESTOSTRYKE', ''); + core.exportVariable('FILESTOSTRYKE_COUNT', 0); } else if (allFilesWithTests.length > prevCount) { const filesToStryke = allFilesWithTests.slice(0, prevCount+1); - core.exportVariable('COMPONENT_FILES', filesToStryke.join(', ')); - core.exportVariable('COMPONENT_COUNT', prevCount+1); + core.exportVariable('FILESTOSTRYKE', filesToStryke.join(', ')); + core.exportVariable('FILESTOSTRYKE_COUNT', prevCount+1); } else { - core.exportVariable('COMPONENT_FILES', allFilesWithTests.join(', ')); + core.exportVariable('FILESTOSTRYKE', allFilesWithTests.join(', ')); } } catch (error) { diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index fe0c9ac..4790e63 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -49,7 +49,7 @@ async function getArtifactId(runId) { } let previousCount = artifact.name.split('_')[1]; - core.exportVariable('COMPONENT_COUNT', previousCount); + core.exportVariable('FILESTOSTRYKE_COUNT', previousCount); console.log(`artifactId = ${artifact.id}`); return artifact.id; } diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index fd69da8..0836f67 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -7,8 +7,8 @@ on: env: NODE_VERSION: "20.9.0" INCREMENTAL_PATH: reports/stryker-incremental.json - COMPONENT_COUNT: 1 - COMPONENT_FILES: '' + FILESTOSTRYKE_COUNT: 0 + FILESTOSTRYKE: '' jobs: buildClient: @@ -44,22 +44,22 @@ jobs: run: node .github/workflows/determine-files.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMPONENT_COUNT: ${{ env.COMPONENT_COUNT }} + FILESTOSTRYKE_COUNT: ${{ env.FILESTOSTRYKE_COUNT }} - name: Run Stryker run: | if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Incremental artifact found, continuing Stryker incremental run." - if [ "$COMPONENT_FILES" != '' ]; then - echo "Running Stryker incremental with $COMPONENT_FILES." + if [ "$FILESTOSTRYKE" != '' ]; then + echo "Running Stryker incremental with $FILESTOSTRYKE." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "No component files were defined to stryke. Unable to run Stryker incremental." fi else echo "No incremental artifact round, running Stryker as initial incremental run." - if [ "$COMPONENT_FILES" != '' ]; then - echo "Running Stryker with $COMPONENT_FILES." + if [ "$FILESTOSTRYKE" != '' ]; then + echo "Running Stryker with $FILESTOSTRYKE." npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "No component files were defined to stryke. Unable to run Stryker." @@ -70,7 +70,7 @@ jobs: # - name: Upload Stryker Incremental Report # uses: actions/upload-artifact@v4 # with: - # name: stryker-incremental_${{ env.COMPONENT_COUNT }} + # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} # path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report diff --git a/stryker.config.mjs b/stryker.config.mjs index 7bc42d1..41988b3 100644 --- a/stryker.config.mjs +++ b/stryker.config.mjs @@ -1,7 +1,7 @@ // @ts-check /** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */ const config = { - mutate: process.env.COMPONENT_FILES ? process.env.COMPONENT_FILES.split(', ') : [], + mutate: process.env.FILESTOSTRYKE ? process.env.FILESTOSTRYKE.split(', ') : [], testRunner: "karma", karma: { configFile: "karma.conf.js", From eb89d784561347fb9ca4e6c51b4ba72390383eef Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:51:33 -0600 Subject: [PATCH 53/65] Re-enable artifact uploading --- .github/workflows/determine-files.js | 4 ---- .github/workflows/scheduled.yml | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/determine-files.js b/.github/workflows/determine-files.js index bb63ed6..45ffe96 100644 --- a/.github/workflows/determine-files.js +++ b/.github/workflows/determine-files.js @@ -29,8 +29,6 @@ async function getAllFiles(octokit, owner, repo, path) { let prevCount = parseInt(process.env.FILESTOSTRYKE_COUNT, 10); const allFiles = await getAllFiles(octokit, context.repo.owner, context.repo.repo, 'src/app'); - console.log("All files: ", allFiles); - const allFilesWithTests = allFiles .filter(filename => filename.endsWith('.spec.ts')) .map(testFile => testFile.replace('.spec.ts', '.ts')); @@ -52,5 +50,3 @@ async function getAllFiles(octokit, owner, repo, path) { core.setFailed(error.message); } })(); - -//commenting a change to see what the next Stryker run does \ No newline at end of file diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 0836f67..e072235 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -67,11 +67,11 @@ jobs: fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - # - name: Upload Stryker Incremental Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} - # path: ${{ env.INCREMENTAL_PATH }} + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 + with: + name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} + path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From 22c077d05bd469afdce98217b94d879869390b76 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 11 Dec 2024 16:55:37 -0600 Subject: [PATCH 54/65] Remove commented out line --- .github/workflows/download-artifact.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 4790e63..c637253 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -107,5 +107,3 @@ function extractArtifact(zipPath) { console.error(`Error: ${error.message}`); } })(); - -// Commenting a change to see what the next Stryker run does \ No newline at end of file From 080c3769f6c52b1bffa2a58b9b19afdd2d92ec2b Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 09:53:02 -0600 Subject: [PATCH 55/65] Attempt with dynamic workflowId --- .github/workflows/download-artifact.js | 25 +++++++-- .github/workflows/scheduled.yml | 75 +++++++++++++------------- 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index c637253..9e12932 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -7,12 +7,26 @@ const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = process.env.OWNER; const REPO = process.env.REPO; -const WORKFLOW_ID = process.env.WORKFLOW_ID; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; -async function getLatestSuccessfulRun() { - console.log(`gettingLatestSuccessfulRun for ${WORKFLOW_ID}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs`; +async function getWorkflowId() { + console.log("getting WorkflowId"); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; + const response = await axios.get(url, { + headers: { Authorization: `token ${GITHUB_TOKEN}` } + }); + console.log(`getWorkflowId Response status: ${response.status}`); + const workflow = response.data.workflows.find(workflow => workflow.name === process.env.GITHUB_WORKFLOW); + return workflow ? workflow.id : null; +} + +async function getLatestSuccessfulRun(workflowId) { + if (!workflowId) { + console.log(`Invalid workflowId provided (${workflowId}), unable to get latest successful runId`); + return null; + } + console.log(`gettingLatestSuccessfulRun for ${workflowId}`); + const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, params: { @@ -98,7 +112,8 @@ function extractArtifact(zipPath) { (async () => { try { - const runId = await getLatestSuccessfulRun(); + const workflowId = await getWorkflowId(); + const runId = await getLatestSuccessfulRun(workflowId); const artifactId = await getArtifactId(runId); const zipPath = await downloadArtifact(artifactId); extractArtifact(zipPath); diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index e072235..91576d3 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -25,8 +25,8 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: npm install - run: npm i + # - name: npm install + # run: npm i - name: Install Temporary Dependencies run: npm install axios adm-zip @actions/core @actions/github @@ -37,44 +37,43 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} - WORKFLOW_ID: 116600610 ARTIFACT_NAME: stryker-incremental - - name: Determine Files to Stryke - run: node .github/workflows/determine-files.js - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - FILESTOSTRYKE_COUNT: ${{ env.FILESTOSTRYKE_COUNT }} + # - name: Determine Files to Stryke + # run: node .github/workflows/determine-files.js + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # FILESTOSTRYKE_COUNT: ${{ env.FILESTOSTRYKE_COUNT }} - - name: Run Stryker - run: | - if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then - echo "Incremental artifact found, continuing Stryker incremental run." - if [ "$FILESTOSTRYKE" != '' ]; then - echo "Running Stryker incremental with $FILESTOSTRYKE." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - else - echo "No component files were defined to stryke. Unable to run Stryker incremental." - fi - else - echo "No incremental artifact round, running Stryker as initial incremental run." - if [ "$FILESTOSTRYKE" != '' ]; then - echo "Running Stryker with $FILESTOSTRYKE." - npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - else - echo "No component files were defined to stryke. Unable to run Stryker." - fi - fi - echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV + # - name: Run Stryker + # run: | + # if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then + # echo "Incremental artifact found, continuing Stryker incremental run." + # if [ "$FILESTOSTRYKE" != '' ]; then + # echo "Running Stryker incremental with $FILESTOSTRYKE." + # npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + # else + # echo "No component files were defined to stryke. Unable to run Stryker incremental." + # fi + # else + # echo "No incremental artifact round, running Stryker as initial incremental run." + # if [ "$FILESTOSTRYKE" != '' ]; then + # echo "Running Stryker with $FILESTOSTRYKE." + # npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + # else + # echo "No component files were defined to stryke. Unable to run Stryker." + # fi + # fi + # echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - - name: Upload Stryker Incremental Report - uses: actions/upload-artifact@v4 - with: - name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} - path: ${{ env.INCREMENTAL_PATH }} + # - name: Upload Stryker Incremental Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} + # path: ${{ env.INCREMENTAL_PATH }} - - name: Upload Stryker Coverage Report - uses: actions/upload-artifact@v4 - with: - name: stryker-coverage - path: reports/mutation/mutation.html \ No newline at end of file + # - name: Upload Stryker Coverage Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-coverage + # path: reports/mutation/mutation.html \ No newline at end of file From c8edac9690f547189a8e31a3f427342f0952b329 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 09:59:19 -0600 Subject: [PATCH 56/65] Rename workflow and uncomment stuff --- .github/workflows/StrykerJS.yml | 79 +++++++++++++++++++++++++++++++++ .github/workflows/scheduled.yml | 79 --------------------------------- 2 files changed, 79 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/StrykerJS.yml delete mode 100644 .github/workflows/scheduled.yml diff --git a/.github/workflows/StrykerJS.yml b/.github/workflows/StrykerJS.yml new file mode 100644 index 0000000..c0c44a3 --- /dev/null +++ b/.github/workflows/StrykerJS.yml @@ -0,0 +1,79 @@ +name: StrykerJS + +on: + pull_request: + branches: ["master"] + +env: + NODE_VERSION: "20.9.0" + INCREMENTAL_PATH: reports/stryker-incremental.json + FILESTOSTRYKE_COUNT: 0 + FILESTOSTRYKE: '' + +jobs: + strykerJS_testing: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: npm install + run: npm i + + - name: Install Temporary Dependencies + run: npm install axios adm-zip @actions/core @actions/github + + - name: Download and Extract Incremental File + run: node .github/workflows/download-artifact.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + ARTIFACT_NAME: stryker-incremental + + - name: Determine Files to Stryke + run: node .github/workflows/determine-files.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILESTOSTRYKE_COUNT: ${{ env.FILESTOSTRYKE_COUNT }} + + - name: Run Stryker + run: | + if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then + echo "Incremental artifact found, continuing Stryker incremental run." + if [ "$FILESTOSTRYKE" != '' ]; then + echo "Running Stryker incremental with $FILESTOSTRYKE." + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + else + echo "No component files were defined to stryke. Unable to run Stryker incremental." + fi + else + echo "No incremental artifact round, running Stryker as initial incremental run." + if [ "$FILESTOSTRYKE" != '' ]; then + echo "Running Stryker with $FILESTOSTRYKE." + npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json + else + echo "No component files were defined to stryke. Unable to run Stryker." + fi + fi + echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV + + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 + with: + name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} + path: ${{ env.INCREMENTAL_PATH }} + + - name: Upload Stryker Coverage Report + uses: actions/upload-artifact@v4 + with: + name: stryker-coverage + path: reports/mutation/mutation.html \ No newline at end of file diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml deleted file mode 100644 index 91576d3..0000000 --- a/.github/workflows/scheduled.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: LetsLearnCI/CD - -on: - pull_request: - branches: ["master"] - -env: - NODE_VERSION: "20.9.0" - INCREMENTAL_PATH: reports/stryker-incremental.json - FILESTOSTRYKE_COUNT: 0 - FILESTOSTRYKE: '' - -jobs: - buildClient: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - - # - name: npm install - # run: npm i - - - name: Install Temporary Dependencies - run: npm install axios adm-zip @actions/core @actions/github - - - name: Download and Extract Incremental File - run: node .github/workflows/download-artifact.js - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} - ARTIFACT_NAME: stryker-incremental - - # - name: Determine Files to Stryke - # run: node .github/workflows/determine-files.js - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # FILESTOSTRYKE_COUNT: ${{ env.FILESTOSTRYKE_COUNT }} - - # - name: Run Stryker - # run: | - # if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then - # echo "Incremental artifact found, continuing Stryker incremental run." - # if [ "$FILESTOSTRYKE" != '' ]; then - # echo "Running Stryker incremental with $FILESTOSTRYKE." - # npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - # else - # echo "No component files were defined to stryke. Unable to run Stryker incremental." - # fi - # else - # echo "No incremental artifact round, running Stryker as initial incremental run." - # if [ "$FILESTOSTRYKE" != '' ]; then - # echo "Running Stryker with $FILESTOSTRYKE." - # npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json - # else - # echo "No component files were defined to stryke. Unable to run Stryker." - # fi - # fi - # echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - - # - name: Upload Stryker Incremental Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} - # path: ${{ env.INCREMENTAL_PATH }} - - # - name: Upload Stryker Coverage Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-coverage - # path: reports/mutation/mutation.html \ No newline at end of file From ad9d6e15bffb317a743a6524841b532bb689965c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:07:08 -0600 Subject: [PATCH 57/65] Update logic to search every successful run to find the most recent incremental artifact --- .github/workflows/download-artifact.js | 111 ++++++++++++++++--------- 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 9e12932..f33dd15 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -20,54 +20,88 @@ async function getWorkflowId() { return workflow ? workflow.id : null; } -async function getLatestSuccessfulRun(workflowId) { +// async function getLatestSuccessfulRun(workflowId) { +// if (!workflowId) { +// console.log(`Invalid workflowId provided (${workflowId}), unable to get latest successful runId`); +// return null; +// } +// console.log(`gettingLatestSuccessfulRun for ${workflowId}`); +// const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; +// const response = await axios.get(url, { +// headers: { Authorization: `token ${GITHUB_TOKEN}` }, +// params: { +// status: 'success', +// per_page: 1 +// } +// }); +// console.log(`getLatestSuccessfulRun Response status: ${response.status}`); +// const run = response.data.workflow_runs[0]; +// console.log(`latestSuccessfulRunId = ${run.id}`); +// return run ? run.id : null; +// } + +async function findLatestIncrementalArtifactId(workflowId) { if (!workflowId) { - console.log(`Invalid workflowId provided (${workflowId}), unable to get latest successful runId`); + console.log(`Invalid workflowId provided (${workflowId}), unable to find latest incremental artifact`); return null; } - console.log(`gettingLatestSuccessfulRun for ${workflowId}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; - const response = await axios.get(url, { + + console.log(`gettingWorkflowRuns for ${workflowId}`); + const workflowRunsUrl = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; + const response = await axios.get(workflowRunsUrl, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, params: { - status: 'success', - per_page: 1 + status: 'success' } }); - console.log(`getLatestSuccessfulRun Response status: ${response.status}`); - const run = response.data.workflow_runs[0]; - console.log(`latestSuccessfulRunId = ${run.id}`); - return run ? run.id : null; -} - -async function getArtifactId(runId) { - if (!runId) { - console.log(`Invalid runId provided (${runId}), unable to get artifactId`); - return null; - } - - console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); - const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; - const response = await axios.get(url, { - headers: { - Authorization: `token ${GITHUB_TOKEN}` + console.log(`gettingWorkflowRuns Response status: ${response.status}`); + const runs = response.data.workflow_runs; + + for (let i = 0; i < runs.length; i++) { + const runId = runs[i].id; + console.log(`gettingArtifacts for run #${i}, runId: ${runId}`); + const artifactsUrl = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; + const response = await axios.get(artifactsUrl, { headers: { Authorization: `token ${GITHUB_TOKEN}` } }); + console.log(`getArtifacts Response status: ${response.status}`); + + const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); + if (artifact) { + let previousCount = artifact.name.split('_')[1]; + core.exportVariable('FILESTOSTRYKE_COUNT', previousCount); + console.log(`artifactId = ${artifact.id}`); + return artifact.id; } - }); - - console.log(`getArtifactId Response status: ${response.status}`); - const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - - if (!artifact) { - console.log(`No artifact found for runId ${runId} with name: ${ARTIFACT_NAME}`); - return null; } - - let previousCount = artifact.name.split('_')[1]; - core.exportVariable('FILESTOSTRYKE_COUNT', previousCount); - console.log(`artifactId = ${artifact.id}`); - return artifact.id; } +// async function getArtifactId(runId) { +// if (!runId) { +// console.log(`Invalid runId provided (${runId}), unable to get artifactId`); +// return null; +// } + +// console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); +// const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; +// const response = await axios.get(url, { +// headers: { +// Authorization: `token ${GITHUB_TOKEN}` +// } +// }); + +// console.log(`getArtifactId Response status: ${response.status}`); +// const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); + +// if (!artifact) { +// console.log(`No artifact found for runId ${runId} with name: ${ARTIFACT_NAME}`); +// return null; +// } + +// let previousCount = artifact.name.split('_')[1]; +// core.exportVariable('FILESTOSTRYKE_COUNT', previousCount); +// console.log(`artifactId = ${artifact.id}`); +// return artifact.id; +// } + async function downloadArtifact(artifactId) { if (!artifactId) { console.log(`Invalid artifactId provided (${artifactId}), unable to download artifact`); @@ -113,8 +147,7 @@ function extractArtifact(zipPath) { (async () => { try { const workflowId = await getWorkflowId(); - const runId = await getLatestSuccessfulRun(workflowId); - const artifactId = await getArtifactId(runId); + const artifactId = await findLatestIncrementalArtifactId(workflowId); const zipPath = await downloadArtifact(artifactId); extractArtifact(zipPath); From 4b913e40c2b1175948266d90c00233447f1c5f83 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:10:14 -0600 Subject: [PATCH 58/65] Commenting out uploading the incremental report for testing --- .github/workflows/StrykerJS.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/StrykerJS.yml b/.github/workflows/StrykerJS.yml index c0c44a3..b9df849 100644 --- a/.github/workflows/StrykerJS.yml +++ b/.github/workflows/StrykerJS.yml @@ -66,11 +66,11 @@ jobs: fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - - name: Upload Stryker Incremental Report - uses: actions/upload-artifact@v4 - with: - name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} - path: ${{ env.INCREMENTAL_PATH }} + # - name: Upload Stryker Incremental Report + # uses: actions/upload-artifact@v4 + # with: + # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} + # path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From cc1c71dbedbe7a8382a0b07a7bcbf0b914f13867 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:12:24 -0600 Subject: [PATCH 59/65] Un-commenting out the upload to test new artifact search logic --- .github/workflows/StrykerJS.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/StrykerJS.yml b/.github/workflows/StrykerJS.yml index b9df849..c0c44a3 100644 --- a/.github/workflows/StrykerJS.yml +++ b/.github/workflows/StrykerJS.yml @@ -66,11 +66,11 @@ jobs: fi echo "INCREMENTAL_PATH=/home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json" >> $GITHUB_ENV - # - name: Upload Stryker Incremental Report - # uses: actions/upload-artifact@v4 - # with: - # name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} - # path: ${{ env.INCREMENTAL_PATH }} + - name: Upload Stryker Incremental Report + uses: actions/upload-artifact@v4 + with: + name: stryker-incremental_${{ env.FILESTOSTRYKE_COUNT }} + path: ${{ env.INCREMENTAL_PATH }} - name: Upload Stryker Coverage Report uses: actions/upload-artifact@v4 From 9644cf42c2fb2d155c0ab487b737ac2980ea0d3f Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:15:14 -0600 Subject: [PATCH 60/65] Adding fake tests to app.header to test strykerJS pipeline logic --- .../app-header/app-header.component.spec.ts | 24 +++++++++++++++++++ src/app/app-header/app-header.component.ts | 11 +++++++++ 2 files changed, 35 insertions(+) diff --git a/src/app/app-header/app-header.component.spec.ts b/src/app/app-header/app-header.component.spec.ts index 7ea9ad2..490967d 100644 --- a/src/app/app-header/app-header.component.spec.ts +++ b/src/app/app-header/app-header.component.spec.ts @@ -20,4 +20,28 @@ describe('AppHeaderComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe("timesTwoTestChange", () => { + it("should return the input value multiplied by two", () => { + let results = component.timesTwo(2); + + expect(results).toBe(4); + }); + }); + + describe("timesFourTestChange", () => { + it("should return the input value multiplied by four", () => { + let results = component.timesFour(2); + + expect(results).toBe(8); + }); + }); + + describe("timesEightTest", () => { + it("should return the input value multiplied by eight", () => { + let results = component.timesEight(2); + + expect(results).toBe(16); + }); + }); }); diff --git a/src/app/app-header/app-header.component.ts b/src/app/app-header/app-header.component.ts index 9a30cf8..05a34fa 100644 --- a/src/app/app-header/app-header.component.ts +++ b/src/app/app-header/app-header.component.ts @@ -11,5 +11,16 @@ export class AppHeaderComponent { content = new AppHeaderContent(); + timesTwo(entry: number): number { + return entry * 2; + } + + timesFour(entry: number): number { + return entry * 4; + } + + timesEight(entry: number): number { + return entry * 8; + } } From 6cb8d285873688a32186b36cfb10abc57d1b3ac8 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:25:38 -0600 Subject: [PATCH 61/65] Format logging info --- .github/workflows/StrykerJS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/StrykerJS.yml b/.github/workflows/StrykerJS.yml index c0c44a3..b86dd36 100644 --- a/.github/workflows/StrykerJS.yml +++ b/.github/workflows/StrykerJS.yml @@ -50,7 +50,7 @@ jobs: if [ -f /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json ]; then echo "Incremental artifact found, continuing Stryker incremental run." if [ "$FILESTOSTRYKE" != '' ]; then - echo "Running Stryker incremental with $FILESTOSTRYKE." + echo "Running Stryker incremental with:" && echo "$FILESTOSTRYKE" | tr ' ' '\n' npx stryker run --incremental --incrementalFile /home/runner/work/lets-learn-angular/lets-learn-angular/.github/workflows/extracted_artifact/stryker-incremental.json else echo "No component files were defined to stryke. Unable to run Stryker incremental." From 5f45a7a56dd36bb68953b3f1ba98c38334e6d79c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Mon, 16 Dec 2024 13:59:00 -0600 Subject: [PATCH 62/65] Update logging and remove commented out code --- .github/workflows/download-artifact.js | 68 ++++---------------------- 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index f33dd15..92f09ae 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -10,7 +10,7 @@ const REPO = process.env.REPO; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function getWorkflowId() { - console.log("getting WorkflowId"); + console.log("getWorkflowId"); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows`; const response = await axios.get(url, { headers: { Authorization: `token ${GITHUB_TOKEN}` } @@ -20,33 +20,13 @@ async function getWorkflowId() { return workflow ? workflow.id : null; } -// async function getLatestSuccessfulRun(workflowId) { -// if (!workflowId) { -// console.log(`Invalid workflowId provided (${workflowId}), unable to get latest successful runId`); -// return null; -// } -// console.log(`gettingLatestSuccessfulRun for ${workflowId}`); -// const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; -// const response = await axios.get(url, { -// headers: { Authorization: `token ${GITHUB_TOKEN}` }, -// params: { -// status: 'success', -// per_page: 1 -// } -// }); -// console.log(`getLatestSuccessfulRun Response status: ${response.status}`); -// const run = response.data.workflow_runs[0]; -// console.log(`latestSuccessfulRunId = ${run.id}`); -// return run ? run.id : null; -// } - async function findLatestIncrementalArtifactId(workflowId) { if (!workflowId) { - console.log(`Invalid workflowId provided (${workflowId}), unable to find latest incremental artifact`); + console.error(`Invalid workflowId provided (${workflowId}), unable to find latest incremental artifact`); return null; } - console.log(`gettingWorkflowRuns for ${workflowId}`); + console.log(`getWorkflowRuns for ${workflowId}`); const workflowRunsUrl = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${workflowId}/runs`; const response = await axios.get(workflowRunsUrl, { headers: { Authorization: `token ${GITHUB_TOKEN}` }, @@ -54,12 +34,12 @@ async function findLatestIncrementalArtifactId(workflowId) { status: 'success' } }); - console.log(`gettingWorkflowRuns Response status: ${response.status}`); + console.log(`getWorkflowRuns Response status: ${response.status}`); const runs = response.data.workflow_runs; for (let i = 0; i < runs.length; i++) { const runId = runs[i].id; - console.log(`gettingArtifacts for run #${i}, runId: ${runId}`); + console.log(`getArtifacts for run #${i}, runId: ${runId}`); const artifactsUrl = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; const response = await axios.get(artifactsUrl, { headers: { Authorization: `token ${GITHUB_TOKEN}` } }); console.log(`getArtifacts Response status: ${response.status}`); @@ -74,40 +54,12 @@ async function findLatestIncrementalArtifactId(workflowId) { } } -// async function getArtifactId(runId) { -// if (!runId) { -// console.log(`Invalid runId provided (${runId}), unable to get artifactId`); -// return null; -// } - -// console.log(`Valid runId provided, gettingArtifactId for run#: ${runId}`); -// const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/artifacts`; -// const response = await axios.get(url, { -// headers: { -// Authorization: `token ${GITHUB_TOKEN}` -// } -// }); - -// console.log(`getArtifactId Response status: ${response.status}`); -// const artifact = response.data.artifacts.find(artifact => artifact.name.includes(ARTIFACT_NAME)); - -// if (!artifact) { -// console.log(`No artifact found for runId ${runId} with name: ${ARTIFACT_NAME}`); -// return null; -// } - -// let previousCount = artifact.name.split('_')[1]; -// core.exportVariable('FILESTOSTRYKE_COUNT', previousCount); -// console.log(`artifactId = ${artifact.id}`); -// return artifact.id; -// } - async function downloadArtifact(artifactId) { if (!artifactId) { - console.log(`Invalid artifactId provided (${artifactId}), unable to download artifact`); + console.error(`Invalid artifactId provided (${artifactId}), unable to download artifact`); return null; } - console.log(`Valid artifactId provided, downloadingArtifact: ${artifactId}`); + console.log(`Valid artifactId provided, downloadArtifact #${artifactId}`); const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${artifactId}/zip`; const response = await axios.get(url, { headers: { @@ -125,10 +77,10 @@ async function downloadArtifact(artifactId) { function extractArtifact(zipPath) { if (!zipPath) { - console.log(`Invalid zipPath provided (${zipPath}), unable to extract artifact`); + console.error(`Invalid zipPath provided (${zipPath}), unable to extract artifact`); return null; } - console.log(`Valid zipPath provided, extractingArtifact from: ${zipPath}`); + console.log(`Valid zipPath provided, extractArtifact from: ${zipPath}`); const zip = new AdmZip(zipPath); const extractPath = path.join(__dirname, 'extracted_artifact'); @@ -140,7 +92,7 @@ function extractArtifact(zipPath) { if (fs.existsSync(artifactFilePath)) { console.log(`Artifact file found at: ${artifactFilePath}!`); } else { - console.log(`Artifact file ${artifactFilePath} not found`); + console.error(`Artifact file ${artifactFilePath} not found`); } } From d355a056d015b2969ef8a7c1f76d83b3f2737d2a Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 18 Dec 2024 15:30:55 -0600 Subject: [PATCH 63/65] Use context to define owner and repo --- .github/workflows/StrykerJS.yml | 2 -- .github/workflows/download-artifact.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/StrykerJS.yml b/.github/workflows/StrykerJS.yml index b86dd36..e3231bf 100644 --- a/.github/workflows/StrykerJS.yml +++ b/.github/workflows/StrykerJS.yml @@ -35,8 +35,6 @@ jobs: run: node .github/workflows/download-artifact.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} ARTIFACT_NAME: stryker-incremental - name: Determine Files to Stryke diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 92f09ae..38e8e0d 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -5,8 +5,8 @@ const fs = require('fs'); const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; -const OWNER = process.env.OWNER; -const REPO = process.env.REPO; +const OWNER = context.repo.owner; +const REPO = context.repo.repo; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function getWorkflowId() { From de2c2bf6234820100381683361c44dec3b7e072f Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 18 Dec 2024 15:33:44 -0600 Subject: [PATCH 64/65] Try it this way, lol --- .github/workflows/download-artifact.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 38e8e0d..73d436f 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -5,8 +5,8 @@ const fs = require('fs'); const path = require('path'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; -const OWNER = context.repo.owner; -const REPO = context.repo.repo; +const OWNER = `${context.repo.owner}`; +const REPO = `${context.repo.repo}`; const ARTIFACT_NAME = process.env.ARTIFACT_NAME; async function getWorkflowId() { From e119f80b95ca65499b231b345befd17b52decf0c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 18 Dec 2024 15:37:17 -0600 Subject: [PATCH 65/65] Import context --- .github/workflows/download-artifact.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/download-artifact.js b/.github/workflows/download-artifact.js index 73d436f..8ff821d 100644 --- a/.github/workflows/download-artifact.js +++ b/.github/workflows/download-artifact.js @@ -3,6 +3,7 @@ const AdmZip = require('adm-zip'); const core = require('@actions/core'); const fs = require('fs'); const path = require('path'); +const { context } = require('@actions/github'); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const OWNER = `${context.repo.owner}`;