-
Notifications
You must be signed in to change notification settings - Fork 3
Attempt incremental run and upload incremental report #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saleazer
wants to merge
66
commits into
master
Choose a base branch
from
incremental_strykesss
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
b0fb37b
Attempt incremental run and upload incremental report
saleazer 5ac1db1
Attempt to retrieve incremental report for next run
saleazer dbbb9cb
Change test name for incremental diff
saleazer 0335290
Add mega logging to JS..
saleazer 4614ddd
Fetch the workflow id
saleazer a4e26c8
Change paths to reports folder
saleazer 3340e36
Redo logging and change filepath
saleazer 3495c30
Debugging setup
saleazer c8485d4
Remove useless debugging and fix upload paths
saleazer bf02e15
Another debug
saleazer 47b7278
Fix typo
saleazer 52209fa
Fix more mistakes
saleazer 20cc584
Tryin' something else, ugh
saleazer 677fb96
Changing tests to test incremental stryker
saleazer 5c59ced
Try full path name for incremental.json
saleazer 2dbc282
Fix the other path too, d'oh
saleazer 56c4892
Add leading slash to urls
saleazer 6579ba1
Fix upload path
saleazer e63a7bc
Update path logic depending on which run runs
saleazer 66d1acf
Test change to trigger incremental run
saleazer debb3c3
Update config to stryke all component files
saleazer 91f4f0a
Clean up JS logging
saleazer a41fd27
Attempt clean stryker run from scratch with no starting file
saleazer 3141a6f
Add back incremental file to workflow
saleazer 00cd11c
Attempt wild component incrementing scheme, haha
saleazer 5909890
Fix mistake in octokit call
saleazer 6db0f9f
Try to fix token issue
saleazer 25e90b2
Fix else/if syntax for stryker run logic
saleazer 3869548
Try to stryke all files that have a .spec file
saleazer cc7400b
Merge branch 'master' into incremental_strykesss
saleazer 52aadfd
Fix mistakes in .js logic
saleazer 157d630
Change a few logging lines for clarity
saleazer 81f1ba7
Big logic change for stryking + reset count back to 0
saleazer 6c2f1bb
Fix missed renambed variable
saleazer f02ab56
Fix stupid mistake
saleazer 4d73152
BIG logic change, using stryker.config for files, etc
saleazer 4485e05
Fix missed variable rename
saleazer 079d1ad
Re-implement getting prev count from artifact to continue the stryking
saleazer df27bba
Adding a comment to inspect what the next run does
saleazer 80c633c
Forcing NULL artifact workflow to test fresh incremental run
saleazer df263c4
Update files to match glob pattern for stryker.config
saleazer 4cd883a
Add logging to check files
saleazer 79db320
Adding random tests to check progress
saleazer 85b4dd8
Add incrementalFile path to npx command
saleazer 4a2529e
Update logging for clarity and null guard artifact
saleazer f8fb545
Temporarily remove uploading artifact to test something
saleazer 522654c
Commenting a change to see what the next run does
saleazer b9c00a4
Move console log to prevent errors
saleazer 9666f7f
Rework logic in artifact download
saleazer aa0a6a1
Update logging for clarity
saleazer f56db47
Moar logging
saleazer d1e78e5
Add more fake tests.. -for science
saleazer 907a8d9
Rename env variables for clarity
saleazer eb89d78
Re-enable artifact uploading
saleazer 22c077d
Remove commented out line
saleazer 080c376
Attempt with dynamic workflowId
saleazer c8edac9
Rename workflow and uncomment stuff
saleazer ad9d6e1
Update logic to search every successful run to find the most recent i…
saleazer 4b913e4
Commenting out uploading the incremental report for testing
saleazer cc1c71d
Un-commenting out the upload to test new artifact search logic
saleazer 9644cf4
Adding fake tests to app.header to test strykerJS pipeline logic
saleazer 6cb8d28
Format logging info
saleazer 5f45a7a
Update logging and remove commented out code
saleazer d355a05
Use context to define owner and repo
saleazer de2c2bf
Try it this way, lol
saleazer e119f80
Import context
saleazer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| 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 }} | ||
| 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:" && 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." | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.FILESTOSTRYKE_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')); | ||
| console.log("All files with tests: ", allFilesWithTests); | ||
|
|
||
| if (allFilesWithTests.length === 0) { | ||
| console.log('No test files found'); | ||
| core.exportVariable('FILESTOSTRYKE', ''); | ||
| core.exportVariable('FILESTOSTRYKE_COUNT', 0); | ||
| } else if (allFilesWithTests.length > prevCount) { | ||
| const filesToStryke = allFilesWithTests.slice(0, prevCount+1); | ||
| core.exportVariable('FILESTOSTRYKE', filesToStryke.join(', ')); | ||
| core.exportVariable('FILESTOSTRYKE_COUNT', prevCount+1); | ||
| } else { | ||
| core.exportVariable('FILESTOSTRYKE', allFilesWithTests.join(', ')); | ||
| } | ||
|
|
||
| } catch (error) { | ||
| core.setFailed(error.message); | ||
| } | ||
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| const axios = require('axios'); | ||
| 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}`; | ||
| const REPO = `${context.repo.repo}`; | ||
| const ARTIFACT_NAME = process.env.ARTIFACT_NAME; | ||
|
|
||
| async function getWorkflowId() { | ||
| 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}` } | ||
| }); | ||
| 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 findLatestIncrementalArtifactId(workflowId) { | ||
| if (!workflowId) { | ||
| console.error(`Invalid workflowId provided (${workflowId}), unable to find latest incremental artifact`); | ||
| return null; | ||
| } | ||
|
|
||
| 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}` }, | ||
| params: { | ||
| status: 'success' | ||
| } | ||
| }); | ||
| 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(`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}`); | ||
|
|
||
| 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; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function downloadArtifact(artifactId) { | ||
| if (!artifactId) { | ||
| console.error(`Invalid artifactId provided (${artifactId}), unable to download artifact`); | ||
| return null; | ||
| } | ||
| 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: { | ||
| 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) { | ||
| if (!zipPath) { | ||
| console.error(`Invalid zipPath provided (${zipPath}), unable to extract artifact`); | ||
| return null; | ||
| } | ||
| console.log(`Valid zipPath provided, extractArtifact from: ${zipPath}`); | ||
| const zip = new AdmZip(zipPath); | ||
| const extractPath = path.join(__dirname, 'extracted_artifact'); | ||
|
|
||
| zip.extractAllTo(extractPath, true); | ||
| 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.error(`Artifact file ${artifactFilePath} not found`); | ||
| } | ||
| } | ||
|
|
||
| (async () => { | ||
| try { | ||
| const workflowId = await getWorkflowId(); | ||
| const artifactId = await findLatestIncrementalArtifactId(workflowId); | ||
| const zipPath = await downloadArtifact(artifactId); | ||
| extractArtifact(zipPath); | ||
|
|
||
| } catch (error) { | ||
| console.error(`Error: ${error.message}`); | ||
| } | ||
| })(); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First test comment for Webhook POC
Edit: 5th edit