-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2030 from PrincetonUniversity/devel
Devel
- Loading branch information
Showing
17 changed files
with
911 additions
and
231 deletions.
There are no files selected for viewing
This file contains 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,64 @@ | ||
name: "Add doc diff to PR comment" | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["PsyNeuLink Docs Compare"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
post-comment: | ||
runs-on: ubuntu-latest | ||
if: > | ||
${{ github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
|
||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name.startsWith("compare") | ||
}).slice(-1)[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); | ||
- name: Unzip artifact | ||
run: unzip pr.zip | ||
|
||
- name: Post comment with docs diff | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var fs = require("fs"); | ||
var issue_number = Number(fs.readFileSync('./PR_NR')); | ||
var os = fs.readFileSync('./PR_OS', 'utf8').trim(); | ||
var python = fs.readFileSync('./PR_PYTHON_VERSION', 'utf8').trim(); | ||
var text = fs.readFileSync("./result.diff").slice(0,16384); | ||
// basic input checks | ||
console.assert(['ubuntu-latest', 'windows-latest', 'macos-latest'].includes(os), 'Unexpected os: %s', os); | ||
console.assert(['3.6', '3.7', '3.8'].includes(python), 'Unexpected python: %s', python); | ||
console.assert(!text.includes('```'), 'Invalid diff!'); | ||
console.log('Posting diff to PR:' + issue_number) | ||
github.issues.createComment({ | ||
issue_number: issue_number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'This PR causes the following changes to the html docs (' + os + ', python-' + python + '):\n```\n' + text + '\n...\n```\nSee CI logs for the full diff.' | ||
}) | ||
This file contains 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 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 |
---|---|---|
|
@@ -87,30 +87,18 @@ jobs: | |
- name: Compare | ||
shell: bash | ||
run: | | ||
mkdir -p compare | ||
# Store the resulting diff, or 'No differences!' to and output file | ||
# The 'or true' part is needed to workaourd 'pipefail' flag used by github-actions | ||
(diff -r docs-base docs-merge && echo 'No differences!' || true) | tee result.diff | ||
- name: Post comment | ||
uses: actions/[email protected] | ||
# Post comment only if not PR across repos | ||
# if: ${{ github.event.base.full_name }} == ${{ github.event.head.repo.full_name }} | ||
# The 'or true' part is needed to workaround 'pipefail' flag used by github-actions | ||
(diff -r docs-base docs-merge && echo 'No differences!' || true) | tee ./compare/result.diff | ||
# save PR number | ||
echo ${{ github.event.number }} > ./compare/PR_NR | ||
echo ${{ matrix.os }} > ./compare/PR_OS | ||
echo ${{ matrix.python-version }} > ./compare/PR_PYTHON_VERSION | ||
- name: Upload comparison results | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
// Post comment only if not PR across repos | ||
console.log(context.payload.pull_request.base.repo.full_name) | ||
console.log(context.payload.pull_request.head.repo.full_name) | ||
var base_repo_name = context.payload.pull_request.base.repo.full_name | ||
var head_repo_name = context.payload.pull_request.head.repo.full_name | ||
if (base_repo_name != head_repo_name) return ; | ||
var fs = require("fs"); | ||
var text = fs.readFileSync("./result.diff").slice(0,16384); | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'This PR causes the following changes to the html docs (${{ matrix.os }}, python-${{ matrix.python-version }}):\n```\n' + text + '\n...\n```\nSee CI logs for the full diff.' | ||
}) | ||
name: compare-${{ matrix.os }}-${{ matrix.python-version }} | ||
path: compare | ||
retention-days: 1 |
This file contains 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 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 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.