Skip to content

Commit

Permalink
Post screenshots to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Jeffery committed Oct 3, 2024
1 parent 996ff1c commit d5bdff7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
push:
branches: [main, test]

permissions:
contents: read
issues: write
pull-requests: write

jobs:
pre-commit:
name: Lint
Expand Down Expand Up @@ -59,13 +64,41 @@ jobs:
msp simulate --length 1000 --recombination-rate 0.01 --mutation-rate 0.01 100 out.trees
python -m tsbrowse preprocess out.trees
python -m tsbrowse screenshot out.tsbrowse mutations
python -m tsbrowse screenshot out.tsbrowse edges
python -m tsbrowse screenshot out.tsbrowse nodes
- name: Upload Screenshot Artifact
uses: actions/upload-artifact@v3
with:
name: screenshots
path: "*.png"

- name: Post Screenshots to PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = process.env.GITHUB_WORKSPACE;
const screenshotDir = path;
const imageFiles = fs.readdirSync(screenshotDir).filter(file => file.endsWith('.png'));
if (imageFiles.length > 0) {
let imagesMarkdown = '';
for (const file of imageFiles) {
const filePath = `${screenshotDir}/${file}`;
const imageData = fs.readFileSync(filePath, { encoding: 'base64' });
imagesMarkdown += `![${file}](data:image/png;base64,${imageData})\n`;
}
const body = `<details><summary>PR Screenshots</summary>\n${imagesMarkdown}\n</details>`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}
- name: Upload coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit d5bdff7

Please sign in to comment.